Is your feature request related to a problem? Please describe.
I would be helpful to have a working VSCode debugging (using C/C++ extension with Cortex-Debug) facility for Zephyr application using the Open Source editor.
Describe the solution you'd like
A working configuration which includes the necessary dependency for this to work on Linux with Zephyr-SDK which in theory should be similar to GNU ARM Embedded?
Describe alternatives you've considered
N/A
Additional context
I could only make this work on Windows with GNU ARM Embedded from this example
@n3rd4i some of my configurations (launch.json)
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"cwd": "${workspaceRoot}",
"executable": "build/zephyr/zephyr.elf",
"name": "zephyr STM32L432KC",
"device": "STM32L432KC",
"configFiles": [
"zephyr/boards/arm/nucleo_l432kc/support/openocd.cfg"
]
},
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"cwd": "${workspaceRoot}",
"executable": "build/zephyr/zephyr.elf",
"name": "zephyr STM32F746ZG",
"device": "STM32F746ZG",
"configFiles": [
"zephyr/boards/arm/nucleo_f746zg/support/openocd.cfg"
]
},
{
"type": "cortex-debug",
"request": "launch",
"servertype": "openocd",
"cwd": "${workspaceRoot}",
"executable": "build/zephyr/zephyr.elf",
"name": "zephyr STM32F072B",
"device": "STM32F072B",
"configFiles": [
"zephyr/boards/arm/stm32f072b_disco/support/openocd.cfg"
]
}
I'm using Code-OSS Version: 1.35.1 on MANJARO. I'm not using the Zephyr SDK but native installed openocd and gcc build-essential for ARM
Here is my c_cpp_properties.json
{
"env" : {
"myZephyrSourcePath": "/home/markus/zephyr/west/zephyr",
"myZephyrSDKPath": "/home/markus/zephyr/sdk/sdk_0.10.0/"
},
"configurations": [
{
"name": "Linux",
"includePath": [
"${myZephyrSourcePath}/include/",
"${myZephyrSourcePath}/lib/libc/minimal/include/",
"${myZephyrSourcePath}/arch/arm/include/",
"${workspaceFolder}/build/zephyr/include/generated/"
],
"compilerPath": "${myZephyrSDKPath}/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
I forgot to mention that I'm using Windows.
So here is my lounch.json for these:
{
"version": "0.2.0",
"configurations": [
{
"name": "Zephyr nRF52832 openocd",
"cwd": "${workspaceRoot}",
"executable": "build/zephyr/zephyr.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"device": "nrf52832_xxaa",
"targetId": "nrf52",
"boardId": "",
"armToolchainPath": "${HOME}/zephyr-sdk-0.10.3/arm-zephyr-eabi/bin",
"interface": "swd",
"gdbpath": "/usr/bin/gdb-multiarch",
"configFiles": [
"/usr/share/openocd/scripts/board/nordic_nrf52_dk.cfg"
]
},
]
}
With the configuration above, I could run the debug session.
Although Zephyr document mentioned that OpenOCD awares threads, I didn't try it by myself yet to see the stacks of several threads in VSCODE.
There is news on this front from PlatformIO.
@n3rd4i have you already tried PlatformIO + Zephyr? Does it work for you?
I tried it yesterday, I have some issue configuring it. I wanted to set-up for nrf52832 but I get:
Processing development (platform: https://github.com/platformio/platform-nordicnrf52.git; framework: zephyr; board: nrf52_dk)
--------------------------------------------------------------------------------------------
PackageManager: Installing framework-zephyr-hal-nordicnrf52 @ ~0.0.191028
Error: Detected unknown package 'framework-zephyr-hal-nordicnrf52'
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
This is my platformio.ini
[env:development]
platform = https://github.com/platformio/platform-nordicnrf52.git
framework = zephyr
board = nrf52_dk
Could you re-run pio update command and try again?
I've run:
pio update
It did this:
T:\platform-nordicnrf52\examples\zephyr-ble-beacon>pio update
Updating tool-pioplus @ 2.6.0 [Up-to-date]
Updating contrib-pysite @ 2.35.191017 [Up-to-date]
Updating tool-unity @ 1.20403.0 [Up-to-date]
Updating tool-scons @ 3.30101.0 [Up-to-date]
Updating contrib-piohome @ 3.1.0-beta.1 [Up-to-date]
Platform Manager
================
Platform Nordic nRF52
--------
Updating nordicnrf52 @ ef37e8e [Up-to-date]
Updating tool-cmake @ 3.15.5 [Up-to-date]
Updating toolchain-gccarmnoneeabi @ 1.70201.0 [Up-to-date]
Updating framework-zephyr @ 1.20000.191120 [Up-to-date]
Updating tool-sreccat @ 1.164.0 [Up-to-date]
Updating tool-dtc @ 1.4.7 [Up-to-date]
Updating tool-ninja @ 1.9.0 [Up-to-date]
Updating framework-mbed @ 5.51401.191023 [Up-to-date]
Uninstalling toolchain-gccarmnoneeabi @ 1.80201.190214: [OK]
Library Manager
===============
Then I run build again:
Processing development (platform: https://github.com/platformio/platform-nordicnrf52.git; framework: zephyr; board: nrf52_dk)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PackageManager: Installing toolchain-gccarmnoneeabi @ ~1.80201.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
toolchain-gccarmnoneeabi @ 1.80201.190214 has been successfully installed!
PackageManager: Installing framework-zephyr-hal-nordicnrf52 @ ~0.0.191028
Error: Detected unknown package 'framework-zephyr-hal-nordicnrf52'
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
I did some more experiments changing the platformio.ini
Experiment #1
[env:development]
platform = https://github.com/platformio/platform-nordicnrf52.git
framework = zephyr
board = nrf52_dk
platform_packages =
; use upstream Git version
framework-zephyr-hal-nordicnrf52 @ https://github.com/platformio/platform-nordicnrf52.git
Bring this:
Processing development (platform: https://github.com/platformio/platform-nordicnrf52.git; framework: zephyr; board: nrf52_dk)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nrf52_dk.html
PLATFORM: Nordic nRF52 3.8.0 #ef37e8e > Nordic nRF52-DK
HARDWARE: NRF52832 64MHz, 64KB RAM, 512KB Flash
DEBUG: Current (blackmagic) On-board (cmsis-dap, jlink) External (blackmagic, stlink)
PACKAGES: tool-dtc 1.4.7, framework-zephyr 1.20000.191120 (2.0.0), framework-zephyr-hal-nordicnrf52 ef37e8e, tool-sreccat 1.164.0 (1.64), toolchain-gccarmnoneeabi 1.80201.190214 (8.2.1), tool-ninja 1.9.0, tool-cmake 3.15.5
Reading CMake configuration...
KeyError: 'framework-zephyr-hal-nordic':
File "C:\users\Anonymous\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 151:
env.SConscript("$BUILD_SCRIPT")
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 605:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 286:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "C:\users\Anonymous\.platformio\platforms\nordicnrf52@src-1ba74587582d452dca0bdd0b9f5bf6ad\builder\main.py", line 166:
target_elf = env.BuildProgram()
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\users\Anonymous\.platformio\packages\framework-zephyr\scripts\platformio\platformio-build-pre.py", line 23:
env.ProcessProgramDeps()
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\users\Anonymous\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 107:
env.BuildFrameworks(env.get("PIOFRAMEWORK"))
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 224:
return self.method(*nargs, **kwargs)
File "C:\users\Anonymous\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 328:
SConscript(env.GetFrameworkScript(f), exports="env")
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 668:
return method(*args, **kw)
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 605:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 286:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "C:\users\Anonymous\.platformio\platforms\nordicnrf52@src-1ba74587582d452dca0bdd0b9f5bf6ad\builder\frameworks\zephyr.py", line 30:
"platformio", "platformio-build.py"), exports="env")
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 668:
return method(*args, **kw)
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 605:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\Anonymous\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 286:
exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
File "C:\users\Anonymous\.platformio\packages\framework-zephyr\scripts\platformio\platformio-build.py", line 746:
codemodel = get_cmake_code_model()
File "C:\users\Anonymous\.platformio\packages\framework-zephyr\scripts\platformio\platformio-build.py", line 206:
run_cmake()
File "C:\users\Anonymous\.platformio\packages\framework-zephyr\scripts\platformio\platformio-build.py", line 179:
"framework-zephyr-hal-" + PLATFORMS_WITH_EXTERNAL_HAL[platform_name]),
File "c:\users\Anonymous\.platformio\penv\lib\site-packages\platformio\managers\platform.py", line 345:
version = self.packages[name].get("version", "")
=============================================================================================== [FAILED] Took 1.27 seconds ===============================================================================================
Experiment #2:
[env:development]
platform = https://github.com/platformio/platform-nordicnrf52.git
framework = zephyr
board = nrf52_dk
platform_packages =
; use upstream Git version
framework-zephyr-hal-nordicnrf52 @ https://github.com/platformio/platform-nordicnrf52.git
framework-zephyr-hal-nordic @ https://github.com/platformio/platform-nordicnrf52.git
brings:
Processing development (platform: https://github.com/platformio/platform-nordicnrf52.git; framework: zephyr; board: nrf52_dk)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nrf52_dk.html
PLATFORM: Nordic nRF52 3.8.0 #ef37e8e > Nordic nRF52-DK
HARDWARE: NRF52832 64MHz, 64KB RAM, 512KB Flash
DEBUG: Current (cmsis-dap) On-board (cmsis-dap, jlink) External (blackmagic, stlink)
PACKAGES: tool-cmake 3.15.5, tool-dtc 1.4.7, framework-zephyr-hal-nordicnrf52 ef37e8e, toolchain-gccarmnoneeabi 1.80201.190214 (8.2.1), framework-zephyr 1.20000.191120 (2.0.0), tool-ninja 1.9.0, framework-zephyr-hal-nordicnrf52 ef37e8e, tool-sreccat 1.164.0 (1.64)
Reading CMake configuration...
-- Found PythonInterp: c:/users/evalan/.platformio/penv/scripts/python.exe (found suitable version "3.5.4", minimum required is "3.4")
-- git describe failed: fatal: not a git repository (or any of the parent directories): .git;
BUILD_VERSION is left undefined
-- Selected BOARD nrf52_pca10040
-- Found west: C:/Python35/Scripts/west.exe (found suitable version "0.6.3", minimum required is "0.6.0")
-- Loading C:/Users/Anonymous/.platformio/packages/framework-zephyr/boards/arm/nrf52_pca10040/nrf52_pca10040.dts as base
-- Overlaying C:/Users/Anonymous/.platformio/packages/framework-zephyr/dts/common/common.dts
Device tree configuration written to T:/platform-nordicnrf52/examples/zephyr-ble-beacon/.pio/build/development/zephyr/include/generated/generated_dts_board.conf
Parsing Kconfig tree in C:/Users/Anonymous/.platformio/packages/framework-zephyr/Kconfig
Loaded configuration 'C:/Users/Anonymous/.platformio/packages/framework-zephyr/boards/arm/nrf52_pca10040/nrf52_pca10040_defconfig'
Merged configuration 'T:/platform-nordicnrf52/examples/zephyr-ble-beacon/zephyr/prj.conf'
Configuration saved to 'T:/platform-nordicnrf52/examples/zephyr-ble-beacon/.pio/build/development/zephyr/.config'
-- Cache files will be written to: C:\Users\Anonymous\AppData\Local/.cache/zephyr
-- The C compiler identification is GNU 8.2.1
-- The CXX compiler identification is GNU 8.2.1
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/Anonymous/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc.exe
-- Performing Test toolchain_is_ok
-- Performing Test toolchain_is_ok - Failed
-- Configuring incomplete, errors occurred!
See also "T:/platform-nordicnrf52/examples/zephyr-ble-beacon/.pio/build/development/CMakeFiles/CMakeOutput.log".
See also "T:/platform-nordicnrf52/examples/zephyr-ble-beacon/.pio/build/development/CMakeFiles/CMakeError.log".
Zephyr version: 2.0.0
CMake Error at C:/Users/Anonymous/.platformio/packages/framework-zephyr/cmake/extensions.cmake:1324 (message):
Assertion failed: The toolchain is unable to build a dummy C file. See
CMakeError.log.
Call Stack (most recent call first):
C:/Users/Anonymous/.platformio/packages/framework-zephyr/CMakeLists.txt:44 (assert)
============================================================================================== [FAILED] Took 15.34 seconds ==============================================================================================
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
Hi @n3rd4i ! Please run pio update again to pull the latest changes. As for the second error that's really strange, if it doesn't work even with the latest version of nordicnrf52 platform please open an issue here as this thread doesn't seem like a right place to continue our discussion. Thanks!
I was able to successfully able to debug with PlatformIO and Zephyr after doing the updates as suggested. I believe with this, we could close this ticket since its kind of resolved with this combination.
Most helpful comment
There is news on this front from PlatformIO.