Must toolchain version match SDK version?

Hi.

For a while I have had some issues with the toolchain when using the nRF connect SDK in visual studio code on windows 10. I believe it was after installing SDK version 2.8.0 that I saw the problems first, although I'm not entirely sure. When I use certain commands I get errors in toolchain versions other than 2.8.0. For instance, if I try to build and flash an application using SDK version 1.9.1 and toolchain 1.9.1 I get the attached output.

First of all, is there a workaround to get this to work? I'm currently flashing manually with nrfjprog from command line.

Secondly, should I be matching toolchain versions and SDK versions in the first place? What is the intended/recommended way to use SDK and toolchain versions? If I try build my application with SDK version 1.9.1 and toolchain version 2.8.0 the application appears to run as expected, even with some improvements: resulting merged.hex file is smaller and more warnings are caught in the build process.

[9/27] Linking CXX executable zephyr\zephyr_pre0.elf
[10/27] Generating dev_handles.c
FAILED: zephyr/dev_handles.c
cmd.exe /C "cd /D C:\...\build_191\zephyr && C:\ncs\v1.9.1\toolchain\opt\bin\python.exe C:/ncs/v1.9.1/zephyr/scripts/gen_handles.py --output-source dev_handles.c --kernel C:/.../build_191/zephyr/zephyr_pre0.elf --zephyr-base C:/ncs/v1.9.1/zephyr --start-symbol __device_start"
Traceback (most recent call last):
  File "C:/ncs/v1.9.1/zephyr/scripts/gen_handles.py", line 37, in <module>
    from elftools.elf.elffile import ELFFile
  File "C:\ncs\toolchains\2d382dcd92\opt\bin\Lib\site-packages\elftools\elf\elffile.py", line 41, in <module>
    from ..dwarf.dwarfinfo import DWARFInfo, DebugSectionDescriptor, DwarfConfig
  File "C:\ncs\toolchains\2d382dcd92\opt\bin\Lib\site-packages\elftools\dwarf\dwarfinfo.py", line 17, in <module>
    from .structs import DWARFStructs
  File "C:\ncs\toolchains\2d382dcd92\opt\bin\Lib\site-packages\elftools\dwarf\structs.py", line 10, in <module>
    from logging.config import valid_ident
  File "<frozen zipimport>", line 259, in load_module
  File "logging\config.py", line 30, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "logging\handlers.py", line 26, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "socket.py", line 49, in <module>
