Compilation dependencies on which board type (in CMakeList.txt and/or prj.conf)

I have a project that has two different types of custom boards. I have created board support packages for each. Is there a way to include different kconfigs in the CMakeLists.txt ? For instance I have the following in my CMakeLists.txt file:

If the build is for board A, it would contain the line:

#list(APPEND EXTRA_CONF_FILE "boardA.conf")
If the build is for board B, it would contain the line:
#list(APPEND EXTRA_CONF_FILE "boardB.conf")
How about a similar condition in the prj.conf ?
  • Hi,

    In our board files we have a Kconfig.board file, which contains something like:

    config BOARD_NRF52833DK_NRF52833
    	bool "NRF52833 DK NRF52833"
    	depends on SOC_NRF52833_QIAA
    

    There is also a <board>_defconfig file, in this case nrf52833dk_nrf52833_defconfig, which among other configs contains:

    CONFIG_SOC_SERIES_NRF52X=y
    CONFIG_SOC_NRF52833_QIAA=y
    CONFIG_BOARD_NRF52833DK_NRF52833=y

    If your custom boards are set up in this way also, you can use if(), elseif() and endif() to only include the desired line:

    if (CONFIG_BOARD_A)
        list(APPEND EXTRA_CONF_FILE "boardA.conf")
    elseif(CONFIG_BOARD_B)
        list(APPEND EXTRA_CONF_FILE "boardB.conf")
    endif()

    Hope that helps

  • Yes. Thank you. One follow up question: Can the same thing be done from a *.conf file, or is the syntax different? Let's say I want to set up a boot signature key depending on the board type in the child_image\mcuboot.conf

    CONFIG_BOOT_SIGNATURE_KEY_FILE="signingKey-BoardA.pem"
    CONFIG_BOOT_SIGNATURE_KEY_FILE="signingKey-BoardB.pem"
  • Add conf files with the name of each board. In a boards folder, or directly in the project folder.

    my_project/board_a.conf
    or
    my_project/boards/board_a.conf

    Then put the board specific configs in that conf file. It will be automatically included alongside the configs in prj.conf. If a config appears in both prj.conf and board_a.conf, the value in board_a.conf will be used in the build.

  • It doesn't recognize it from there, as it needs to be in the mcuboot child_image directory. Anyway to do if-elseif statements from within the mcuboot.conf ?

  • You can do it in your CMakeLists.txt. Make an mcubootA.conf and mcubootB.conf, and add them in the if-blocks you made, using:

    add_overlay_config(
        mcuboot
        ${CMAKE_CURRENT_SOURCE_DIR}/mcubootA.conf
    )

    Not 100% sure if this will work properly with the child_image/mcuboot.conf. You may need to remove it and add its contents to both files.

Related