Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

toolchain manager sets ZEPHYR_TOOLCHAIN_VARIANT incorrectly

These are the details of my system:

  • Ubuntu 20.04.5 LTS
  • nRF Connect for Desktop v3.12.0
  • Toolchain Manager v1.2.1
  • Visual Studio Code 1.73.1
  • NCS 2.1.2

If I start Visual Studio Code from the Nordic Toolchain Manager, the global environment variable ZEPHYR_TOOLCHAIN_VARIANT is set to the value "zephyr".

This setting causes my project to not compile.

I also tried to set the correct ZEPHYR_TOOLCHAIN_VARIANT in the file ~/.zephyrrc:

export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb

My workaround is not to start Visual Studio Code from the Toolchain Manager.
Instead set all environment settings manually before starting Visual Studio Code:

export ZEPHYR_BASE="/home/ephimee/ncs2/v2.1.2/zephyr"
export BOARD_ROOT=/home/ephimee/git/myproject
export BOARD=nrf52840dk_nrf52840
export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
code

A few questions:

  1. why does Toolchain Manager set ZEPHYR_TOOLCHAIN_VARIANT to the value "zephyr"?
  2. can you provide a list of all environment settings the Toolchain Manager sets before running Visual Studio Code?
  3. which script is executed by the Toolchain Manager before running Visual Studio Code?
  4. is this a bug?
  • Hi,

    1. The correct toolchain variant for v2.1.2 of nRF Connect SDK is zephyr. In v2.0.0 the SDK started using the Zephyr SDK as default toolchain instead of the GNU Arm Embedded Toolchain. Since you did the installation using the Toolchain Manager, then you should have the Zephyr SDK toolchain under /home/ephimee/ncs2/toolchains/v2.1.2/.

    2. You can see the source code for the Toolchain Manager here: https://github.com/NordicSemiconductor/pc-nrfconnect-toolchain-manager. I cannot find that the ZEPHYR_TOOLCHAIN_VARIANT is set to zephyr anywhere, nor that ZEPHYR_SDK_INSTALL_DIR is set. However, if no toolchain is selected, then the build system will look for the Zephyr SDK and use this toolchain.

    3. VS Code is opened here: https://github.com/NordicSemiconductor/pc-nrfconnect-toolchain-manager/blob/main/src/VsCodeDialog/vscode.ts.

    4. No, zephyr is the default toolchain, so this is not a bug.

    Best regards,

    Marte

  • Thanks for the explanation. Then I don't understand why compile fails when ZEPHYR_TOOLCHAIN_VARIANT is set to zephyr?


     *  Executing task: nRF Connect: Build: cafsample/build_nrf52840dk (active)

    Building cafsample
    west build --build-dir /home/ephimee/vscode/cafsample/build_nrf52840dk /home/ephimee/vscode/cafsample --pristine --board nrf52840dk_nrf52840 -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="/home/ephimee/vscode/cafsample" -DCONFIG_DEBUG_OPTIMIZATIONS:STRING="y" -DCONFIG_DEBUG_THREAD_INFO:STRING="y" -DDTC_OVERLAY_FILE:STRING="/home/ephimee/vscode/cafsample/boards/nrf52840dk_nrf52840.overlay" -DCONF_FILE:STRING="/home/ephimee/vscode/cafsample/prj.conf"

    -- west build: generating a build system
    ZEPHYR_BASE = /home/ephimee/ncs2/v2.1.2/zephyr
    BOARD_ROOT = /home/ephimee/vscode/cafsample
    BOARD = nrf52840dk_nrf52840
    ZEPHYR_TOOLCHAIN_VARIANT = zephyr
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/ephimee/vscode/cafsample
    -- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter
    -- Cache files will be written to: /home/ephimee/.cache/zephyr
    -- Zephyr version: 3.1.99 (/home/ephimee/ncs2/v2.1.2/zephyr)
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.14.1 (/home/ephimee/ncs_v2.0.2/toolchains/v2.0.2/opt/zephyr-sdk)
    -- Found dtc: /usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (/home/ephimee/ncs_v2.0.2/toolchains/v2.0.2/opt/zephyr-sdk)
    -- Found BOARD.dts: /home/ephimee/ncs2/v2.1.2/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: /home/ephimee/vscode/cafsample/boards/nrf52840dk_nrf52840.overlay
    CMake Error at /home/ephimee/ncs2/v2.1.2/zephyr/cmake/modules/extensions.cmake:1883 (file):
      file STRINGS file
      "/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/zephyr.dts.d"
      cannot be read.
    Call Stack (most recent call first):
      /home/ephimee/ncs2/v2.1.2/zephyr/cmake/modules/dts.cmake:195 (toolchain_parse_make_rule)
      /home/ephimee/ncs2/v2.1.2/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
      /home/ephimee/ncs2/v2.1.2/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /home/ephimee/ncs2/v2.1.2/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:13 (find_package)


    Traceback (most recent call last):
      File "/home/ephimee/ncs2/v2.1.2/zephyr/scripts/dts/gen_defines.py", line 1032, in <module>
        main()
      File "/home/ephimee/ncs2/v2.1.2/zephyr/scripts/dts/gen_defines.py", line 65, in main
        edt = edtlib.EDT(args.dts, args.bindings_dirs,
      File "/home/ephimee/ncs2/v2.1.2/zephyr/scripts/dts/python-devicetree/src/devicetree/edtlib.py", line 205, in __init__
        self._dt = DT(dts)
      File "/home/ephimee/ncs2/v2.1.2/zephyr/scripts/dts/python-devicetree/src/devicetree/dtlib.py", line 741, in __init__
        with open(filename, encoding="utf-8") as f:
    FileNotFoundError: [Errno 2] No such file or directory: '/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/zephyr.dts.pre'
    -- In: /home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr, command: /usr/bin/python3.8;/home/ephimee/ncs2/v2.1.2/zephyr/scripts/dts/gen_defines.py;--dts;/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/zephyr.dts.pre;--dtc-flags;'-Wno-unique_unit_address_if_enabled';--bindings-dirs;/home/ephimee/ncs2/v2.1.2/nrf/dts/bindings;/home/ephimee/ncs2/v2.1.2/zephyr/dts/bindings;--header-out;/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/include/generated/devicetree_unfixed.h.new;--device-header-out;/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/include/generated/device_extern.h.new;--dts-out;/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/zephyr.dts.new;--edt-pickle-out;/home/ephimee/vscode/cafsample/build_nrf52840dk/zephyr/edt.pickle;--vendor-prefixes;/home/ephimee/ncs2/v2.1.2/nrf/dts/bindings/vendor-prefixes.txt;--vendor-prefixes;/home/ephimee/ncs2/v2.1.2/zephyr/dts/bindings/vendor-prefixes.txt
    CMake Error at /home/ephimee/ncs2/v2.1.2/zephyr/cmake/modules/dts.cmake:230 (message):
      gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
      /home/ephimee/ncs2/v2.1.2/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
      /home/ephimee/ncs2/v2.1.2/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /home/ephimee/ncs2/v2.1.2/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:13 (find_package)


    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /home/ephimee/.local/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/ephimee/vscode/cafsample/build_nrf52840dk -GNinja -DBOARD=nrf52840dk_nrf52840 -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DBOARD_ROOT:STRING=/home/ephimee/vscode/cafsample -DCONFIG_DEBUG_OPTIMIZATIONS:STRING=y -DCONFIG_DEBUG_THREAD_INFO:STRING=y -DDTC_OVERLAY_FILE:STRING=/home/ephimee/vscode/cafsample/boards/nrf52840dk_nrf52840.overlay -DCONF_FILE:STRING=/home/ephimee/vscode/cafsample/prj.conf -S/home/ephimee/vscode/cafsample

     *  The terminal process terminated with exit code: 1.
     *  Terminal will be reused by tasks, press any key to close it.

  • Hi,

    Are you using the same build directory as when you built with gnuarmemb? If so, can you try deleting the build directory and creating a new one?

    I see from your log that it is complaining about some devicetree files. Can you share what your nrf52840dk_nrf52840.overlay looks like?

    Best regards,

    Marte

  • 5241.nrf52840dk_nrf52840.overlay

    When I try to generate new build configuration I get the same error.

  • Hi,

    I am not able to reproduce your error on my side, and I cannot find any issues with the overlay file.

    Do you see the same error if you build on command line?

    Can you generate support information from VS Code and upload it here? To generate it open command palette (ctrl+shift+p) in VS Code and write nRF Connect: generate support information. Select this option, and the information will be generated in the output tab. Copy that and paste it here.

    Best regards,

    Marte

Related