I am developing on a custom board nRF5340 using an external J-Link Base Classic in VSCode nRF Connect SDK 2.0.0. I am using macOS 13.4.1. After months of being able to debug without issue, I now am having issues getting the debugger to work. Flashing always works fine, and the application runs as expected. When selecting Debug, the terminal indicates everything has loaded successfully and I see the Debug bar in VSCode, but main() breakpoint is never hit and the Debug bar shows a pause button as if it is running. Trying to hit the pause button does nothing. Here is the Debug Console output:
JLinkGDBServerCLexe: SEGGER J-Link GDB Server V7.88m Command Line Version JLinkGDBServerCLexe: JLinkGDBServerCLexe: JLinkARM.dll V7.88m (DLL compiled Jul 19 2023 14:21:54) JLinkGDBServerCLexe: JLinkGDBServerCLexe: -----GDB Server start settings----- JLinkGDBServerCLexe: GDBInit file: none JLinkGDBServerCLexe: GDB Server Listening port: 64727 JLinkGDBServerCLexe: SWO raw output listening port: 2332 JLinkGDBServerCLexe: Terminal I/O port: 2333 JLinkGDBServerCLexe: Accept remote connection: yes JLinkGDBServerCLexe: Generate logfile: off JLinkGDBServerCLexe: Verify download: off JLinkGDBServerCLexe: Init regs on start: off JLinkGDBServerCLexe: Silent mode: on JLinkGDBServerCLexe: Single run mode: on JLinkGDBServerCLexe: Target connection timeout: 0 ms JLinkGDBServerCLexe: ------J-Link related settings------ JLinkGDBServerCLexe: J-Link Host interface: USB JLinkGDBServerCLexe: J-Link script: none JLinkGDBServerCLexe: J-Link settings file: none JLinkGDBServerCLexe: ------Target related settings------ JLinkGDBServerCLexe: Target device: nRF5340_xxAA_APP JLinkGDBServerCLexe: Target device parameters: none JLinkGDBServerCLexe: Target interface: SWD JLinkGDBServerCLexe: Target interface speed: 12000kHz JLinkGDBServerCLexe: Target endian: little JLinkGDBServerCLexe: =thread-group-added,id="i1" =cmd-param-changed,param="pagination",value="off" arch_cpu_idle () at /opt/nordic/ncs/v2.0.0/zephyr/arch/arm/core/aarch32/cpu_idle.S:105 105 cpsie i [New Remote target]
The IDE will sit like this indefinitely. That is, until I found that by merely opening up the nRF Connect for Desktop Programmer application, the main() breakpoint is immediately hit. At that point, I am able to step and set breakpoints as expected. The Debug Console output is amended with the following:
[New Thread 536893792] [New Thread 536890440] [New Thread 536894288] [New Thread 536887536] [New Thread 536887784] [Switching to Thread 536894040] Thread 2 hit Breakpoint 1, main () at ../src/main.c:201 201 {
This is okay as a workaround, but I'm eager to find a long-term solution as to why this occurs. I've tried deleting my Segger tools installation and re-installing (the universal version, as per the Nordic installation guide), and upgraded the probe firmware using JLinkConfig, to no avail. I also have a nRF5340 DK, and I do NOT experience the same issue debugging when using the on-board debugger; I tried using the external J-Link probe on the DK (instead of the on-board debugger), and I DO encounter the debugging issue. So it appears localized to either the external J-link probe or its interaction with my PC.
Thanks in advance for any insights!