The BOARD variable is not defined at the top of CmakeLists.txt on ncs2.8.0

I work test program on ncs2.8.0.

I put a reference to the BOARD variable at the top of my project's CMakeLists.txt.

When "west build -b nrf52833dk_nrf52833",  BOARD is not defined.

But,

When "cmake -GNinja -DBOARD=nrf52833dk_nrf52833 ..",  BOARD is nrf52833dk_nrf52833.

This was not a problem in ncs2.6.0.
Please tell me how to reference the BOARD in ncs2.8.0.

Parents Reply Children
  • Hi,

    You can do this in the file sysbuild.cmake when using sysbuild. If you do not have this file in your project already, create it. If you want to add, for example, prj_release.conf when building for nRF52833 DK, add the following to sysbuild.cmake:

    if(SB_CONFIG_BOARD_NRF52833DK_NRF52833)
        set(${DEFAULT_IMAGE}_CONF_FILE "prj_release.conf" CACHE INTERNAL "")
    endif()

    Best regards,
    Marte

  • Thanks.

    Is it possible to use the board specified in BOARD_ROOT for the board used in sysbuild?

  • Hi,

    You can use BOARD for this, just note that in sysbuild the board is nrf52833dk and not nrf52833dk_nrf52833:

    if(BOARD STREQUAL nrf52833dk)
        set(${DEFAULT_IMAGE}_CONF_FILE "prj_release.conf" CACHE INTERNAL "")
    endif()

    Using BOARD_ROOT will not work, as this is a list with all board roots, not just the board root for the custom board. For example, here I set the project directory as board root using -DBOARD_ROOT, but the full BOARD_ROOT contains the nrf and zephyr directories as well:

    Is there any reason why you cannot have the board specific configuration files as extra Kconfig files instead? For example, have one prj.conf that has all the Kconfig options that are common for all boards, then have board specific files such as nrf52833dk_nrf52833.conf. If these files are in your project directory, they should automatically be added to the build if you build for a board target that matches the filename.

    Best regards,
    Marte

  • OK.Thanks.

    It seems like I can do what I want to do.

Related