cortex-debug
cortex-debug copied to clipboard
Could not start GDB process while debugging Zephyr Blinky build on NUCLEO-WL55JCx
Dear All,
Please find issue report I'm experiencing with coretx-debug v1.12.1 using it with VSCode v1.88.1 under Ubuntu LTS v22.04 with NUCLEO-WL55JCx board when trying to run \sample\basic\blinky demo from zephyr-sdk-0.16.5-1
Describe the bug
NUCLEO-WL55JCx is working fine with STM32CudeIDE, have updated STLINK debugger to V3J14M5.
Zephyr-SDK installation is working fine with FRDM-K64F boards with VSCode using MCUXpresso plugin.
I can also flash and manually GDB debug Blinky example on NUCLEO-WL55JCx board with west.
west flash and west debug all work are expected using "openocd" version 0.11.0+dev-00728-gb6f95a16c (2024-02-17-23:51) from Zephyr SDK.
But I can't do source level debugging using cortex-debug neither with "stlink" nor with "openocd"
To Reproduce Steps to reproduce the behavior:
- Start debug session
- See issue
VSCode Terminal Output for "openocd" servertype
24-04-13T20:07:43.230Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
openocd -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s /home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky -f /home/XXXXXXX/.vscode/extensions/marus25.cortex-debug-1.12.1/support/openocd-helpers.tcl -f /home/XXXXXXX/zephyrproject/zephyr/boards/st/nucleo_wl55jc/support/openocd.cfg
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
CDLiveWatchSetup
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : clock speed 500 kHz
Info : STLINK V3J14M5 (API v3) VID:PID 0483:374E
Info : Target voltage: 3.269241
Info : stm32wlx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32wlx.cpu on 50000
Info : Listening on port 50000 for gdb connections
[2024-04-13T20:07:45.362Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...
VSCode Termial Output for "stlink" servertype
[2024-04-13T20:14:10.553Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
/opt/st/stm32cubeide_1.15.0/plugins/com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.linux64_2.1.200.202401191126/tools/bin/ST-LINK_gdbserver -p 50000 -cp /opt/st/stm32cubeide_1.15.0/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64_2.1.200.202311302303/tools/bin --swd --halt
STMicroelectronics ST-LINK GDB server. Version 7.6.0
Copyright (c) 2024, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 31
Listen Port Number : 50000
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
COM frequency = 12000 kHz
Target connection mode: Default
Reading ROM table for AP 0 @0xe00fffd0
Hardware watchpoint supported by the target
ST-LINK Firmware version : V3J14M5
Device ID: 0x497
PC: 0x8000830
ST-LINK device status: HALT_MODE
ST-LINK detects target voltage = 3.27 V
ST-LINK device status: HALT_MODE
ST-LINK device initialization OK
SwvSrv state change: 0 -> 1
Waiting for debugger connection...
Waiting for connection on port 50000...
Stm32Device, pollAndNotify running...
Waiting for connection on port 50001...
[2024-04-13T20:14:12.590Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...
Expected behavior
I expect to be able to do source level debugging of Zephyr blinky demo on NUCLEO-WL55 board but instead I'm getting this error:
Screenshots
Environment:
- Cortex-Debug Version 1.12.1
- OS: Ubuntu 22.04 LTS
- Zephyr SDK: 0.16.5-1 (installed literally following https://docs.zephyrproject.org/latest/develop/getting_started/index.html)
- GDB Version: GNU gdb (Zephyr SDK 0.16.5-1) 12.1
- Compiler Toolchain Version: [arm-zephyr-eabi from Zephyr SDK 0.16.5-1]
Please include launch.json
VSCode workspace is literally followed this https://github.com/KozhinovAlexander/zephyr_vscode_workspace.
Below is the content of launch.json
{
"version": "2.0.0",
// See available parameters under:
// https://github.com/Marus/cortex-debug/blob/master/src/common.ts#LL249C25-L249C25
"configurations": [
{
"name": "STLINK Flash & Debug AppUnderDev",
"cwd": "${workspaceFolder:AppUnderDev}",
"executable": "${config:app.build_dir}/zephyr/zephyr.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "stlink",
"interface": "swd",
"device": "${config:bsp.soc}",
"targetId": "${config:bsp.board}",
"boardId": "1",
"toolchainPrefix": "arm-zephyr-eabi",
//"armToolchainPath": "${env:GNUARMEMB_TOOLCHAIN_PATH}/bin",
"armToolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"svdFile": "${config:bsp.svd}",
"showDevDebugOutput": "both",
"configFiles": [
"${config:bsp.debug_config}"
]
},
{
"name": "Flash & Debug AppUnderDev",
"cwd": "${workspaceFolder:AppUnderDev}",
"executable": "${config:app.build_dir}/zephyr/zephyr.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"interface": "swd",
"device": "${config:bsp.soc}",
"targetId": "${config:bsp.board}",
"boardId": "1",
"toolchainPrefix": "arm-zephyr-eabi",
//"armToolchainPath": "${env:GNUARMEMB_TOOLCHAIN_PATH}/bin",
"armToolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"svdFile": "${config:bsp.svd}",
"showDevDebugOutput": "raw",
"configFiles": [
"${config:bsp.debug_config}"
]
},
{
"name": "Flash & Debug BootloaderUnderDev",
"cwd": "${workspaceFolder:BootloaderUnderDev}",
"executable": "${config:app_boot.build_dir}/zephyr/zephyr.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"interface": "swd",
"device": "${config:bsp.soc}",
"targetId": "${config:bsp.board}",
"boardId": "1",
"toolchainPrefix": "arm-zephyr-eabi",
//"armToolchainPath": "${env:GNUARMEMB_TOOLCHAIN_PATH}/bin",
"armToolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"svdFile": "${config:bsp.svd}",
"showDevDebugOutput": "raw",
"configFiles": [
"${config:bsp.debug_config}"
]
}
]
}
I added the following to Zephyr.code-workspace after reading https://github.com/Marus/cortex-debug/issues/598, but it did not helped.
Adding it to launch.json makes no difference.
"cortex-debug.armToolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"cortex-debug.toolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"cortex-debug.toolchainPrefix": "arm-zephyr-eabi",
"cortex-debug.gdbPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"cortex-debug.objdumpPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump",
Attach text from Debug Console
stlink server type output
Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
"name": "STLINK Flash & Debug AppUnderDev",
"cwd": "/home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky",
"executable": "/home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "stlink",
"interface": "swd",
"device": "stm32wl55jc",
"targetId": "nucleo_wl55jc",
"boardId": "1",
"toolchainPrefix": "arm-zephyr-eabi",
"armToolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"svdFile": "/home/XXXXXXX/zephyrproject/zephyr_vscode_workspace/stm32_svd/STM32WL5x_CM4.svd",
"showDevDebugOutput": "both",
"configFiles": [
"/home/XXXXXXX/zephyrproject/zephyr/boards/st/nucleo_wl55jc/support/openocd.cfg"
],
"__configurationTarget": 6,
"gdbServerConsolePort": 55878,
"pvtAvoidPorts": [],
"chainedConfigurations": {
"enabled": false
},
"debuggerArgs": [],
"swoConfig": {
"enabled": false,
"decoders": [],
"cpuFrequency": 0,
"swoFrequency": 0,
"source": "probe"
},
"rttConfig": {
"enabled": false,
"decoders": []
},
"graphConfig": [],
"preLaunchCommands": [],
"postLaunchCommands": [],
"preAttachCommands": [],
"postAttachCommands": [],
"preRestartCommands": [],
"postRestartCommands": [],
"preResetCommands": [],
"postResetCommands": [],
"toolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"gdbPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"objdumpPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump",
"extensionPath": "/home/XXXXXXX/.vscode/extensions/marus25.cortex-debug-1.12.1",
"registerUseNaturalFormat": true,
"variableUseNaturalFormat": false,
"pvtVersion": "1.12.1",
"__sessionId": "9a9fe92a-893e-4dd5-8759-67a48b20d008",
"pvtShowDevDebugOutput": "both"
}
Reading symbols from ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump --syms -C -h -w /home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf
Reading symbols from ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm --defined-only -S -l -C -p /home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf
Launching GDB: ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb -q --interpreter=mi2
1-gdb-version
Error: ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm failed! statics/global/functions may not be properly classified: Error: spawn ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm ENOENT
Expecting `nm` next to `objdump`. If that is not the problem please report this.
Could not start GDB process, does the program exist in filesystem?
Error: spawn ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb ENOENT
openocd server type output
Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
"name": "Flash & Debug AppUnderDev",
"cwd": "/home/XXXXXXXXX/zephyrproject/zephyr/samples/basic/blinky",
"executable": "/home/XXXXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"interface": "swd",
"device": "stm32wl55jc",
"targetId": "nucleo_wl55jc",
"boardId": "1",
"toolchainPrefix": "arm-zephyr-eabi",
"armToolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"svdFile": "/home/XXXXXXXXX/zephyrproject/zephyr_vscode_workspace/stm32_svd/STM32WL5x_CM4.svd",
"showDevDebugOutput": "raw",
"configFiles": [
"/home/XXXXXXXXX/zephyrproject/zephyr/boards/st/nucleo_wl55jc/support/openocd.cfg"
],
"__configurationTarget": 6,
"gdbServerConsolePort": 55878,
"pvtAvoidPorts": [],
"chainedConfigurations": {
"enabled": false
},
"debuggerArgs": [],
"swoConfig": {
"enabled": false,
"decoders": [],
"cpuFrequency": 0,
"swoFrequency": 0,
"source": "probe"
},
"rttConfig": {
"enabled": false,
"decoders": []
},
"graphConfig": [],
"preLaunchCommands": [],
"postLaunchCommands": [],
"preAttachCommands": [],
"postAttachCommands": [],
"preRestartCommands": [],
"postRestartCommands": [],
"preResetCommands": [],
"postResetCommands": [],
"searchDir": [],
"toolchainPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin",
"gdbPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb",
"objdumpPath": "~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump",
"extensionPath": "/home/XXXXXXXXX/.vscode/extensions/marus25.cortex-debug-1.12.1",
"registerUseNaturalFormat": true,
"variableUseNaturalFormat": false,
"pvtVersion": "1.12.1",
"__sessionId": "6f66650a-9b58-43e5-9d64-53ccb446a7d1",
"pvtShowDevDebugOutput": "raw"
}
Reading symbols from ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump --syms -C -h -w /home/XXXXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf
Reading symbols from ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm --defined-only -S -l -C -p /home/XXXXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf
Launching GDB: ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb -q --interpreter=mi2
1-gdb-version
Error: ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm failed! statics/global/functions may not be properly classified: Error: spawn ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm ENOENT
Expecting `nm` next to `objdump`. If that is not the problem please report this.
Could not start GDB process, does the program exist in filesystem?
Error: spawn ~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb ENOENT
Both outputs are fundamentally the same
Additional context
Manual execution of of the following works as expected. I do get all symbols and version info
~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-nm --defined-only -S -l -C -p /home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf > nm.txt
~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-objdump --syms -C -h -w /home/XXXXXXX/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.elf > objdump.txt
both produce about 50kb files
~/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb -q --interpreter=mi2
produce the following output
(gdb)
1-gdb-version
~"GNU gdb (Zephyr SDK 0.16.5-1) 12.1\n"
~"Copyright (C) 2022 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"--host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<https://github.com/zephyrproject-rtos/sdk-ng/issues>.\n"
~"Find the GDB manual and other documentation resources online at:\n <http://www.gnu.org/software/gdb/documentation/>."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\".\n"
1^done
Zephyr west debug output
-- west debug: rebuilding
ninja: no work to do.
-- west debug: using runner openocd
-- runners.openocd: OpenOCD GDB server running on port 3333; no thread info available
Open On-Chip Debugger 0.11.0+dev-00728-gb6f95a16c (2024-02-17-23:51)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 500 kHz
Info : STLINK V3J14M5 (API v3) VID:PID 0483:374E
Info : Target voltage: 3.270839
GNU gdb (Zephyr SDK 0.16.5-1) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=arm-zephyr-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://github.com/zephyrproject-rtos/sdk-ng/issues>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/XXXXXXX/zephyrproject/zephyr/build/zephyr/zephyr.elf...
Info : [stm32wlx.cpu0] Cortex-M4 r0p1 processor detected
Info : [stm32wlx.cpu0] target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32wlx.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32wlx.cpu0 hla_target little stm32wlx.cpu running
target halted due to debug-request, current mode: Thread
xPSR: 0x41000000 pc: 0x08000a6e psp: 0x20000c20
Info : Listening on port 6333 for tcl connections
Info : Listening on port 4444 for telnet connections
Remote debugging using :3333
Info : accepting 'gdb' connection on tcp/3333
Info : device idcode = 0x10036497 (STM32WLE/WL5x - Rev 'unknown' : 0x1003)
Info : RDP level 0 (0xAA)
Info : flash size = 256kbytes
Info : flash mode : single-bank
Info : device idcode = 0x10036497 (STM32WLE/WL5x - Rev 'unknown' : 0x1003)
Info : RDP level 0 (0xAA)
Info : OTP size is 1024 bytes, base address is 0x1fff7000
arch_cpu_idle () at /home/XXXXXXX/zephyrproject/zephyr/arch/arm/core/cortex_m/cpu_idle.S:139
139 cpsie i
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000830 msp: 0x20001040
Loading section rom_start, size 0x138 lma 0x8000000
Loading section text, size 0x33d8 lma 0x8000138
Loading section .ARM.exidx, size 0x8 lma 0x8003510
Loading section initlevel, size 0x68 lma 0x8003518
--Type <RET> for more, q to quit, c to continue without paging--
Loading section device_area, size 0xa0 lma 0x8003580
Loading section sw_isr_table, size 0x1f0 lma 0x8003620
Loading section rodata, size 0x308 lma 0x8003810
Loading section datas, size 0x5c lma 0x8003b18
Loading section device_states, size 0x10 lma 0x8003b74
Loading section .last_section, size 0x4 lma 0x8003b84
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000830 msp: 0x20001040
Start address 0x08000830, load size 15240
Transfer rate: 417 bytes/sec, 1524 bytes/write.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/XXXXXXX/zephyrproject/zephyr/build/zephyr/zephyr.elf
Info : Unable to match requested speed 500 kHz, using 200 kHz
Info : Unable to match requested speed 500 kHz, using 200 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08000830 msp: 0x20001040
I'm able to execute (gdb) run and see LED blinking
Any support or help is highly appreciated. Thank You!
Update
I have installed STM32 VS Code Extension for VSCode and tried to load Zephyr build with modified launch.json configuration
"serverpath": "${config:STM32VSCodeExtension.cubeCLT.path}/STLink-gdb-server/bin/ST-LINK_gdbserver",
"stm32cubeprogrammer":"${config:STM32VSCodeExtension.cubeCLT.path}/STM32CubeProgrammer/bin",
"stlinkPath": "${config:STM32VSCodeExtension.cubeCLT.path}/STLink-gdb-server/bin/ST-LINK_gdbserver",
"armToolchainPath": "${config:STM32VSCodeExtension.cubeCLT.path}/GNU-tools-for-STM32/bin",
"gdbPath":"${config:STM32VSCodeExtension.cubeCLT.path}/GNU-tools-for-STM32/bin/arm-none-eabi-gdb",
"serverArgs": ["-m","0"],
and it started to work. I will play more to understand what is going on. But one thing I'm certain, that Cortex-Debug is not happy with Zephyr GDB.
After investigation it all boiled down to this line that makes a difference -> don't use Zephyr GDB
"gdbPath":"${config:STM32VSCodeExtension.cubeCLT.path}/GNU-tools-for-STM32/bin/arm-none-eabi-gdb",