Debugging from VSCode with nRF Connect Extension

Hello, I'm having problems to debug my application when I check the "Enable debug options" in the build configuration. If I don't check this box, I can debug, however, most of the break points are ignored and most of the variables are optimized, making the process much harder.

I'm using Linux, SDK v.1.8.0 and I have the following output when I press the Debug button of the nRF Connect extension:

Waiting for gdb server to start...[2022-05-04T12:46:11.237Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
/opt/SEGGER/JLink/JLinkGDBServerCLExe -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device nRF9160_xxAA -select usb=960091702 -rtos /opt/SEGGER/JLink/GDBServer/RTOSPlugin_Zephyr.so
SEGGER J-Link GDB Server V7.60g Command Line Version

JLinkARM.dll V7.60g (DLL compiled Feb  2 2022 10:33:24)

Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device nRF9160_xxAA -select usb=960091702 -rtos /opt/SEGGER/JLink/GDBServer/RTOSPlugin_Zephyr.so
-----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:      yes
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:                 nRF9160_xxAA
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 Dec  3 2021 15:46:55
Hardware: V1.00
S/N: 960091702
Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
Checking target voltage...
Target voltage: 3.30 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 0x0003668A (Data = 0xF3BFB662)
Read 2 bytes @ address 0x0003668A (Data = 0xB662)
Loading RTOS plugin: //opt/SEGGER/JLink/GDBServer/RTOSPlugin_Zephyr.so...
RTOS plugin (API v1.1) loaded successfully
RTOS_Init() core = 235012351
RTOS plugin: Loaded
RTOS_GetSymbols()
Received symbol: _kernel (0x2001B8D0)
Received symbol: _kernel_openocd_offsets (0x0005F864)
Received symbol: z_sys_post_kernel (0x2001BA75)
All mandatory symbols successfully loaded.
Read 4 bytes @ address 0x0003668A (Data = 0xF3BFB662)
All mandatory symbols successfully loaded.
Read 4 bytes @ address 0x0003668A (Data = 0xF3BFB662)
All mandatory symbols successfully loaded.
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x0003668A)
Received monitor command: reset
Resetting target
Downloading 16048 bytes @ address 0x00000000
Downloading 15832 bytes @ address 0x00003EB0
Downloading 16080 bytes @ address 0x00010000
Downloading 16128 bytes @ address 0x00013ED0
Downloading 16224 bytes @ address 0x00017DD0
Downloading 16368 bytes @ address 0x0001BD30
Downloading 736 bytes @ address 0x0001FD20
Downloading 15984 bytes @ address 0x00020000
Downloading 16112 bytes @ address 0x00023E70
Downloading 15984 bytes @ address 0x00027D60
Downloading 16000 bytes @ address 0x0002BBD0
Downloading 1456 bytes @ address 0x0002FA50
Downloading 15920 bytes @ address 0x00030000
Downloading 16016 bytes @ address 0x00033E30
Downloading 15968 bytes @ address 0x00037CC0
Downloading 15952 bytes @ address 0x0003BB20
Downloading 1680 bytes @ address 0x0003F970
Downloading 16048 bytes @ address 0x00040000
Downloading 15984 bytes @ address 0x00043EB0
Downloading 16112 bytes @ address 0x00047D20
Downloading 15968 bytes @ address 0x0004BC10
Downloading 1424 bytes @ address 0x0004FA70
Downloading 15984 bytes @ address 0x00050000
Downloading 15968 bytes @ address 0x00053E70
Downloading 15968 bytes @ address 0x00057CD0
Downloading 16016 bytes @ address 0x0005BB30
Downloading 1600 bytes @ address 0x0005F9C0
Downloading 16272 bytes @ address 0x00060000
Downloading 16208 bytes @ address 0x00063F90
Downloading 2079 bytes @ address 0x00067EE0
Comparing flash   [....................] Done.
Erasing flash     [....................] Done.
Programming flash [....................] Done.
Writing register (PC = 0x       0)
Received monitor command: reset
Resetting target
Read 4 bytes @ address 0x00000000 (Data = 0x20017D68)
Read 2 bytes @ address 0x00000000 (Data = 0x7D68)
Reading 64 bytes @ address 0x00031C80
Read 2 bytes @ address 0x00031C9C (Data = 0x4B80)
Read 2 bytes @ address 0x00031CA0 (Data = 0x2300)
Read 2 bytes @ address 0x00031CB2 (Data = 0x461A)
Read 2 bytes @ address 0x00031CDE (Data = 0xF001)
Read 2 bytes @ address 0x00031CE2 (Data = 0xF001)
Reading 64 bytes @ address 0x00053FC0
Read 2 bytes @ address 0x00053FE6 (Data = 0xF8C0)
Reading 64 bytes @ address 0x000187C0
Read 2 bytes @ address 0x00031C8C (Data = 0xE92D)
Read 2 bytes @ address 0x000187CE (Data = 0xB508)
Read 2 bytes @ address 0x00000438 (Data = 0xB57F)
Setting breakpoint @ address 0x00000438, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x000187CE, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x00031C8C, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x00031C9C, Size = 2, BPHandle = 0x0004
Setting breakpoint @ address 0x00031CA0, Size = 2, BPHandle = 0x0005
Setting breakpoint @ address 0x00031CB2, Size = 2, BPHandle = 0x0006
Setting breakpoint @ address 0x00031CDE, Size = 2, BPHandle = 0x0007
Setting breakpoint @ address 0x00031CE2, Size = 2, BPHandle = 0x0008
Setting breakpoint @ address 0x00053FE6, Size = 2, BPHandle = 0x0009
Starting target CPU...
Erasing flash     [....................] Done.
Programming flash [....................] Done.
...Breakpoint reached @ address 0x00000438
RTOS_UpdateThreads()
Parsed thread -1046179653, next=0
RTOS_GetNumThreads() --> 1
RTOS_GetCurrentThreadId()
Reading all registers
RTOS_GetThreadRegList(, -583729001)
RTOS_GetThreadReg(, 0, -583729001)
Read register 0 (4 bytes) from DLL: 04000000
RTOS_GetThreadReg(, 1, -583729001)
Read register 1 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 2, -583729001)
Read register 2 (4 bytes) from DLL: 01000000
RTOS_GetThreadReg(, 3, -583729001)
Read register 3 (4 bytes) from DLL: 746D0000
RTOS_GetThreadReg(, 4, -583729001)
Read register 4 (4 bytes) from DLL: 193C0000
RTOS_GetThreadReg(, 5, -583729001)
Read register 5 (4 bytes) from DLL: 20000000
RTOS_GetThreadReg(, 6, -583729001)
Read register 6 (4 bytes) from DLL: 68550120
RTOS_GetThreadReg(, 7, -583729001)
Read register 7 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 8, -583729001)
Read register 8 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 9, -583729001)
Read register 9 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 10, -583729001)
Read register 10 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 11, -583729001)
Read register 11 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 12, -583729001)
Read register 12 (4 bytes) from DLL: 00000000
RTOS_GetThreadReg(, 13, -583729001)
Read register 13 (4 bytes) from DLL: 607D0120
RTOS_GetThreadReg(, 14, -583729001)
Read register 14 (4 bytes) from DLL: 353C0000
RTOS_GetThreadReg(, 15, -583729001)
Read register 15 (4 bytes) from DLL: 38040000
RTOS_GetThreadReg(, 16, -583729001)
Read register 16 (4 bytes) from DLL: 00000069
RTOS_GetNumThreads() --> 1
RTOS_GetThreadId(0)
Removing breakpoint @ address 0x00000438, Size = 2
Removing breakpoint @ address 0x000187CE, Size = 2
Removing breakpoint @ address 0x00031C8C, Size = 2
Removing breakpoint @ address 0x00031C9C, Size = 2
Removing breakpoint @ address 0x00031CA0, Size = 2
Removing breakpoint @ address 0x00031CB2, Size = 2
Removing breakpoint @ address 0x00031CDE, Size = 2
Removing breakpoint @ address 0x00031CE2, Size = 2
Removing breakpoint @ address 0x00053FE6, Size = 2
Debugger requested to halt target...


Any idea how to fix this? 

Thank you!

Related