Debugging in VS Code: does not halt in main() and can not view peripherals

Hi there!

I'm using nRF Connect SDK v2.1.2 and VS Code 1.73.1 with nRF Connect extensions on a Windows 11 x64 machine. I created a Freestanding application based on the nrf/applications/asset_tracker_v2 as a starting point for the Thingy:91

Coming from Segger Embedded Studio + nRF5 SDK 17.0.2, I'm completely new to this dev system and any pointers will be much appreciated. I learned (the hard way) that I had to disable debug options in the build configuration for debugging to work at all.

When I start debugging, it programs the nRF9160 and breaks here in cpu_idle.S, not main():

It also does not show any peripherals. I can put a breakpoint somewhere in main(), run and it will break there.

I created a launch.json file and here is the content:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "nrf-connect",
            "request": "launch",
            "name": "Launch active build configuration",
            "config": "${activeConfig}",
            "runToEntryPoint": "main"
        },
        {
            "name": "Launch build",
            "type": "nrf-connect",
            "request": "launch",
            "config": "d:\\Work\\PICONOMIX\\projects-contract\\DAU\\Thingy91\\firmware\\asset_tracker_v2\\build",
            "runToEntryPoint": "main",
            "svdFile": "d:\\ncs\\v2.1.2\\modules\\hal\\nordic\\nrfx\\mdk\\nrf9160.svd"
        }
    ]
}

So the "runToEntryPoint" field means that it is supposed to stop in main(), right?

I added the "svdFile" field to see if I could fix the "PERIPHERALS" view but that property name is not valid.

How do I fix this? Must I install and use the Cortex-Debug extension?

Thanks in advance,

Pieter

https://piconomix.com

