nRF52840 Dongle Debug with JLINK (Internal or External) in NCS 2.1.0

Hi guys,

As I want to debug on my nRF52840 Dongle with a Debugger, my first step was to connect it with internal segger OB JLINK integrated into nRF52840DK.
This was not efficient, and I was not able to debug using the usual and suggested configuration as 


Maybe due to bootloader or voltage references different ?
The VSCode always show me the DK and not the target device.

SO, I tried with a JLINK base device.

Settings are theese:

Hardware config:

JLINK       | nRF52840

SWDIO       | SWDIO
SWDCLK      | SWDCLK
VREF        | VBUS
GND         | GND
RESET       | RESET

nRF52840 is powered by an external battery of 3.7V
I also connected RESET to the testpoint under the dongle.


launch.json is configured as this:

	"configurations": [
	{
		"name": "Debug with JLink",
		"cwd": "${workspaceFolder}",
		"executable": "${workspaceFolder}\\build\\zephyr\\zephyr.hex",
		"request": "launch",
		"type": "cortex-debug",
		"device": "nRF52840_xxAA",
		"runToEntryPoint": "main",
		"showDevDebugOutput": "raw",
		"servertype": "jlink",
		"interface": "swd",
	},

I select as DEBUGGER EXTENSION the Cortex-Debugger (as nRF-Debugger seems to be not working with external debugger)

BUT the dongle is not working.
VSCode shows me this:

[2022-10-14T13:59:10.968Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:\\Program Files (x86)\\SEGGER\\JLink\\JLinkGDBServerCL.exe" -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device nRF52840_xxAA -select usb=51017173 -rtos "C:\\Program Files\\SEGGER\\JLink\\GDBServer\\RTOSPlugin_Zephyr.dll"
SEGGER J-Link GDB Server V7.66a Command Line Version

JLinkARM.dll V7.66a (DLL compiled May 19 2022 15:13:27)

Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device nRF52840_xxAA -select usb=51017173 -rtos C:\Program Files\SEGGER\JLink\GDBServer\RTOSPlugin_Zephyr.dll
-----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:                 nRF52840_xxAA
Target interface:              SWD
Target interface speed:        4000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V11 compiled Sep 22 2022 14:53:28
Hardware: V11.00
S/N: 51017173
Feature(s): GDB
Checking target voltage...
Target voltage: 3.45 V
Listening on TCP/IP port 50000
Connecting to target...
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000578 (Data = 0x0000E7FE)
Read 2 bytes @ address 0x00000578 (Data = 0xE7FE)
Loading RTOS plugin: C:\Program Files\SEGGER\JLink\GDBServer\RTOSPlugin_Zephyr.dll...
RTOS plugin load failed (Error 193, %1 is not a valid Win32 application.).
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x00000578)
Received monitor command: reset
Resetting target
Downloading 16256 bytes @ address 0x00001000
Downloading 16208 bytes @ address 0x00004F80
Downloading 16224 bytes @ address 0x00008ED0
Downloading 12752 bytes @ address 0x0000CE30
Downloading 16128 bytes @ address 0x00010000
Downloading 16000 bytes @ address 0x00013F00
Downloading 15984 bytes @ address 0x00017D80
Downloading 16048 bytes @ address 0x0001BBF0
Downloading 1376 bytes @ address 0x0001FAA0
Downloading 16032 bytes @ address 0x00020000
Downloading 16032 bytes @ address 0x00023EA0
Downloading 16000 bytes @ address 0x00027D40
Downloading 16016 bytes @ address 0x0002BBC0
Downloading 1456 bytes @ address 0x0002FA50
Downloading 15968 bytes @ address 0x00030000
Downloading 15984 bytes @ address 0x00033E60
Downloading 16032 bytes @ address 0x00037CD0
Downloading 16064 bytes @ address 0x0003BB70
Downloading 1488 bytes @ address 0x0003FA30
Downloading 16112 bytes @ address 0x00040000
Downloading 16272 bytes @ address 0x00043EF0
Downloading 11912 bytes @ address 0x00047E80
Comparing flash   [....................] Done.
Writing register (PC = 0x   1a414)
Received monitor command: reset
Resetting target
Read 4 bytes @ address 0x0001A414 (Data = 0x49132000)
Read 2 bytes @ address 0x0001A414 (Data = 0x2000)
Reading 64 bytes @ address 0x0003B980
Read 2 bytes @ address 0x0003B9C0 (Data = 0xB002)
Reading 64 bytes @ address 0x0003C7C0
Read 2 bytes @ address 0x0003C7CE (Data = 0x4040)
Reading 64 bytes @ address 0x00012500
Read 4 bytes @ address 0x000125D4 (Data = 0x00043694)
Read 2 bytes @ address 0x00012594 (Data = 0xF000)
Read 2 bytes @ address 0x0001250C (Data = 0xB5F0)
Reading register (MSP = 0x20040000)
Reading register (PSP = 0x       0)
Reading register (PRIMASK = 0x       0)
Reading register (BASEPRI = 0x       0)
Reading register (FAULTMASK = 0x       0)
Reading register (CONTROL = 0x       0)
Reading register (FPSCR = 0x       0)
Reading register (s0 = 0x       0)
Reading register (s1 = 0x       0)
Reading register (s2 = 0x       0)
Reading register (s3 = 0x       0)
Reading register (s4 = 0x       0)
Reading register (s5 = 0x       0)
Reading register (s6 = 0x       0)
Reading register (s7 = 0x       0)
Reading register (s8 = 0x       0)
Reading register (s9 = 0x       0)
Reading register (s10 = 0x       0)
Reading register (s11 = 0x       0)
Reading register (s12 = 0x       0)
Reading register (s13 = 0x       0)
Reading register (s14 = 0x       0)
Reading register (s15 = 0x       0)
Reading register (s16 = 0x       0)
Reading register (s17 = 0x       0)
Reading register (s18 = 0x       0)
Reading register (s19 = 0x       0)
Reading register (s20 = 0x       0)
Reading register (s21 = 0x       0)
Reading register (s22 = 0x       0)
Reading register (s23 = 0x       0)
Reading register (s24 = 0x       0)
Reading register (s25 = 0x       0)
Reading register (s26 = 0x       0)
Reading register (s27 = 0x       0)
Reading register (s28 = 0x       0)
Reading register (s29 = 0x       0)
Reading register (s30 = 0x       0)
Reading register (s31 = 0x       0)
Reading register (d0 = 0x       0)
Reading register (d1 = 0x       0)
Reading register (d2 = 0x       0)
Reading register (d3 = 0x       0)
Reading register (d4 = 0x       0)
Reading register (d5 = 0x       0)
Reading register (d6 = 0x       0)
Reading register (d7 = 0x       0)
Reading register (d8 = 0x       0)
Reading register (d9 = 0x       0)
Reading register (d10 = 0x       0)
Reading register (d11 = 0x       0)
Reading register (d12 = 0x       0)
Reading register (d13 = 0x       0)
Reading register (d14 = 0x       0)
Reading register (d15 = 0x       0)
Setting breakpoint @ address 0x0001250C, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x00012594, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x0003B9C0, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x0003C7CE, Size = 2, BPHandle = 0x0004
Starting target CPU...



Another question, as using an external debugger, the original bootloader will be removed... could this cause a problem during compilation? 
I mean, selecting "nRf52840 dongle" in build configuration, will cause an issue if there's no bootloader mounted ?

  • Hi again Enrico, 

    Please try to sum up your issue. Maybe it's easier to answer the following questions: 

    - Have you managed to program any application to the dongle. Please test with very simple application for example blinky.

    - If you can flash the blinky application, did the blinky work ? (LED blink ?)

    - Have you managed to flash the bootloader on the dongle ? Which bootloader you used ? 

    - Please state step by step how you run the debugger ? Which GDB server you used ?  Have you configure the board for debugging. You need to select this : 

Related