J-Link Debugger Hang Issue

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!

Parents
  • Hi,

    For us to have a better look at your system, can you Generate support information and upload it here as a txt file?
    If you do not want to share all your data in a public case, you can either REDACT information you do not want to share, or I can convert this case to a private case.

    Regards,
    Sigurd Hellesvik

  • Hi Segurd,

    Sure thing, see below.

    IMPORTANT: The data below could contain sensitive or confidential information about your environment.
    If you do not wish this to be seen by others, please make sure to remove it before sharing.
    
    For help and support, visit the Nordic DevZone at https://devzone.nordicsemi.com/.
    
    {
      "platform": {
        "os": "darwin",
        "osVersion": "Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000",
        "osKernel": "22.5.0",
        "vscode": "1.80.0",
        "electron": "22.3.14",
        "node": "v16.17.1"
      },
      "system": {
        "date": "2023-07-20T13:09:11.539Z",
        "vscodeRoot": "/Applications/Visual Studio Code.app/Contents/Resources/app",
        "nrfConnectForDesktopInstalled": true,
        "vscodeUptime": "143:27:51",
        "osUptime": "143:28:27",
        "cpu": {
          "model": "Apple M1 Max",
          "speed": "24 MHz",
          "count": 5
        },
        "memory": {
          "total": "32.00 GB",
          "free": "0.35 GB"
        }
      },
      "workspace": {
        "name": "Untitled (Workspace)",
        "workspaceFile": "1687886788912",
        "folders": [
          "REPO-PATH/nordic-soc-firmware",
          "REPO-PATH/nordic-soc-firmware/peripheral_mds",
          "REPO-PATH/nordic-soc-firmware/sr_coex"
        ]
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2023.6.345",
            "path": "/Users/brushlow/.vscode/extensions/nordic-semiconductor.nrf-connect-2023.6.345-darwin-arm64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2023.6.78",
            "path": "/Users/brushlow/.vscode/extensions/nordic-semiconductor.nrf-terminal-2023.6.78",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2023.6.108",
            "path": "/Users/brushlow/.vscode/extensions/nordic-semiconductor.nrf-devicetree-2023.6.108",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2023.6.51",
            "path": "/Users/brushlow/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2023.6.51",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": "1.12.0",
          "ms-vscode.cpptools": "1.16.3",
          "ms-vscode.js-debug": "1.80.0",
          "ms-vscode.js-debug-companion": "1.1.1",
          "ms-vscode.vscode-js-profile-table": "1.0.3",
          "akiramiyakoda.cppincludeguard": "1.7.1",
          "bierner.markdown-checkbox": "0.4.0",
          "cschlosser.doxdocgen": "1.4.0",
          "gitpod.gitpod-desktop": "0.0.137",
          "gitpod.gitpod-remote-ssh": "0.0.48",
          "mcu-debug.debug-tracker-vscode": "0.0.15",
          "mcu-debug.memory-view": "0.0.22",
          "mcu-debug.peripheral-viewer": "1.4.6",
          "mcu-debug.rtos-views": "0.0.7",
          "ms-azuretools.vscode-docker": "1.25.2",
          "ms-python.python": "2023.12.0",
          "ms-python.vscode-pylance": "2023.7.20",
          "ms-toolsai.jupyter": "2023.6.1101941928",
          "ms-toolsai.jupyter-keymap": "1.1.2",
          "ms-toolsai.jupyter-renderers": "1.0.17",
          "ms-toolsai.vscode-jupyter-cell-tags": "0.1.8",
          "ms-toolsai.vscode-jupyter-slideshow": "0.1.5",
          "ms-vscode-remote.remote-ssh": "0.102.0",
          "ms-vscode-remote.remote-ssh-edit": "0.86.0",
          "ms-vscode.cmake-tools": "1.14.34",
          "ms-vscode.cpptools-extension-pack": "1.3.0",
          "ms-vscode.cpptools-themes": "2.0.0",
          "ms-vscode.hexeditor": "1.9.11",
          "ms-vscode.remote-explorer": "0.4.1",
          "mshr-h.veriloghdl": "1.11.11",
          "trond-snekvik.gnu-mapfiles": "1.1.0",
          "twxs.cmake": "0.0.17"
        }
      },
      "tools": {
        "/opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc": "0.14.1",
        "/Applications/SEGGER/JLink/JLinkExe": "7.88m",
        "/usr/local/bin/nrfjprog": "10.22.0",
        "nrfutil": "Not found",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/cmake": "3.20.5",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/west": "0.13.1",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/python3": "3.9.6",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/ninja": "1.10.2",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/gperf": "3.1",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/dtc": "1.6.1",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/gn": "2039",
        "/opt/nordic/ncs/toolchains/v2.0.0/bin/git": "2.32.0",
        "gdbPath": "/opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb-no-py"
      },
      "sdks": [
        {
          "version": "2.0.0",
          "path": "/opt/nordic/ncs/v2.0.0"
        },
        {
          "version": "2.3.0",
          "path": "/opt/nordic/ncs/v2.3.0"
        },
        {
          "version": "2.4.0",
          "path": "/opt/nordic/ncs/v2.4.0"
        }
      ],
      "toolchains": [
        {
          "version": "2.0.0",
          "path": "/opt/nordic/ncs/toolchains/v2.0.0"
        },
        {
          "version": "2.3.0",
          "path": "/opt/nordic/ncs/toolchains/v2.3.0"
        },
        {
          "version": "2.4.0",
          "path": "/opt/nordic/ncs/toolchains/4ef6631da0"
        }
      ],
      "connectedDevices": [
        {
          "serialNumber": "1050011113"
        },
        {
          "serialNumber": "51025794"
        }
      ],
      "deviceProvider": "nrfjprog",
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "${nrf-connect.sdk:2.0.0}",
          "toolchain": {
            "path": "${nrf-connect.toolchain:2.0.0}"
          },
          "ozonePath": "",
          "applications": [
            "${workspaceFolder}/Periph_Device",
            "${workspaceFolder}/Central_Device"
          ],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig",
            "executeInDefaultShell": false
          },
          "welcome": {
            "showOnStartup": false
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "taskBindings": {},
          "debugging": {
            "flash": true,
            "bindings": {}
          },
          "activeAppFollowActiveEditor": true,
          "deviceProvider": "nrfjprog",
          "enableTelemetry": false
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        },
        "marus25.cortex-debug": {
          "variableUseNaturalFormat": true,
          "liveWatchRefreshRate": "300",
          "armToolchainPath": null,
          "armToolchainPrefix": "arm-none-eabi",
          "gdbPath": null,
          "objdumpPath": null,
          "JLinkGDBServerPath": null,
          "openocdPath": null,
          "pyocdPath": null,
          "PEGDBServerPath": null,
          "stutilPath": null,
          "stlinkPath": null,
          "stm32cubeprogrammer": null,
          "enableTelemetry": true,
          "dbgServerLogfile": null
        }
      },
      "environment": {
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "GIT_EXEC_PATH": "/opt/nordic/ncs/toolchains/v2.0.0/Cellar/git/2.32.0_1/libexec/git-core",
          "HOME": "/Users/brushlow",
          "PATH": "/opt/nordic/ncs/toolchains/v2.0.0/bin:/opt/nordic/ncs/toolchains/v2.0.0/usr/bin:/opt/nordic/ncs/toolchains/v2.0.0/usr/local/bin:/opt/nordic/ncs/toolchains/v2.0.0/opt/bin:/opt/nordic/ncs/toolchains/v2.0.0/opt/nanopb/generator-bin:/opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin:/opt/homebrew/anaconda3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/homebrew/anaconda3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
          "ZEPHYR_BASE": "/opt/nordic/ncs/v2.0.0/zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "/opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk",
          "USER": "brushlow"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "/Users/brushlow",
          "PATH": "/opt/homebrew/anaconda3/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
          "USER": "brushlow"
        },
        "toolchainPath": "/opt/nordic/ncs/toolchains/v2.0.0",
        "toolchainBinPath": "/opt/nordic/ncs/toolchains/v2.0.0/opt/zephyr-sdk/arm-zephyr-eabi/bin",
        "toolchainVersion": "2.0.0"
      },
      "terminal": {
        "defaultProfile": null
      }
    }
    
    

    Thanks

  • Hi Jonathan,

    SEGGER Ozone seems to work well, as I can't find any issues with its operation on my suspect J-Link and target. I exited that session and immediately tried the default debug option with the same J-Link probe and target. It hits the main breakpoint this time, but now I get a lot of unexpected breakpoints of low-level init functions (e.g. ARM_MPU_SetRegionEx). Eventually it hit a SIGTRAP error and I had to restart; after restarting, the functionality described in my original post returned (i.e. wouldn't hit main() breakpoint). All that to say, the default debug option (without Ozone) still seems to not be fully operational for me, while Ozone works well.

    I do have the J-Link probe firmware upgraded to the latest version.

    Thanks

  • Apologies, I just saw your question regarding my experience on other DKs. I am only experiencing it on my sole J-Link Base probe. I do not experience the same issue on my nRF5340 DK.

    I was suspicious of my J-Link base probe, but per the alternative debugger test you suggested, that probe seems to work fine with Ozone.

  • brushlow said:
    I can't find any issues with its operation on my suspect J-Link and target.

    Since Ozone works as expected then I think it is ok to assume that the debugger HW is not the issue, but you do say "my suspected J-Link", does that mean that you have multiple other J-Link's that do not portray this issue?

    - But if you have the option to test a few different debuggers then that would good just to confirm 100% that it is not isolated to one J-Link device. 

    Has there been any updates to the OS from when there where no issues to when the issues started?

    Regards,
    Jonathan

  • Sorry for the ambiguity, I only have one external J-Link Base probe. The only other devices I have to work from are two nRF5340 DKs; debugging on these DKs works fine. Unfortunately, I don't have the immediate option to test with other external J-Link probes unless I can pretty well prove this one is defunct (which seems less likely at this point).

    There have been a few minor updates to macOS since I last remember everything working (probably late May to early June). I couldn't say whether or not an update coincided with my debugger issues.

  • Thanks for the clarification. I think we are on the same page then. I have been checking with the developers on this but currently still many is on vacation, so it will be looked at but can promise any traction on the matter. Might be hard to preproduce as well.
    Feel free to update if you find some other solution or if the issue is suddenly fixed. Will also keep you updated if i find anything else useful to ask about or if there is something else the developers would like to know. 

    Regards,
    Jonathan 

Reply
  • Thanks for the clarification. I think we are on the same page then. I have been checking with the developers on this but currently still many is on vacation, so it will be looked at but can promise any traction on the matter. Might be hard to preproduce as well.
    Feel free to update if you find some other solution or if the issue is suddenly fixed. Will also keep you updated if i find anything else useful to ask about or if there is something else the developers would like to know. 

    Regards,
    Jonathan 

Children
Related