Parents Reply Children
  • P.S.S. Does it have to do with the fact that I installed the Nordic SDK on the D: drive? Here is the support information:

    {
      "platform": {
        "os": "win32",
        "osVersion": "Windows 10 Home",
        "osKernel": "10.0.22621",
        "vscode": "1.73.1",
        "electron": "19.0.17",
        "node": "v16.14.2"
      },
      "system": {
        "date": "2022-11-25T13:18:01.966Z",
        "vscodeRoot": "c:\\Program Files\\Microsoft VS Code\\resources\\app",
        "nrfConnectForDesktopInstalled": true,
        "vscodeUptime": "01:26:27",
        "osUptime": "01:27:47",
        "cpu": {
          "model": "12th Gen Intel(R) Core(TM) i5-12600",
          "speed": "3302 MHz",
          "count": 6
        },
        "memory": {
          "total": "15.75 GB",
          "free": "8.84 GB"
        }
      },
      "workspace": {
        "name": "Untitled (Workspace)",
        "workspaceFile": "1669299877415",
        "folders": [
          "d:\\Work\\PICONOMIX\\projects\\Thingy91\\firmware\\asset_tracker_v2"
        ]
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2022.10.30",
            "path": "c:\\Users\\Pieter\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2022.10.30-win32-x64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2022.10.7",
            "path": "c:\\Users\\Pieter\\.vscode\\extensions\\nordic-semiconductor.nrf-terminal-2022.10.7",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2022.9.11",
            "path": "c:\\Users\\Pieter\\.vscode\\extensions\\nordic-semiconductor.nrf-devicetree-2022.9.11",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2022.10.7",
            "path": "c:\\Users\\Pieter\\.vscode\\extensions\\nordic-semiconductor.nrf-kconfig-2022.10.7",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": null,
          "ms-vscode.cpptools": "1.12.4",
          "ms-vscode-remote.remote-wsl-recommender": "0.0.17",
          "ms-vscode.js-debug": "1.72.0",
          "ms-vscode.js-debug-companion": "1.0.18",
          "ms-vscode.vscode-js-profile-table": "1.0.3",
          "dan-c-underwood.arm": "1.7.4",
          "ms-vscode.cpptools-extension-pack": "1.3.0",
          "ms-vscode.cpptools-themes": "2.0.0",
          "trond-snekvik.gnu-mapfiles": "1.1.0"
        }
      },
      "tools": {
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gcc.exe": "0.14.1",
        "C:\\Program Files\\SEGGER\\JLink\\JLink.exe": "7.82b",
        "C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\nrfjprog.exe": "10.18.1",
        "nrfutil": "Not found",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\cmake.exe": "3.20.5",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\Scripts\\west.exe": "0.14.0",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\python.exe": "3.8.2",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\ninja.exe": "1.9.0",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\gperf.exe": "3.1",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\dtc.exe": "1.4.7",
        "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\gn.exe": "2071",
        "d:\\ncs\\toolchains\\v2.1.2\\mingw64\\bin\\git.exe": "2.26.2.windows.1"
      },
      "sdks": [
        {
          "version": "2.1.2",
          "path": "d:\\ncs\\v2.1.2"
        }
      ],
      "toolchains": [
        {
          "version": "2.1.2",
          "path": "d:\\ncs\\toolchains\\v2.1.2"
        }
      ],
      "connectedDevices": [
        {
          "serialNumber": "59201630"
        }
      ],
      "deviceProviders": [
        "nrfjprog"
      ],
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "${nrf-connect.sdk:2.1.2}",
          "toolchain": {
            "path": "${nrf-connect.toolchain:2.1.2}"
          },
          "ozonePath": "",
          "applications": [
            "${workspaceFolder}"
          ],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig"
          },
          "welcome": {
            "showOnStartup": true
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "enableTelemetry": false,
          "taskBindings": {},
          "debugging": {
            "backend": "nRF Debug",
            "flash": true
          },
          "activeAppFollowActiveEditor": true
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        }
      },
      "environment": {
        "westExe": "west",
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\SPB_Data",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\Pieter",
          "Path": "d:\\ncs\\toolchains\\v2.1.2\\mingw64\\bin;d:\\ncs\\toolchains\\v2.1.2\\mingw64\\libexec\\git-core;d:\\ncs\\toolchains\\v2.1.2\\opt\\bin;d:\\ncs\\toolchains\\v2.1.2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin;d:\\ncs\\toolchains\\v2.1.2\\arm-zephyr-eabi\\bin;d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\Scripts;C:\\Program Files\\SlickEdit Pro 27.0.0\\win\\;C:\\ProgramData\\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\\TortoiseSVN\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\TortoiseGit\\bin;C:\\UnixShellUtils\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Python\\3.11\\Scripts\\;C:\\Python\\3.11\\;C:\\Users\\Pieter\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Pieter\\AppData\\Local\\atom\\bin;C:\\Users\\Pieter\\AppData\\Local\\Microsoft\\WindowsApps;",
          "ZEPHYR_BASE": "d:\\ncs\\v2.1.2\\zephyr",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "d:\\ncs\\toolchains\\v2.1.2\\opt\\zephyr-sdk",
          "PYTHONPATH": "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin;d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\Lib;d:\\ncs\\toolchains\\v2.1.2\\opt\\bin\\Lib\\site-packages",
          "Python3_ROOT": "d:\\ncs\\toolchains\\v2.1.2\\opt\\bin"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\SPB_Data",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\Pieter",
          "Path": "C:\\Program Files\\SlickEdit Pro 27.0.0\\win\\;C:\\ProgramData\\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\\TortoiseSVN\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\TortoiseGit\\bin;C:\\UnixShellUtils\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Python\\3.11\\Scripts\\;C:\\Python\\3.11\\;C:\\Users\\Pieter\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Pieter\\AppData\\Local\\atom\\bin;C:\\Users\\Pieter\\AppData\\Local\\Microsoft\\WindowsApps;",
          "PATH": "C:\\Program Files\\SlickEdit Pro 27.0.0\\win\\;C:\\ProgramData\\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\\TortoiseSVN\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\TortoiseGit\\bin;C:\\UnixShellUtils\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Python\\3.11\\Scripts\\;C:\\Python\\3.11\\;C:\\Users\\Pieter\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Pieter\\AppData\\Local\\atom\\bin;C:\\Users\\Pieter\\AppData\\Local\\Microsoft\\WindowsApps;"
        },
        "toolchainPath": "d:\\ncs\\toolchains\\v2.1.2",
        "toolchainBinPath": "d:\\ncs\\toolchains\\v2.1.2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin",
        "toolchainVersion": "2.1.2"
      },
      "terminal": {
        "shell": null,
        "defaultProfile": null
      }
    }

Related