Vscode : I can’t use jlink (blocked on “Waiting for GDB connection…” )

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)

New contributor

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.

New contributor

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.

New contributor

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

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật