Debugging in VSCode

Debugging the nRF9151 uses probe-rs as the gdb server. You can easily step through your application in a few steps.

  1. Install Debugger for probe-rs via the VSCode Marketplace.

Debugger Extension

The extension helps facilitate the integration between probe-rs and the built-in debugging facilities of VSCode.

  1. Add a .vscode/launch.json file. Here's an example which is using Circuit Dojo Zephyr Tools:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "nRF9151 • App (Non-Secure)",
      "type": "probe-rs-debug",
      "request": "attach",
      "chip": "nRF9151_xxAA",
      "cwd": "${workspaceFolder}",
      "speed": 4000,
      "coreConfigs": [
        {
          "coreIndex": 0,
          "programBinary": "${workspaceFolder}/app/app/build/circuitdojo_feather_nrf9151/app/zephyr/zephyr.elf"
        }
      ],
      "consoleLogLevel": "Console"
    }
  ]
}
  1. Program merged.hex as normal to your device. In Circuit Dojo Zephyr Tools, you can run the Flash option:

Flash button

This will flash and start running your code. At any point in the process you can view the console output (via the Monitor button).

  1. Then, in the debug menu you should see the new launch option that you created:

Launch Debug

  1. If the connection is successful, you will see a few indications that debugging is running:

Debugging working

This includes a Running indication in the left debug column. You should also see a red disconnect button on the top next to the debugger controls.

From here you can set halt points as normal and debug your firmware!

For more information on debugging with probe-rs, check out the official documentation.