This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to create a new target of a project by makefile(nRF52810)?

Hi, I would like to create a new target,but nRF52810 only can be compiled with makefile and I don't know makefile too much.

I try to edit the makefile with my own target name:

PROJECT_NAME := Smart_Remote_3_nRF52_Firmware_nRF52810

Before:
TARGETS := PCA20031-SR3_nRF52810_Product_Example

After:

TARGETS := ABCDEFG


OUTPUT_DIRECTORY := _build
#_build

SDK_ROOT := ../../../../../..
PROJ_DIR := ../../..

Before:

$(OUTPUT_DIRECTORY)/PCA20031-SR3_nRF52810_Product_Example.out: \

After:

$(OUTPUT_DIRECTORY)/ABCDEFG.out: \

LINKER_SCRIPT := Smart_Remote_3_nRF52_gcc_nrf52.ld

# Source files common to all targets
SRC_FILES += \
$(PROJ_DIR)/Source/Drivers/drv_acc_lis3dh.c \
$(PROJ_DIR)/Source/Drivers/drv_audio_anr.c \
.........

# Include folders common to all targets

INC_FOLDERS += \
$(PROJ_DIR)/Source/Modules \
$(PROJ_DIR)/Source/Libraries/bv32fp-1.2 \
........

# Libraries common to all targets
LIB_FILES += \
$(SDK_ROOT)/external/nrf_cc310/lib/libcc310_gcc_0.9.0.a \
$(PROJ_DIR)/Source/Libraries/vocal_anr_gcc.a \
$(SDK_ROOT)/external/micro-ecc/nrf52nf_armgcc/armgcc/micro_ecc_lib_nrf52.a \

# Optimization flags
OPT = -O1 -g3
# Uncomment the line below to enable link time optimization
#OPT += -flto

# C flags common to all targets
CFLAGS += $(OPT)
CFLAGS += -DCONFIG_DEBUG_BUILD=0
................

# C++ flags common to all targets
CXXFLAGS += $(OPT)

# Assembler flags common to all targets
ASMFLAGS += -g3
ASMFLAGS += -mcpu=cortex-m4
................

# Linker flags
LDFLAGS += $(OPT)
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
LDFLAGS += -mcpu=cortex-m4
# let linker dump unused sections
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -flto -specs=nano.specs

before:

PCA20031-SR3_nRF52810_Product_Example: CFLAGS += -DCONFIG_BOARD_NRF52810_PCA20031
PCA20031-SR3_nRF52810_Product_Example: ASMFLAGS += -DCONFIG_BOARD_NRF52810_PCA20031

after:
ABCDEFG: CFLAGS += -DCONFIG_BOARD_ABCDEFG
ABCDEFG: ASMFLAGS += -DCONFIG_BOARD_ABCDEFG

And it seems that the CONFIG_BOARD_ABCDEFG is not defined ,according to compile error message.

What else should I do?

Parents
  • Hi,

    The CONFIG_BOARD_xxx symbol defines which board header file to include in the project, see sr3_config.h line 89. You can edit this file if you want to use a custom board header.  

  • Hi, Vidar Berg

    I have already included my own custom board header with  my own CONFIG_BOARD_xxx defines, which can be compiled and runs on the board, but still in the same Target  PCA20031-SR3_nRF52810_Product_Example.

    The problem is If I change the TARGETS to my own custom name(ABCDEFG) in makefile, gcc will just show  my CONFIG_BOARD_xxx is not defined even I have.

    BTW, 

    I want to use Eclipse to compile costume target instead of manually modify the makefile, because I find your blog of 

     "development with GCC and Eclipse".

    My environment:

    GNU MCU Eclipse IDE for C/C++ Developers: 4.4.2

    GNU Tools ARM Embedded: 4.9 2015q3

    GNU MCU Eclipse build tool 2.11

    nRF5x SDK v14.2.0-SR3 

    And I encounter some problems by follow your tutorial:

    1.my Eclipse IDE's "C/C++->Build->Global Tools path" is missing.

    I check around and find another locations have similar things in Preferences "MCU->Global Build Tools Path/Global ARM Toolchains Path"  

    Can I use this MCU location instead of C/C++ location?

    2.RUN/Debug also cant find SGGER J-Link but does in MUC->Workspace SGGER Jlink Path.

    3. My nRF SDK14.2 doesn't have .project and .cproject  file,Can I use the file in your attachments(SDK12)?

    Thanks

  • Hi,

    I would recommend you to use Segger embedded studio. The Eclipse setup described in the blog post still requires editing of the makefile when you need to add a new source files, etc. Starting from SDK version 14 we included Segger embedded Studio projects for all examples. 

    Unfortunately, the smart remote examples do not include SES support yet. What you can do is to copy one of the the examples from SDK 14, \ble_app_hrs\pca10040e\s112\ses for instance, open the *emproject file in a text editor, then edit it according to to the Makefile (eg., add/remove necessary source files).

  • Hi, if just some normal editings of makefile is fine to me, can I still use eclipse to do my project? 

Reply Children
Related