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

Include app_config definitions in Makefile

I'm developing firmware for the nRF52832 in eclipse, and since I'm using the NFC pins as GPIOs I need to include the "CONFIG_NFCT_PINS_AS_GPIOS" cflag in my Makefile. However, I don't want to make this change on the nRF52 DK which I want the firmware to be backwards compatible with.

How should I include the -DCONFIG_NFCT_PINS_AS_GPIOS (or any other define) based on the board type I define in app_config.h?

Another example of this is that I see "ASMFLAGS += -DBOARD_PCA10040" defined in the makefile which I don't think I want to have defined when building for the custom board.

  • Hi,

    The normal way to do this is to have one makefile for each board. You have one makefile for the PCA10040, and a different makefile for your custom board.

    So for your makefile that you use for the PCA10040, you have the "ASMFLAGS += -DBOARD_PCA10040" , and you dont have the -DCONFIG_NFCT_PINS_AS_GPIOS flag.

    For the makefile for you custom board, you should create your own board file. When creating a new board file, simply copy the pca10040.h file, rename it, and modify it after your requirements(change pin configuration, number of buttons, leds, etc). Then you have to modify boards.h to support your new file, and add a new define that you can specify in the makefile for your custom board.

    Modify boards.h to support your new file:

    ..
    #elif defined(BOARD_CUSTOM)
      #include "custom_board.h"
    ..
    

    In the makefile for your custom board, you then have the ASMFLAGS += -DBOARD_CUSTOM and the DCONFIG_NFCT_PINS_AS_GPIOS flag defined.

Related