This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

JLinkGDBServer could not connect to target

Hi all,

I tried to follow this tutorial to be able to use GDB as debugger but failed right in the beginning because JLinkGDBServer could not connect. Here's the log I get:

user@xubuntu$/opt/SEGGER/JLink/JLinkGDBServer -if swd -port 2331 -device nRF5340_xxAA_APP                                                                   13:41:41  
SEGGER J-Link GDB Server V6.84a Command Line Version

JLinkARM.dll V6.84a (DLL compiled Sep  7 2020 18:27:57)

Command line: -if swd -port 2331 -device nRF5340_xxAA_APP
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      yes
Generate logfile:              off
Verify download:               off
Init regs on start:            off
Silent mode:                   off
Single run mode:               off
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:                 nRF5340_xxAA_APP
Target interface:              SWD
Target interface speed:        4000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link OB-K22-NordicSemi compiled Jan 21 2020 17:33:01
Hardware: V1.00
S/N: 960178404
Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
ERROR: Could not connect to target.
Target connection failed. GDBServer will be closed...Restoring target state and closing J-Link connection...
Shutting down...
Could not connect to target.
Please check power, connection and settings.%   

Strange part is that I could flash the samples/empty_app_core/ from ConnectSDK sucessfully. My idea is to have something like this and debug projects in VSCode.

Board is a nRF5340 PDK. Xubuntu OS.

What should I check to determine what's causing this?

Thanks in advance.

  • Hello, avlier!

    I must speak with the author of that tutorial for some details, but in the meantime you can have a look at a tutorial I've looked at myself earlier. It's a bit old, but it enabled me to debug an nRF9160 using VSCode.

    My Cortex Debug configuration is attached below:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Debug NCS",
                "cwd": "${workspaceRoot}",
                "executable": "./build/zephyr/zephyr.elf",
                "request": "launch",
                "type": "cortex-debug",
                "serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe",
                "servertype": "jlink",
                "device": "nrf9160_xxAA",
                "interface": "swd",
                "armToolchainPath": "C:/gnuarmemb/bin",
                "ipAddress": null,
                "serialNumber": null
            }
        ]
    }


    We do not really support debugging solutions outside of SES, but I will do my best to help you.

    Best regards,
    Carl Richard

  • Hey Carl, thanks for sharing your configuration. I've managed to make it work by using "cortex-m33" as "device" value. Not sure if this is the best way but at least I got myself some breakpoints.

  • Hello, again!

    No problem! Glad to hear that you've made it work. 

    I will probably try this out for the nRF5340 myself someday soon. Will update you if I discover a better way.

    Best regards,
    Carl Richard

Related