How to override automatic BOARD_ROOT in VS Code extension

I'm using VS Code 1.81.1 on Windows 10. The behavior described below occurs with (at least) nRF Connect extension versions 2023.4.179, 2023.6.345, and 2023.7.129.

When I add a build configuration in my application I select a board (a custom board I've created for nRF5340) and leave the other selections at their default (Configuration is "Use build system default"; no Kconfig nor extra CMake arguments; Build directory is "build"; the box is checked to "Build after generating configuration"). Then I click the Build Configuration button.

Near the beginning of the build process a CMake warning is emitted like the following:

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: Z:/home/user/repo/nrf-docker/src/nrf5340
-- Found Python3: C:/ncs/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.3.0/zephyr/.cache
-- Zephyr version: 3.2.99 (C:/ncs/v2.3.0/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
CMake Warning at C:/ncs/v2.3.0/zephyr/cmake/modules/boards.cmake:88 (message):
  BOARD_ROOT element without a 'boards' subdirectory:
 
  /home/user/repo/nrf-docker/src/nrf9160/boards/arm/custom_board_nrf9160_ns

Clearly there's a problem with my BOARD_ROOT: it contains a path that it should not contain. The path exists but it's unrelated to the present project (and it should not include the boards/* portion). I'd like to entirely remove it from the BOARD_ROOT variable. I edit my build configuration and find that the Extra CMake arguments field contains -DBOARD_ROOT:STRING= which is set to a whole series of paths. There's an entry here relating to most, but not all, of the applications I have open in my VS Code workspace. It's not  clear why the nRF Connect extension has chosen to include all of these, but in any case, I click the pencil icon to edit and reduce it to -DBOARD_ROOT:STRING="z:/home/user/repo/nrf-docker/src/nrf5340". My custom board is defined in boards/ under this directory. I click OK, then Build Configuration.

The same warning occurs; I visit the Edit Build Configuration page again and find that my BOARD_ROOT change has been replaced with the auto-generated string again.

Am I wrong to think I should be able to to change the BOARD_ROOT setting in this way? If I'm correct, how can I make it work?

  • Hi,

    Generally I would recommend using the Toolchain manager on Windows, and then you will get the environment we test (including with nRF Connect for VS Code). But regardless, you can provide the Board Root by setting nrf-connect.boardRoots in your VS Code settings. Have you done that?

  • Thank you. This environment was installed with Toolchain manager, however I did modify the installed version of the extension in VS code in order to test whether this was a new behavior.

    The nrf-connect.boardRoots setting did indeed contain the problematic board path. I don't recall adding it there but it must have been my doing! With that cleaned up the CMake warning no longer occurs. Thanks for reminding me of this setting.

    It still seems odd (misleading) that the GUI allows to edit the "Extra CMake arguments" for BOARD_ROOT, even though edits will be discarded. At least now I have a better understanding of how to manipulate its auto-generated content.

Related