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

Define BOARD_CUSTOM not working in SDK12 with GCC

I can't seem to add custom pin definitions to my own board in SDK12. I use the BOARD_CUSTOM define and copied my PCA10040 header file to one call custom_board.h and my pin assignments do not change. The only warnings I get are from bad paths to the config folder which is new since moving to SDK12.image description

  • I just tested this using the PCA10028 and it works OK

    You could try cleaning the project in case it didn't get recompiled

    make clean
    

    Are you sure it worked before you changed the pin assignment ?

  • I can directly edit the pca10040.h file and change the pin assignments but that's not the correct way to do it. As far as I can tell define BOARD_CUSTOM does NOTHING.

  • Look in examples\bsp\boards.h line 45

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

    Defining BOARD_CUSTOM in the makefile causes custom_board.h to be included

    Note

    -DBOARD_PCA10040
    

    occurs in 2 places in the makefile, once for C files and once for assembler files

    I quick way of checking if custom_board.h is being included is just to put

    #error Board is included
    

    into that header

    If the file is being included your compile will stop at that point

    (Or you could use #warning.. I often just write something like AAAAAAAAAAAAAAAAAAAAA into a file, and that fails compilation as well ;-)

  • Hi Roger,

    Reading the docs for SDK12 under the heading "Using the SDK with other boards" it states "You can then select to use the custom board by adding the define statement #define BOARD_CUSTOM". This is what I'm doing which does not work. Using your error debug method I can see where is selects PCA10040 header file but never my custom_board file.

  • If you are using gcc and the makefile, the definition for the board is set inside the makefile and not using a #define in a header

    The SDK is slightly misleading, as it applies to all build platforms e.g. Keil and IAR as well as gcc, and each of them will have a different way to add the define.

    If you add

    #define BOARD_CUSTOM  
    

    To a header that is included by the whole project, this will cause a problem, as the define for the PCA board will still be defined in the makefile.

    the

    -DXXX
    

    flag for the gcc compiler (preprocessor) is the same as

    #define XXX
    

    So, you need to change the lines in the makefile which have

    -DBOARD_PCA10040
    

    to

    -DBOARD_CUSTOM
    

    This occurs in 2 places, once for the CFLAGS and once for the ASMFLAGS

Related