Thingy 91 debugging using breakpoints not working

Hello. For some reason I have a lot of troubles debugging my code using breakpoints on Thingy 91 board.

My setup:

Thingy 91 board

VSCode with NCS v2.5.0

J-Link Compact Plus debugger

The code that I am trying to debug:

/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <stdio.h>
#include <zephyr/kernel.h>

int main(void)
{
	while(1){
		printf("Hello World! %s\n", CONFIG_BOARD);
		k_msleep(1000);
	}
	return 0;
}

All I did was place a breakpoint:

and launch a debug session:

Once the debug session started, the following screen is opened:

after I click F5 to continue:

After I click F5 again, nothing happens. The code does not stop at the breakpoint that I have placed. I cannot wrap my head around what could be an issue. Why does it seem so complicated? I would appreciate if someone could point me in the right direction to understand how to properly stop the code at a breakpoint and what is the cause why it does not do it now?

Am I doing something wrong or its just not working as intended?

Parents
  • Hello, 

    I've tried to reproduce your issue, running Hello World (NCS v2.5.0) in debug mode. The initial test would stop at break point set in main. 

    Pressing F5 to continue, it would end up here when pressing pause. 

    I did another test with the Asset Tracker v2 instead from v2.5.0, building with debug KConfig overlay

    This would consistently trigger the break point I set in e.g. src/events/led_state_event.h

    Kind regards,
    Øyvind

  • Its great that yours are working great.

    Perhaps you got any ideas why would mine work differently? Is there something else I should try to provide you more information so you can help me out atleast a little?

    You mentioned something about debug kconfig overlay. Thats not something I am familliar with. I dont think I used it. Could that be the case?

    Do you need to set anything in prj.conf?

    Would it help if I share to you the whole project including configuration and everything so you can try to replicate the issue on the exact same project?

  • I just tested without the debug overlay and got the same result. Could you please provide the output of running the nRF Connect: Generate Support information from the VS Code command palette? 

  • Hello! Before I captured the support information I went ahead and tried something else. Please see the image that I have attached on my initial post:

    As you can see, the breakpoint is placed on the k_msleep function instead of printf.

    When the breakpoint is placed on the k_msleep, I will get the behaviour that I have explained initially. However, if I remove the breakpoint at k_msleep and add a break point at printf line (line 13). The debug will work as expected and the program will stop at the printf.

    Is there any particular reason why I would not be able to use breakpoint at k_msleep? Are you able to reproduce the issue if you place it on the k_msleep as well?

  • I'm still not able to reproduce. What does the output in your Debug Console state?

    Here is mine

