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
  • Hi,

    Can you clarify what you mean by "putting a reference to the BOARD variable at the top of CMakeLists.txt"?

    Do you see any difference if you use nrf52833dk/nrf52833 as the board target instead of nrf52833dk_nrf52833?

    Best regards,
    Marte

  • Simply put,

    CMakeList.txt
    -----------------------------------------------------------------------------------------
    message("BOARD is ${BOARD}")
    ...
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(my_project)
    ...
    -----------------------------------------------------------------------------------------
    When I run "west build -b nrf52833dk_nrf52833"

    on NCS2.6.0
    BOARD is nrf52833dk_nrf52833

    on NCS2.8.0
    BOARD is

  • Hi,

    This is most likely due to sysbuild.
    However, it works in v2.8.0 as well if you call it after find_package:

    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(NONE)
    
    message("BOARD is ${BOARD}")

    Please note that in v2.7.0 and later, you should use nrf52833dk/nrf52833 instead of nrf52833dk_nrf52833 due to hardware model v2.

    Best regards,
    Marte

  • find_package() reads prj.conf etc.
    However, we want to switch prj.conf for each board.
    To do that, we need to determine the BOARD variable before executing find_package().
    Please tell me how to get the value that will be set for BOARD before calling find_package().

  • 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

Reply
  • 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

Children
No Data
Related