Can't debug the system with jlink

I have tried to debug my nordic5340 with VS code and it fails to load the code, although I'm able to flash the code using vs code.

when trying to track the problem using the Jlink commander I get a message the jlink fails to connect as my device is secured.

It offers to unsecure the board but that doesn't work.

see below logs:

SEGGER J-Link Commander V8.12d (Compiled Jan 29 2025 13:07:00)
DLL version V8.12d, compiled Jan 29 2025 13:06:04

Connecting to J-Link via USB...O.K.
Firmware: J-Link V12 compiled Dec 4 2024 17:53:50
Hardware version: V12.00
J-Link uptime (since boot): 0d 00h 01m 55s
S/N: 52003290
License(s): GDB
USB speed mode: High speed (480 MBit/s)
VTref=1.812V


Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. <Default>: CORTEX-M33
Type '?' for selection dialog
Device>?
Please specify target interface:
J) JTAG (Default)
S) SWD
T) cJTAG
TIF>JTAG
Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect
JTAGConf>
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>4000
Device "NRF5340_XXAA_APP" selected.


Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 23us
InitTarget() start
Device will be unsecured now.
InitTarget() end - Took 11.2s
Connect failed. Resetting via Reset pin and trying again.
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 8us
InitTarget() start
Device will be unsecured now.
InitTarget() end - Took 2.31s
Error occurred: Could not connect to the target device.
For troubleshooting steps visit: wiki.segger.com/J-Link_Troubleshooting
J-Link>

Parents
  • Hi again Joshua,

    Does recovering or "erasing all" help? Do you have all the switches on the board on the board in the default position?

    Regards,

    Elfving

  • Hi Elfving,

    This debug is working in the evaluation board; its our board, which is based on nRF5340 MCU that I can't connect with a debugger. Flashing with the VS code is working well but it seems like some security locks not allowing to connect with the J-link.

  • also recovering helps when the device program fails, but the connection to the j-link for debugging always fails

  • sometimes the debug console shows the following logs, which implies that the jlink debug server was able to connect but vs code doesn't show anything on the IDE:

    JLinkGDBServerCL: SEGGER J-Link GDB Server V8.12d Command Line Version
    JLinkGDBServerCL: 
    JLinkGDBServerCL: JLinkARM.dll V8.12d (DLL compiled Jan 29 2025 13:06:04)
    JLinkGDBServerCL: 
    JLinkGDBServerCL: -----GDB Server start settings-----
    JLinkGDBServerCL: GDBInit file:                  none
    JLinkGDBServerCL: GDB Server Listening port:     57568
    JLinkGDBServerCL: SWO raw output listening port: 2332
    JLinkGDBServerCL: Terminal I/O port:             2333
    JLinkGDBServerCL: Accept remote connection:      localhost only
    JLinkGDBServerCL: Generate logfile:              off
    JLinkGDBServerCL: Verify download:               off
    JLinkGDBServerCL: Init regs on start:            off
    JLinkGDBServerCL: Silent mode:                   on
    JLinkGDBServerCL: Single run mode:               on
    JLinkGDBServerCL: Target connection timeout:     0 ms
    JLinkGDBServerCL: ------J-Link related settings------
    JLinkGDBServerCL: J-Link Host interface:         USB
    JLinkGDBServerCL: J-Link script:                 none
    JLinkGDBServerCL: J-Link settings file:          none
    JLinkGDBServerCL: ------Target related settings------
    JLinkGDBServerCL: Target device:                 nrf5340_xxaa_app
    JLinkGDBServerCL: Target device parameters:      none
    JLinkGDBServerCL: Target interface:              SWD
    JLinkGDBServerCL: Target interface speed:        12000kHz
    JLinkGDBServerCL: Target endian:                 little
    JLinkGDBServerCL: 
    =thread-group-added,id="i1"
    =cmd-param-changed,param="pagination",value="off"
    arch_cpu_atomic_idle (key=32) at C:/Repos/Genio2.2/genio-worskpace/zephyr/arch/arm/core/cortex_m/cpu_idle.c:131
    131		SLEEP_IF_ALLOWED(__WFE);
    

Reply
  • sometimes the debug console shows the following logs, which implies that the jlink debug server was able to connect but vs code doesn't show anything on the IDE:

    JLinkGDBServerCL: SEGGER J-Link GDB Server V8.12d Command Line Version
    JLinkGDBServerCL: 
    JLinkGDBServerCL: JLinkARM.dll V8.12d (DLL compiled Jan 29 2025 13:06:04)
    JLinkGDBServerCL: 
    JLinkGDBServerCL: -----GDB Server start settings-----
    JLinkGDBServerCL: GDBInit file:                  none
    JLinkGDBServerCL: GDB Server Listening port:     57568
    JLinkGDBServerCL: SWO raw output listening port: 2332
    JLinkGDBServerCL: Terminal I/O port:             2333
    JLinkGDBServerCL: Accept remote connection:      localhost only
    JLinkGDBServerCL: Generate logfile:              off
    JLinkGDBServerCL: Verify download:               off
    JLinkGDBServerCL: Init regs on start:            off
    JLinkGDBServerCL: Silent mode:                   on
    JLinkGDBServerCL: Single run mode:               on
    JLinkGDBServerCL: Target connection timeout:     0 ms
    JLinkGDBServerCL: ------J-Link related settings------
    JLinkGDBServerCL: J-Link Host interface:         USB
    JLinkGDBServerCL: J-Link script:                 none
    JLinkGDBServerCL: J-Link settings file:          none
    JLinkGDBServerCL: ------Target related settings------
    JLinkGDBServerCL: Target device:                 nrf5340_xxaa_app
    JLinkGDBServerCL: Target device parameters:      none
    JLinkGDBServerCL: Target interface:              SWD
    JLinkGDBServerCL: Target interface speed:        12000kHz
    JLinkGDBServerCL: Target endian:                 little
    JLinkGDBServerCL: 
    =thread-group-added,id="i1"
    =cmd-param-changed,param="pagination",value="off"
    arch_cpu_atomic_idle (key=32) at C:/Repos/Genio2.2/genio-worskpace/zephyr/arch/arm/core/cortex_m/cpu_idle.c:131
    131		SLEEP_IF_ALLOWED(__WFE);
    

Children
Related