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
  • I found a workaround that allows me to build my project from within nRF Connect for VS Code.  After adding an application to my workspace I added a build configuration and tried compiling my project.  Once the build system failed and threw out the error previously posted above, I opened the CMakeCache.txt file in my projects generated build directory and changed the toolchain variant from gnuarmemb to zephyr.  

    //Zephyr toolchain variant
    ZEPHYR_TOOLCHAIN_VARIANT:STRING=zephyr  // previously gnuarmemb

    Now when I build no errors are thrown and I can flash my board with the resulting image.  Now I'm working on getting the debug environment running as it is throwing the following error:

    Assuming I just need to update some environment variables so nRF Connect can find the appropriate debugger executables and connect to my j-link pod.

    Cheers,

    Parker 

  • Ok I found a fix!  

    So the problem with Debugging not starting in Linux (VS Code, nRF Connect) is because I hadn't properly setup the Cortex-Debug extension settings.json.  The settings.json contains information on where the debugger gdb toolchains are located.  In my case, I'm using the Zephyr SDK to do all the work so I had to point to arm-zephyr-eabi-gdb, which for me is located in "~/zephyr-sdk-0.13.2/arm-zephyr-eadi/bin".  To configure Cortex-Debug to this I added the following lines to settings.json:

    {
        "cortex-debug.JLinkGDBServerPath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
        "cortex-debug.armToolchainPrefix": "arm-zephyr-eabi",
        "cortex-debug.armToolchainPath": "~/zephyr-sdk-0.13.2/arm-zephyr-eabi/bin"
    }

    Note:  ~ needs to be replaced with your home directory.

    After that I simply hit the debug button from within nRF Connect and the debug session started up correctly!  I'm sure I could also add arm-zephyr-eabi and JLinkGDBServerCLIExe to the system path etc. to remove the need for including those two lines above. 

    Cheers,

    Parker

Reply
  • Ok I found a fix!  

    So the problem with Debugging not starting in Linux (VS Code, nRF Connect) is because I hadn't properly setup the Cortex-Debug extension settings.json.  The settings.json contains information on where the debugger gdb toolchains are located.  In my case, I'm using the Zephyr SDK to do all the work so I had to point to arm-zephyr-eabi-gdb, which for me is located in "~/zephyr-sdk-0.13.2/arm-zephyr-eadi/bin".  To configure Cortex-Debug to this I added the following lines to settings.json:

    {
        "cortex-debug.JLinkGDBServerPath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
        "cortex-debug.armToolchainPrefix": "arm-zephyr-eabi",
        "cortex-debug.armToolchainPath": "~/zephyr-sdk-0.13.2/arm-zephyr-eabi/bin"
    }

    Note:  ~ needs to be replaced with your home directory.

    After that I simply hit the debug button from within nRF Connect and the debug session started up correctly!  I'm sure I could also add arm-zephyr-eabi and JLinkGDBServerCLIExe to the system path etc. to remove the need for including those two lines above. 

    Cheers,

    Parker

Children
No Data
Related