ImportError: Module use of python312.dll conflicts with this version of Python.
ninja: build stopped: subcommand failed.
FATAL ERROR: re-build

  • I believe you are still talking about installing and uninstalling the SDKs v2.8.0 and v2.9.0. Did you also remove/uninstall the toolchains? 

  • Hi.

    When uninstalling v2.8.0 and 2.9.0 of I specifically used the following command in VSCode:
    "nRF Connect: Uninstall Toolchain"

    So should be toolchain. Let me know if I should remove SDK as well.

    I also see that I didn't provide the best info in terms of what works and what does not work in my original post, sorry for that. If I try to only build the project it finishes successfully, but if I run "Flash to board" or "Erase and flash to board" it fails during re re-building step.

    So you might be able to reproduce the problem by:

    1. Copy application_update sample from 1.9.1 SDK and common folder in parent directory.
    2. Build for nrf9160dk_nrf9160ns (SDK 1.9.1, Toolchain v2.0.0, nRF Connect for VS Code v2025.4.106)
    3. Complete build successfully.
    4. Edit something some code to trigger a file change.
    5. Run: Erase and flash active image to board.

    ^^This only fails if it has to build and flash in sequence. In my projects, flashing always triggers re-build which is why it is particularly inconvenient. See full attached build log in VSCode below. I have also attached the .vscode-nrf-connect.json for the configuration used. Please let me know if you need anything else.

     *  Executing task: nRF Connect: Generate config nrf9160dk_nrf9160_ns for c:\project\samples\application_update 
    
    Building application_update
    C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir c:/project/samples/application_update/build c:/project/samples/application_update --pristine --board nrf9160dk_nrf9160_ns -- -DNCS_TOOLCHAIN_VERSION=NONE"
    
    -- west build: generating a build system
    Including boilerplate (Zephyr base): C:/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake
    -- Application: C:/project/samples/application_update
    -- Zephyr version: 2.7.99 (C:/ncs/v1.9.1/zephyr), build: v2.7.99-ncs1-1
    -- Found Python3: C:/ncs/toolchains/v2.0.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf9160dk_nrf9160_ns, Revision: 0.7.0
    -- Cache files will be written to: C:/ncs/v1.9.1/zephyr/.cache
    -- Found host-tools: zephyr 0.14.1 (C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found dtc: C:/ncs/toolchains/v2.0.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns.dts
    -- Generated zephyr.dts: C:/project/samples/application_update/build/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: C:/project/samples/application_update/build/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: C:/project/samples/application_update/build/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: C:/project/samples/application_update/build/zephyr/dts.cmake
    
    warning: Experimental symbol NET_SOCKETS_OFFLOAD is enabled.
    
    Parsing C:/project/samples/application_update/Kconfig
    Loaded configuration 'C:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns_defconfig'
    Merged configuration 'C:/project/samples/application_update/prj.conf'
    Configuration saved to 'C:/project/samples/application_update/build/zephyr/.config'
    Kconfig header saved to 'C:/project/samples/application_update/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 10.3.0
    -- The CXX compiler identification is GNU 10.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Changed board to secure nrf9160dk_nrf9160 (NOT NS)
    
    === child image spm -  begin ===
    loading initial cache file C:/project/samples/application_update/build/spm/child_image_preload.cmake
    Including boilerplate (Zephyr base): C:/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake
    -- Application: C:/ncs/v1.9.1/nrf/samples/spm
    -- Zephyr version: 2.7.99 (C:/ncs/v1.9.1/zephyr), build: v2.7.99-ncs1-1
    -- Found Python3: C:/ncs/toolchains/v2.0.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf9160dk_nrf9160, Revision: 0.7.0
    -- Cache files will be written to: C:/ncs/v1.9.1/zephyr/.cache
    -- Found host-tools: zephyr 0.14.1 (C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found dtc: C:/ncs/toolchains/v2.0.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
    -- Found devicetree overlay: C:/ncs/v1.9.1/nrf/samples/spm/nrf9160dk_nrf9160.overlay
    -- Generated zephyr.dts: C:/project/samples/application_update/build/spm/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: C:/project/samples/application_update/build/spm/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: C:/project/samples/application_update/build/spm/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: C:/project/samples/application_update/build/spm/zephyr/dts.cmake
    Parsing C:/ncs/v1.9.1/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_defconfig'
    Merged configuration 'C:/ncs/v1.9.1/nrf/samples/spm/prj.conf'
    Merged configuration 'C:/ncs/v1.9.1/nrf/samples/spm/boards/nrf9160dk_nrf9160.conf'
    Merged configuration 'C:/ncs/v1.9.1/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration 'C:/project/samples/application_update/build/spm/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to 'C:/project/samples/application_update/build/spm/zephyr/.config'
    Kconfig header saved to 'C:/project/samples/application_update/build/spm/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 10.3.0
    -- The CXX compiler identification is GNU 10.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Warning at C:/ncs/v1.9.1/zephyr/CMakeLists.txt:1687 (message):
      __ASSERT() statements are globally ENABLED
    
    
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/project/samples/application_update/build/spm
    === child image spm -  end ===
    
    Changed board to secure nrf9160dk_nrf9160 (NOT NS)
    
    === child image mcuboot -  begin ===
    Including boilerplate (Zephyr base): C:/ncs/v1.9.1/zephyr/cmake/app/boilerplate.cmake
    loading initial cache file C:/project/samples/application_update/build/mcuboot/child_image_preload.cmake
    -- Application: C:/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr
    -- Zephyr version: 2.7.99 (C:/ncs/v1.9.1/zephyr), build: v2.7.99-ncs1-1
    -- Found Python3: C:/ncs/toolchains/v2.0.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: nrf9160dk_nrf9160, Revision: 0.7.0
    -- Cache files will be written to: C:/ncs/v1.9.1/zephyr/.cache
    -- Found host-tools: zephyr 0.14.1 (C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found dtc: C:/ncs/toolchains/v2.0.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.14.1 (C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
    -- Found devicetree overlay: C:/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr/dts.overlay
    -- Generated zephyr.dts: C:/project/samples/application_update/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: C:/project/samples/application_update/build/mcuboot/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: C:/project/samples/application_update/build/mcuboot/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: C:/project/samples/application_update/build/mcuboot/zephyr/dts.cmake
    Parsing C:/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_defconfig'
    Merged configuration 'C:/ncs/v1.9.1/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration 'C:/ncs/v1.9.1/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration 'C:/project/samples/application_update/build/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to 'C:/project/samples/application_update/build/mcuboot/zephyr/.config'
    Kconfig header saved to 'C:/project/samples/application_update/build/mcuboot/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 10.3.0
    -- The CXX compiler identification is GNU 10.3.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    MCUBoot bootloader key file: C:/ncs/v1.9.1/bootloader/mcuboot/root-ec-p256.pem
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/project/samples/application_update/build/mcuboot
    === child image mcuboot -  end ===
    
    CMake Warning at C:/ncs/v1.9.1/nrf/modules/mcuboot/CMakeLists.txt:262 (message):
      
    
            ---------------------------------------------------------
            --- WARNING: Using default MCUBoot key, it should not ---
            --- be used for production.                           ---
            ---------------------------------------------------------
            
    
    
    
    CMake Warning at C:/ncs/v1.9.1/zephyr/CMakeLists.txt:764 (message):
      No SOURCES given to Zephyr library: subsys__net__pkt_filter
    
      Excluding target from build.
    
    
    CMake Warning at C:/ncs/v1.9.1/zephyr/CMakeLists.txt:1687 (message):
      __ASSERT() statements are globally ENABLED
    
    
    -- Found partition manager static configuration: C:/project/samples/application_update/pm_static.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_app' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_ctrl' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_rx' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_sram' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_tx' is not included in the dynamic resolving since it is statically defined.
    Partition 'spm' is not included in the dynamic resolving since it is statically defined.
    Partition 'spm_sram' is not included in the dynamic resolving since it is statically defined.
    Partition 'sram_nonsecure' is not included in the dynamic resolving since it is statically defined.
    Partition 'sram_secure' is not included in the dynamic resolving since it is statically defined.
    Dropping partition 'nrf_modem_lib_trace' since its size is 0.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/project/samples/application_update/build
    -- west build: building application
    [257/267] Linking C executable zephyr\zephyr_pre0.elf
    
    [261/267] Linking C executable zephyr\zephyr_pre1.elf
    
    [267/267] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       65024 B        64 KB     99.22%
                SRAM:       12136 B        32 KB     37.04%
            IDT_LIST:          0 GB         2 KB      0.00%
    [173/183] Linking C executable zephyr\zephyr_pre0.elf
    
    [177/183] Linking C executable zephyr\zephyr_pre1.elf
    
    [183/183] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       33992 B        48 KB     69.16%
                SRAM:       16416 B     211736 B      7.75%
            IDT_LIST:          0 GB         2 KB      0.00%
    [212/233] Linking C executable zephyr\zephyr_pre0.elf
    
    [216/233] Linking C executable zephyr\zephyr_pre1.elf
    
    [225/233] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       96944 B     425472 B     22.79%
                SRAM:       25528 B     211736 B     12.06%
            IDT_LIST:          0 GB         2 KB      0.00%
    [233/233] Generating zephyr/merged.hex
     *  Terminal will be reused by tasks, press any key to close it. 
    
     *  Executing task: nRF Connect: Flash: application_update/build (active) 
    
    Flashing build to motor
    C:\Windows\system32\cmd.exe /d /s /c "west flash -d c:\project\samples\application_update\build --snr 203200665 --erase"
    
    -- west flash: rebuilding
    [0/25] Performing build step for 'spm_subimage'
    ninja: no work to do.
    [1/23] Performing build step for 'mcuboot_subimage'
    ninja: no work to do.
    [2/23] Building C object CMakeFiles/app.dir/src/main.c.obj
    [4/21] Linking C static library app\libapp.a
    [5/21] Linking C executable zephyr\zephyr_pre0.elf
    
    [6/21] Generating dev_handles.c
    FAILED: zephyr/dev_handles.c 
    cmd.exe /C "cd /D C:\project\samples\application_update\build\zephyr && C:\ncs\toolchains\v2.0.0\opt\bin\python.exe C:/ncs/v1.9.1/zephyr/scripts/gen_handles.py --output-source dev_handles.c --kernel C:/project/samples/application_update/build/zephyr/zephyr_pre0.elf --zephyr-base C:/ncs/v1.9.1/zephyr --start-symbol __device_start"
    Traceback (most recent call last):
      File "C:/ncs/v1.9.1/zephyr/scripts/gen_handles.py", line 37, in <module>
        from elftools.elf.elffile import ELFFile
      File "C:\ncs\toolchains\b620d30767\opt\bin\Lib\site-packages\elftools\elf\elffile.py", line 41, in <module>
        from ..dwarf.dwarfinfo import DWARFInfo, DebugSectionDescriptor, DwarfConfig
      File "C:\ncs\toolchains\b620d30767\opt\bin\Lib\site-packages\elftools\dwarf\dwarfinfo.py", line 17, in <module>
        from .structs import DWARFStructs
      File "C:\ncs\toolchains\b620d30767\opt\bin\Lib\site-packages\elftools\dwarf\structs.py", line 10, in <module>
        from logging.config import valid_ident
      File "<frozen zipimport>", line 259, in load_module
      File "logging\config.py", line 30, in <module>
      File "<frozen zipimport>", line 259, in load_module
      File "logging\handlers.py", line 26, in <module>
      File "<frozen zipimport>", line 259, in load_module
      File "socket.py", line 49, in <module>
    ImportError: Module use of python312.dll conflicts with this version of Python.
    ninja: build stopped: subcommand failed.
    FATAL ERROR: re-build in c:\project\samples\application_update\build failed
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it.
    {
      "toolchainPath": "c:\\ncs\\toolchains\\v2.0.0",
      "sdkPath": "c:\\ncs\\v1.9.1",
      "board": "nrf9160dk_nrf9160_ns",
      "boardDir": "c:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160",
      "boardDirs": [
        "c:/ncs/v1.9.1/zephyr/boards/arm/nrf9160dk_nrf9160"
      ],
      "optimizations": "none",
      "cmakeArgs": [],
      "confFiles": [],
      "buildDirectory": "build",
      "kconfigFragments": [],
      "snippets": [],
      "dtcOverlays": [],
      "extraDtcOverlays": []
    }

  • Can you please try to click "install new toolchain", and then select the folder icon to select the path to your toolchain:

    I note that your .vscode-nrf-connect.json points to "toolchainPath": "c:\\ncs\\toolchains\\v2.0.0"

    Try making it point to your v1.9.1 toolchain folder. 

    Best regards,

    Edvin

Related