I would like to upload/debug a C program for an embended MCU: cortex M0 (infineon XMC1302).
I am using windows 10, vscode and Jlink (V9). It is the first time I try to use those 2 tools together so it could be that I make a stupid mistake.
Jlink is connected to the device with SWD (2 wires + Grnd).
When I select start debugging (F5) in vscode, I get the following message
Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
Reading symbols from C:/Users/pc/ModusToolbox/tools_3.3/gcc/bin/arm-none-eabi-objdump.exe --syms -C -h -w C:/Data/tsdz8/mstrens_test_gpio_in_debug/GPIO_IN/build/last_config/mtb-example-xmc-gpio-toggle.elf
Reading symbols from c:/users/pc/modustoolbox/tools_3.3/gcc/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p C:/Data/tsdz8/mstrens_test_gpio_in_debug/GPIO_IN/build/last_config/mtb-example-xmc-gpio-toggle.elf
Launching GDB: Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
Reading symbols from C:/Users/pc/ModusToolbox/tools_3.3/gcc/bin/arm-none-eabi-objdump.exe --syms -C -h -w C:/Data/tsdz8/mstrens_test_gpio_in_debug/GPIO_IN/build/last_config/mtb-example-xmc-gpio-toggle.elf
Reading symbols from c:/users/pc/modustoolbox/tools_3.3/gcc/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p C:/Data/tsdz8/mstrens_test_gpio_in_debug/GPIO_IN/build/last_config/mtb-example-xmc-gpio-toggle.elf
Launching GDB: "C:\Users\pc\ModusToolbox\tools_3.3\gcc\bin\arm-none-eabi-gdb.exe" -q --interpreter=mi2
IMPORTANT: Set "showDevDebugOutput": "raw" in "launch.json" to see verbose GDB transactions here. Very helpful to debug issues or report problems
Launching gdb-server: JLinkGDBServerCL.exe -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device XMC1302-T028x0064
Please check TERMINAL tab (gdb-server) for output from JLinkGDBServerCL.exe
Failed to launch jlink GDB Server: Error: spawn JLinkGDBServerCL.exe ENOENT
IMPORTANT: Set "showDevDebugOutput": "raw" in "launch.json" to see verbose GDB transactions here. Very helpful to debug issues or report problems
Launching gdb-server: JLinkGDBServerCL.exe -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device XMC1302-T028x0064
Please check TERMINAL tab (gdb-server) for output from JLinkGDBServerCL.exe
Failed to launch jlink GDB Server: Error: spawn JLinkGDBServerCL.exe ENOENT
I do not understand the message. So I also tried to run some commands in windows command prompt:
Command 1) “C:UserspcModusToolboxtools_3.3gccbinarm-none-eabi-gdb.exe” -q –interpreter=mi2 let me get the prompt (gdb) and asking help. So I expect that this command is accepted.
Command 2 in another windows command prompt to start jlinkgdbserver gives
C:Program FilesSEGGERJLink_V812>JLinkGDBServerCL.exe -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device XMC1302-T028x0064
SEGGER J-Link GDB Server V8.12 Command Line Version
JLinkARM.dll V8.12 (DLL compiled Dec 18 2024 15:27:57)
Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device XMC1302-T028x0064
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 50000
SWO raw output listening port: 50001
Terminal I/O port: 50002
Accept remote connection: localhost only
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: XMC1302-T028x0064
Target device parameters: none
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little
Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware: V9.60
S/N: 69651235
Feature(s): RDI, GDB, FlashDL, FlashBP, JFlash
Checking target voltage...
Target voltage: 3.36 V
Listening on TCP/IP port 50000
Connecting to target...
Halting core...
Connected to target
Waiting for GDB connection...
It is blocked with waiting for GDB connection…
I do not know how to solve this issue.
Additional notes:
- Jlink is working because I was already able to flash a Hex file in the same MCU and I can read back the flash memory with jflash.exe.
Here are some Json files from vscode:
- settings.json
{
"cmake.showOptionsMovedNotification": false,
"git.enableSmartCommit": true,
"git.confirmSync": false,
"cmake.configureOnOpen": true,
"[cpp]": {
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"cmake.pinnedCommands": [
"workbench.action.tasks.configureTaskRunner",
"workbench.action.tasks.runTask"
],
"arduino.useArduinoCli": true,
"clangd.detectExtensionConflicts": false,
"cortex-debug.JLinkGDBServerPath.windows": "C:/Program Files/SEGGER/JLink_V812/JLinkGDBServerCL.exe",
"cortex-debug.JLinkGDBServerPath": "C:/Program Files (x86)/SEGGER/JLink_V612a/JLinkGDBServerCL.exe",
"makefile.configureOnOpen": true
}
- Extract of launch.json
"configurations": [
{
"name": "Launch (JLink)",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"executable": "build/last_config/mtb-example-xmc-gpio-toggle.elf",
"servertype": "jlink",
//"device": "XMC1302-T028x0064",
"device": "XMC1302-T038x0064",
// : "2000",
"interface": "swd",
"serialNumber": "",
"preLaunchCommands": [
// Program via the hex file to get complete coverage
"exec-file build/last_config/mtb-example-xmc-gpio-toggle.hex"
],
"overrideRestartCommands": [
"starti"
],
// svdFile is optional, it can be very large.
"svdFile": "../mtb_shared/mtb-xmclib-cat3/release-v4.4.0/CMSIS/Infineon/SVD/XMC1300.svd",
"breakAfterReset": true,
"runToEntryPoint": "main", // Specifies application entry point name where program will halt
"preLaunchTask": "Build", // Set this to run a task from tasks.json before
// starting a debug session
"showDevDebugOutput": "raw"
},
As explained here above, I tried
- to check Jlink connection with target (and it seems OK)
- to enter manually in command prompt the commands used by vscode
- to run jlinkgdbserver.exe (so the gui version instead of the command line version) and It shows the result (= non connection with gdb)
mstrens is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
It seemed that the path to jlinkgdbserver.exe was not right.
Jlink was installed in a folder named “jlink_V812” and not the default “jlink”.
I had changed the path in settings.json but it did not work (even adding .exe).
Finally I created a “jlink” folder and moved all jlink files into it.
First it did not worked but I then recreated totally the project (with the default settings to “jlink” folder and it now works. I still do not understand what was wrong.
mstrens is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
try changing the .exe file to JLinkGDBServerCL.exe.
Jonathan Muñoz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1