Failed to configure 3rd party toolchain with vscode

Hi,

I tried to install manually nrf connect sdk and zephyr sdk as per the documentation says for version nrf connect v2.4.2 and  I'm wondering how to setup properly the toolchain path since I'm unable to build projects. The build system seems to be miss configured because the path to arm gcc is wrong. See the build output below :

 *  Executing task: nRF Connect: Build: peripheral_uart_example/build (active) 

Building peripheral_uart_example
/bin/sh -c west build --build-dir /home/octech/Documents/dev-nordic/peripheral_uart_example/build /home/octech/Documents/dev-nordic/peripheral_uart_example

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: /home/octech/Documents/dev-nordic/peripheral_uart_example
-- CMake version: 3.22.1
-- Cache files will be written to: /home/octech/.cache//zephyr
-- Zephyr version: 3.3.99 (/home/octech/ncs/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.7.1")
-- Board: nrf52840dk_nrf52840
-- Found toolchain: gnuarmemb (/home/octech/toolchains/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin)
-- Configuring incomplete, errors occurred!
CMake Error at /home/octech/ncs/zephyr/cmake/compiler/gcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: gnuarmemb

  Internal variables:

  CROSS_COMPILE:
  /home/octech/toolchains/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin/bin/arm-none-eabi-


  TOOLCHAIN_HOME:
  /home/octech/toolchains/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin


Call Stack (most recent call first):
  /home/octech/ncs/zephyr/cmake/modules/FindHostTools.cmake:107 (include)
  /home/octech/ncs/zephyr/cmake/modules/dts.cmake:9 (find_package)
  /home/octech/ncs/zephyr/cmake/modules/zephyr_default.cmake:115 (include)
  /home/octech/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/octech/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
  CMakeLists.txt:8 (find_package)


FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/octech/Documents/dev-nordic/peripheral_uart_example/build -GNinja -S/home/octech/Documents/dev-nordic/peripheral_uart_example

Here are the generated support information :

{
  "platform": {
    "os": "linux",
    "osVersion": "#32~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 18 10:40:13 UTC 2",
    "osKernel": "6.2.0-32-generic",
    "vscode": "1.82.0",
    "electron": "25.8.0",
    "node": "v18.15.0"
  },
  "system": {
    "date": "2023-09-19T10:08:38.533Z",
    "vscodeRoot": "/usr/share/code/resources/app",
    "nrfConnectForDesktopInstalled": "unknown",
    "vscodeUptime": "00:13:07",
    "osUptime": "00:14:19",
    "cpu": {
      "model": "12th Gen Intel(R) Core(TM) i7-12650H",
      "speed": "2688 MHz",
      "count": 2
    },
    "memory": {
      "total": "7.75 GB",
      "free": "6.38 GB"
    }
  },
  "workspace": {
    "name": "peripheral_uart_example",
    "workspaceFile": null,
    "folders": [
      "/home/ot/Documents/dev-nordic/peripheral_uart_example"
    ]
  },
  "extensions": {
    "internal": {
      "nordic-semiconductor.nrf-connect": {
        "version": "2023.9.169",
        "path": "/home/ot/.vscode/extensions/nordic-semiconductor.nrf-connect-2023.9.169-linux-x64",
        "isActive": true
      },
      "nordic-semiconductor.nrf-terminal": {
        "version": "2023.9.29",
        "path": "/home/ot/.vscode/extensions/nordic-semiconductor.nrf-terminal-2023.9.29",
        "isActive": true
      },
      "nordic-semiconductor.nrf-devicetree": {
        "version": "2023.9.57",
        "path": "/home/ot/.vscode/extensions/nordic-semiconductor.nrf-devicetree-2023.9.57",
        "isActive": true
      },
      "nordic-semiconductor.nrf-kconfig": {
        "version": "2023.9.31",
        "path": "/home/ot/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2023.9.31",
        "isActive": true
      }
    },
    "external": {
      "marus25.cortex-debug": "1.12.1",
      "ms-vscode.cpptools": "1.17.5",
      "ms-vscode.js-debug": "1.82.0",
      "ms-vscode.js-debug-companion": "1.1.2",
      "ms-vscode.vscode-js-profile-table": "1.0.3",
      "azemoh.one-monokai": "0.5.0",
      "cschlosser.doxdocgen": "1.4.0",
      "mcu-debug.debug-tracker-vscode": "0.0.15",
      "mcu-debug.memory-view": "0.0.24",
      "mcu-debug.peripheral-viewer": "1.4.6",
      "mcu-debug.rtos-views": "0.0.7",
      "mhutchie.git-graph": "1.30.0",
      "MS-CEINTL.vscode-language-pack-fr": "1.82.2023091309",
      "ms-vscode.makefile-tools": "0.7.0",
      "seatonjiang.gitmoji-vscode": "1.2.4",
      "trond-snekvik.gnu-mapfiles": "1.1.0",
      "twxs.cmake": "0.0.17"
    }
  },
  "tools": {
    "zephyr-sdk": "Not found",
    "/opt/SEGGER/JLink/JLinkExe": "7.92e",
    "/usr/local/bin/nrfjprog": "10.23.0",
    "nrfutil": "Not found",
    "/usr/bin/cmake": "3.22.1",
    "/home/ot/.local/bin/west": "1.1.0",
    "/usr/bin/python3": "3.10.12",
    "/usr/bin/ninja": "1.10.1",
    "/usr/bin/gperf": "3.1",
    "/usr/bin/dtc": "1.6.1",
    "gn": "Not found",
    "/usr/bin/git": "2.34.1",
    "gdbPath": "/home/ot/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
  },
  "sdks": [
    {
      "version": "2.4.2",
      "path": "/home/ot/ncs"
    }
  ],
  "toolchains": [],
  "connectedDevices": [],
  "deviceProvider": "nrfutil",
  "config": {
    "nordic-semiconductor.nrf-connect": {
      "topdir": "",
      "toolchain": {
        "path": "${nrf-connect.zephyrsdk:0.16.0}"
      },
      "ozonePath": "",
      "applications": [],
      "applicationOptions": {},
      "kconfig": {
        "interface": "kconfig",
        "executeInDefaultShell": false
      },
      "welcome": {
        "showOnStartup": true
      },
      "west": {
        "env": {
          "$base": "terminal"
        }
      },
      "boardRoots": [],
      "taskBindings": {},
      "debugging": {
        "flash": true,
        "bindings": {}
      },
      "activeAppFollowActiveEditor": true,
      "deviceProvider": "nrfutil",
      "enableTelemetry": true,
      "thirdpartyIntegration": {},
      "toolchainManager": {
        "indexURL": null,
        "installDirectory": ""
      },
      "nrfutil": {
        "home": null
      }
    },
    "nordic-semiconductor.nrf-terminal": {
      "terminalMode": "character"
    },
    "marus25.cortex-debug": {
      "variableUseNaturalFormat": true,
      "liveWatchRefreshRate": "300",
      "armToolchainPath": null,
      "armToolchainPrefix": "arm-none-eabi",
      "gdbPath": null,
      "objdumpPath": null,
      "JLinkGDBServerPath": null,
      "openocdPath": null,
      "pyocdPath": null,
      "PEGDBServerPath": null,
      "stutilPath": null,
      "stlinkPath": null,
      "stm32cubeprogrammer": null,
      "enableTelemetry": true,
      "dbgServerLogfile": null
    }
  },
  "environment": {
    "westEnv": {
      "ELECTRON_RUN_AS_NODE": "1",
      "HOME": "/home/ot",
      "PATH": "/home/ot/zephyr-sdk-0.16.0/arm-zephyr-eabi/bin:/home/ot/.local/bin:/home/ot/toolchains/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin:/home/ot/.local/bin:/home/ot/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      "ZEPHYR_BASE": "/home/ot/ncs/zephyr",
      "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
      "USER": "ot"
    },
    "inherited": {
      "ELECTRON_RUN_AS_NODE": "1",
      "HOME": "/home/ot",
      "PATH": "/home/ot/.local/bin:/home/ot/toolchains/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/bin:/home/ot/.local/bin:/home/ot/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      "GNUARMEMB_TOOLCHAIN_PATH": "/home/ot/toolchains/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi",
      "ZEPHYR_TOOLCHAIN_VARIANT": "gnuarmemb",
      "USER": "ot"
    },
    "toolchainPath": "PATH"
  },
  "terminal": {
    "defaultProfile": null
  }
}

The vscode extension uses PATH variable to locate arm gcc toolchain but it appends /bin to the path, leading to a wrong path deduction... It doesn't use the GNUARMEMB_TOOLCHAIN_PATH along with ZEPHYR_TOOLCHAIN_VARIANT globally available in the system since setup in the user's .profile file.

Moreover, in the vscode extension when I click on "Manage toolchains -> Set Active Toolchain -> Browse" and then select the arm gcc toolchain directory, the result is an error message indicating the selected directory contains an invalid toolchain.

Best regards,

Hugo

Related