Building/Debugging with Zephyr SDK Toolchain in nRF Connect VS Code (Linux)

Hello,

I've successfully setup a development environment for nRF Connect and Zephyr on windows (VS Code extension) where I can build, debug and flash code to my board, and now I'm attempting to do the same in a Linux environment running on a virtual machine.  Below I will explain in detail what I've done so far, but here I'll just state that my main goal is to use nRF Connect VS Code as my development environment, but use the currently installed Zephyr SDK toolchain (installed using instruction in latest Zephyr documentation) as is without having to install the nRF SDK and gnuarmemb toolchain.  Is there a way to to tell nRF connect that my toolchain is located in the Zephyr SDK so I can do this?  Just seems wasteful to have to install two identical toolchains when I can already build, flash and debug from a terminal.

More Details:

I followed documentation (Zephyr Getting Started) to get the Zephyr SDK and required toolchains installed, and was successful at building, debugging and flashing code from the command line.  Now I am trying to move away from the command line and setup nRF Connect in VS Code to use the Zephyr SDK toolchains.  I started following the "installing manually" Nordic Semi documentation on this process, but I'm getting a little confused.  In the documentation there is a paragraph:

"If you already have your system set up to work with Zephyr OS based on Zephyr’s Getting Started Guide, you already have some of the requirements for the nRF Connect SDK installed. The only requirement not covered by the installation steps in Zephyr is the GN tool. This tool is needed only for Matter (Project CHIP) applications. You can also skip the Install the GNU Arm Embedded Toolchain section."  

This leads me to believe I can use the existing Zephyr ARM toolchain without installing another.  So after installing the nRF Connect VS Code extension I tried making a new application (I chose to use the Zephy SDK and PATH as toolchain shown in figure below) and then made a build configuration (figure below).  The project started building and then threw the following errors:

 

Building CLARI
west build --build-dir /home/parker/Documents/GitHub/Software_Development/Applications/CLARI/build /home/parker/Documents/GitHub/Software_Development/Applications/CLARI

-- west build: generating a build system
Including boilerplate (Zephyr base (cached)): /home/parker/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/parker/Documents/GitHub/Software_Development/Applications/CLARI
-- Zephyr version: 2.7.99 (/home/parker/zephyrproject/zephyr), build: v2.7.99-1181-g3c450b103e83
-- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
-- Board: nrf52_clari
-- Cache files will be written to: /home/parker/.cache/zephyr
-- Found dtc: /usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
-- Configuring incomplete, errors occurred!
CMake Error at /home/parker/zephyrproject/zephyr/cmake/extensions.cmake:2014 (message):
  Assertion failed: GNUARMEMB_TOOLCHAIN_PATH is not set
Call Stack (most recent call first):
  /home/parker/zephyrproject/zephyr/cmake/toolchain/gnuarmemb/generic.cmake:13 (assert)
  /home/parker/zephyrproject/zephyr/cmake/generic_toolchain.cmake:36 (include)
  /home/parker/zephyrproject/zephyr/cmake/app/boilerplate.cmake:540 (include)
  /home/parker/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /home/parker/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
  /home/parker/Documents/GitHub/Software_Development/Applications/CLARI/build/CMakeLists.txt:4 (find_package)


FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/parker/Documents/GitHub/Software_Development/Applications/CLARI/build -S/home/parker/Documents/GitHub/Software_Development/Applications/CLARI -GNinja

So based on my limited understanding, I think I can somehow change a configuration in nRF Connect to point to the existing Zephyr SDK toolchain for ARM and I should be able to build, debug and flash code from VS Code without installing a separate nRF SDK...let me know if this workflow is possible.

OS:  Ubuntu 20.04 LTS

Zephyr SDK:  Zephyr 2.7.99

VS Code:  1.6.2.0

Cheers,

Parker

Parents Reply Children
  • Hi Jonathan,

    Yes I used the toolchain manager and those tutorials to setup my nRF connect toolchain in Windows, but as far as I know the Linux installation is predominantly a manual process.  Also the tutorials above only really apply for Mac OS and Windows.

    On Linux, It seems like installing the Zephyr SDK (following these directions) is the easiest and most foolproof method of getting a working environment to build, flash and debug Zephyr applications.  Then installing VS Code, the nRF Connect extension and setting the toolchain variables to use zephyr and not gnuarmemb allows nRF Connect to make use of the existing toolchains without having to install a second /ncs repository with redundant toolchains.

    Thanks,

    Parker

  • Ok thanks for the clarification, 

    could you try to add rm-none-eabi to path

    /home/$USER/.bashrc

    export PATH=$PATH:$GNUARMEMB_TOOLCHAIN_PATH/bin



    And important to start VS code from terminal. 

    Regards,
    Jonathan

  • Sorry for the delay, my VM had a meltdown and then I got super busy with school.  I'm getting the same environment setup in WSL2 running Ubuntu.  I ended up adding 

    export ZEPHYR_TOOLCHAIN_VARIANT=zephyr

    export PATH=$PATH:$GNUARMEMB_TOOLCHAIN_PATH/bin

    to my ~/.bashrc.  Currently I can build my project no problem (nRF Connect now uses the Zephyr toolchain for building by default), but I'm having trouble with getting the JLink debugger to connect to WSL (a completely separate problem).  Once I get that fixed I should be able to retest debugging.

    Cheers,

    Parker 

  • Hi Jonathan,

    I fixed my JLink probe issues and now I can flash code from VS Code nRF Connect.  So I'm back to where I was before...still unable to start a debug session.  I added export PATH=$PATH:$GNUARMEMB_TOOLCHAIN_PATH/bin to my ~/.bashrc file.  But still nothing is working.

    I can start a debug session using west if I navigate to the ~/zephyrproject/zephyr folder and run "west debug".  Now I want to configure VS Code so it will use the Zephyr SDK toolchain to start a debug session.  

    I'm guessing it's something really simple, like having to configure my launch.json file to point to the Zephyr SDK toolchain, or adding the toolchain to the path somehow.  Any advice?

    Cheers,

    Parker

Related