Skip to content

NOTE (Debug)

softgraph edited this page May 13, 2019 · 3 revisions

Debugging with gdb, pyOCD and VS Code

Debug System Structure

Visual Studio Code
(as a debugger UI)
C/C++ for Visual Studio Code
arm-none-eabi-gdb
pyOCD
USB
The debug target
(micro:bit device)

Module Outlines

About .vscode/launch.json

  • .vscode/launch.json is a configuration file used by VS Code for debugging.

Instructions to Start Debugging

  1. Build the executable suitable for debugging using the following commands.

    • yotta build --debug-build (or yt build -d)

    Note that the following file is required to suppress the compile error of nrf51-sdk for a debug build.

    • source/suppress-errors.nrf51-sdk.cmake
  2. Flash the combined.hex file (microbit-dal-ext-kit-example-combined.hex) to the device.

  3. Launch VS Code and open the project root folder (microbit-dal-ext-kit-example).

  4. On VS Code, select Debug -> Start Debugging (F5) to start a debug session using .vscode/launch.json.

  5. The debugger automatically stops at funciton main().

For the general topics regarding debugger, see also References (Debugging Tools).

Hints for Customizing launch.json

Troubleshooting

  • If the debugger does not stop at function main() after starting the debug session, kill the following processes and try again.

    • arm-none-eabi-gdb
    • pyocd
  • If you are in trouble with VS Code and launch.json, verify gdb and pyOCD behavior without VS Code.
    The following note would be a good guide for you.