Reply Children
  • I have placed the breakpoint once again on the k_msleep. After I run the debugger, for some reason the code stops at  tfm_arch_config_extensions function (as I have shown in my initial post).

    The debug console logs:
    JLinkGDBServerCL: SEGGER J-Link GDB Server V7.88m Command Line Version
    JLinkGDBServerCL: 
    JLinkGDBServerCL: JLinkARM.dll V7.88m (DLL compiled Jul 19 2023 14:27:38)
    JLinkGDBServerCL: 
    JLinkGDBServerCL: -----GDB Server start settings-----
    JLinkGDBServerCL: GDBInit file:                  none
    JLinkGDBServerCL: GDB Server Listening port:     50693
    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:                 cortex-m33
    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 () at C:/Users/petrikas.lu/Desktop/WORK/NRF/Thingy_91/external/zephyr/arch/arm/core/aarch32\cpu_idle.S:203
    203		msr	BASEPRI, r0
    Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
    
    Breakpoint 2, tfm_core_init () at C:/Users/petrikas.lu/Desktop/WORK/NRF/Thingy_91/external/modules/tee/tf-m/trusted-firmware-m/secure_fw/spm/cmsis_psa/main.c:64
    64	    tfm_arch_config_extensions();
    
    I have also generated support information:
    [14:33:03] ENOENT: no such file or directory, open 'c:\ncs\v2.4.0\.west\config' (c:\ncs\v2.4.0)
    [14:33:21] nRF Command Line Tools 10.23.2 are up to date
    [14:33:39] ENOENT: no such file or directory, open 'c:\ncs\v2.4.0\.west\config' (c:\ncs\v2.4.0)
    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": "win32",
        "osVersion": "Windows 10 Pro",
        "osKernel": "10.0.19045",
        "vscode": "1.84.2",
        "electron": "25.9.2",
        "node": "v18.15.0"
      },
      "system": {
        "date": "2023-11-15T12:33:18.139Z",
        "vscodeRoot": "c:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app",
        "nrfConnectForDesktopInstalled": true,
        "vscodeUptime": "00:00:21",
        "osUptime": "00:11:06",
        "cpu": "AMD Ryzen 7 PRO 5850U with Radeon Graphics"
      },
      "workspace": {
        "name": "app_nrf9160",
        "workspaceFile": null,
        "folders": [
          "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91\\app_nrf9160"
        ]
      },
      "sdks": [
        {
          "version": "2.4.2",
          "path": "c:\\ncs\\v2.4.2"
        },
        {
          "version": "2.5.0",
          "path": "c:\\ncs\\v2.5.0"
        },
        {
          "version": "2.5.0",
          "path": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91"
        }
      ],
      "activeBuild": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91\\app_nrf9160\\build",
      "apps": [
        {
          "workspace": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91\\app_nrf9160",
          "uri": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91\\app_nrf9160",
          "buildConfigurations": [
            {
              "id": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91\\app_nrf9160\\build",
              "name": "build",
              "boardId": "thingy91_nrf9160_ns",
              "type": "Zephyr",
              "isChild": false,
              "isStale": false,
              "taskBindings": {
                "build": [],
                "pristineBuild": [],
                "flash": [],
                "eraseAndFlash": []
              }
            }
          ]
        }
      ],
      "topdir": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91",
      "workspaceState": "empty-ready",
      "toolchains": [
        {
          "version": "2.4.2",
          "path": "c:\\ncs\\toolchains\\31f4403e35"
        },
        {
          "version": "2.5.0",
          "path": "c:\\ncs\\toolchains\\c57af46cb7"
        }
      ],
      "connectedDevices": [],
      "deviceProvider": "nrfutil",
      "tools": {
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gcc.exe": "0.16.1",
        "C:\\Program Files\\SEGGER\\JLink_V788m\\JLink.exe": "7.88m",
        "C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\nrfjprog.exe": "10.23.2",
        "nrfutil": "Not found",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\cmake.exe": "3.20.5",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\Scripts\\west.exe": "1.1.0",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\python.exe": "3.8.2",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\ninja.exe": "1.9.0",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\gperf.exe": "3.1",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\dtc.exe": "1.4.7",
        "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\gn.exe": "2122",
        "C:\\ncs\\toolchains\\c57af46cb7\\mingw64\\bin\\git.exe": "2.37.3.windows.1",
        "gdbPath": "c:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gdb.exe"
      },
      "nrfutil": {
        "nrfutil-device": {
          "version": "2.0.0",
          "binPath": "c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2023.11.24-win32-x64\\platform\\nrfutil\\bin\\nrfutil-device"
        },
        "nrfutil-toolchain-manager": {
          "version": "0.14.1",
          "binPath": "c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2023.11.24-win32-x64\\platform\\nrfutil\\bin\\nrfutil-toolchain-manager"
        }
      },
      "environment": {
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\Users\\petrikas.lu",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\petrikas.lu",
          "PATH": "C:\\ncs\\toolchains\\c57af46cb7;C:\\ncs\\toolchains\\c57af46cb7\\mingw64\\bin;C:\\ncs\\toolchains\\c57af46cb7\\bin;C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin;C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\Scripts;C:\\ncs\\toolchains\\c57af46cb7\\opt\\nanopb\\generator-bin;C:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk\\aarch64-zephyr-elf\\bin;C:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk\\x86_64-zephyr-elf\\bin;C:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin;c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2023.11.24-win32-x64\\platform\\nrfutil\\lib\\nrfutil-toolchain-manager;C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\Program Files\\Amazon\\AWSCLIV2\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\nodejs\\;C:\\Program Files\\MySQL\\MySQL Shell 8.0\\bin\\;C:\\Users\\petrikas.lu\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\petrikas.lu\\.dotnet\\tools;C:\\Program Files (x86)\\Nmap;C:\\Users\\petrikas.lu\\Desktop\\WORK\\openssl-0.9.8k_X64\\bin;C:\\Users\\petrikas.lu\\AppData\\Roaming\\npm;C:\\Program Files\\nodejs;C:\\MinGW\\bin;C:\\MinGW\\mingw32\\bin;C:\\msys\\1.0\\bin;C:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Python\\Python311;C:\\Users\\petrikas.lu\\esp5\\esp-idf\\tools;C:\\Users\\petrikas.lu\\AppData\\Local\\gitkraken\\bin;C:\\Program Files (x86)\\SEGGER\\JLink;",
          "ZEPHYR_BASE": "c:\\Users\\petrikas.lu\\Desktop\\WORK\\NRF\\Thingy_91\\zephyr",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "C:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk",
          "PYTHONPATH": "C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin;C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\Lib;C:\\ncs\\toolchains\\c57af46cb7\\opt\\bin\\Lib\\site-packages"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\Users\\petrikas.lu",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\petrikas.lu",
          "Path": "C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\Program Files\\Amazon\\AWSCLIV2\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\nodejs\\;C:\\Program Files\\MySQL\\MySQL Shell 8.0\\bin\\;C:\\Users\\petrikas.lu\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\petrikas.lu\\.dotnet\\tools;C:\\Program Files (x86)\\Nmap;C:\\Users\\petrikas.lu\\Desktop\\WORK\\openssl-0.9.8k_X64\\bin;C:\\Users\\petrikas.lu\\AppData\\Roaming\\npm;C:\\Program Files\\nodejs;C:\\MinGW\\bin;C:\\MinGW\\mingw32\\bin;C:\\msys\\1.0\\bin;C:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Python\\Python311;C:\\Users\\petrikas.lu\\esp5\\esp-idf\\tools;C:\\Users\\petrikas.lu\\AppData\\Local\\gitkraken\\bin;C:\\Program Files (x86)\\SEGGER\\JLink;",
          "PATH": "C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\Program Files\\Amazon\\AWSCLIV2\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\nodejs\\;C:\\Program Files\\MySQL\\MySQL Shell 8.0\\bin\\;C:\\Users\\petrikas.lu\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\petrikas.lu\\.dotnet\\tools;C:\\Program Files (x86)\\Nmap;C:\\Users\\petrikas.lu\\Desktop\\WORK\\openssl-0.9.8k_X64\\bin;C:\\Users\\petrikas.lu\\AppData\\Roaming\\npm;C:\\Program Files\\nodejs;C:\\MinGW\\bin;C:\\MinGW\\mingw32\\bin;C:\\msys\\1.0\\bin;C:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\petrikas.lu\\AppData\\Local\\Programs\\Python\\Python311;C:\\Users\\petrikas.lu\\esp5\\esp-idf\\tools;C:\\Users\\petrikas.lu\\AppData\\Local\\gitkraken\\bin;C:\\Program Files (x86)\\SEGGER\\JLink;"
        },
        "toolchainPath": "c:\\ncs\\toolchains\\c57af46cb7",
        "toolchainBinPath": "c:\\ncs\\toolchains\\c57af46cb7\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin",
        "toolchainVersion": "2.5.0"
      },
      "terminal": {
        "defaultProfile": null
      },
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "${nrf-connect.sdk:2.5.0}",
          "toolchain": {
            "path": ""
          },
          "ozonePath": "",
          "applications": [],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig",
            "executeInDefaultShell": false
          },
          "welcome": {
            "showOnStartup": true
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "taskBindings": {},
          "debugging": {
            "flash": true,
            "bindings": {}
          },
          "activeAppFollowActiveEditor": true,
          "deviceProvider": "",
          "enableTelemetry": true,
          "thirdpartyIntegration": {},
          "toolchainManager": {
            "indexURL": null,
            "installDirectory": null
          },
          "nrfutil": {
            "home": null
          },
          "defaultOpenAction": "ask"
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        }
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2023.11.24",
            "path": "c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2023.11.24-win32-x64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2023.10.17",
            "path": "c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-terminal-2023.10.17",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2023.10.22",
            "path": "c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-devicetree-2023.10.22",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2023.10.27",
            "path": "c:\\Users\\petrikas.lu\\.vscode\\extensions\\nordic-semiconductor.nrf-kconfig-2023.10.27",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": null,
          "ms-vscode.cpptools": "1.18.4",
          "ms-vscode-remote.remote-wsl-recommender": "0.0.19",
          "ms-vscode.js-debug": "1.84.0",
          "ms-vscode.js-debug-companion": "1.1.2",
          "ms-vscode.vscode-js-profile-table": "1.0.3",
          "aaron-bond.better-comments": "3.0.2",
          "bbenoist.Doxygen": "1.0.0",
          "cschlosser.doxdocgen": "1.4.0",
          "eamodio.gitlens": "14.5.0",
          "ecmel.vscode-html-css": "1.13.1",
          "esbenp.prettier-vscode": "10.1.0",
          "espressif.esp-idf-extension": "1.6.5",
          "GitHub.copilot": "1.136.0",
          "GitHub.copilot-chat": "0.10.1",
          "jeff-hykin.better-cpp-syntax": "1.17.2",
          "mariorodeghiero.vue-theme": "2.0.2",
          "ms-python.isort": "2023.10.1",
          "ms-python.python": "2023.20.0",
          "ms-python.vscode-pylance": "2023.11.10",
          "ms-toolsai.jupyter": "2023.10.1100000000",
          "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.cpptools-extension-pack": "1.3.0",
          "ms-vscode.cpptools-themes": "2.0.0",
          "sdras.night-owl": "2.0.1",
          "SonarSource.sonarlint-vscode": "4.0.5",
          "trond-snekvik.gnu-mapfiles": "1.1.0",
          "webfreak.debug": "0.26.1"
        }
      }
    }
    I hope we can get to the bottom of this as this is quite strange!
  • Hello, sorry for the delayed answer. Do you have e.g. Segger Ozone available, or are you able to test with that using an external programmer i.e. nRF9160DK?

    -Øyvind

  • I have tested it via nRF9160DK and the output is exactly the same.

    Keep in mind that if I just press F5 multiple times to skip all the tfm functions that are triggered, I will eventually get to the breakpoint that I have placed in my main.c.

    So it works but not quite the same as on your side which is strange.

    Regarding the Segger Ozone, I have actually downloaded that the other day but havent set it up fully.

    When I click Debug with Ozone:

    The ozone opens up but there seems to be some issue regarding source files not being found:

    Perhaps its best to contact segger regarding that.

  • Hi, sorry for the late reply. No updates from our side. The debug feature in VS Code have provided some unwanted cases in certain cases. Our VS Code extension team are working towards an optimal solution, but nothing at the moment. As I'm not able to reproduce what you are seeing, I am not able to provide any solution right now.

Related