Debugging the Raspberry Pi Pico using Picoprobe

Video Tutorial

Read on to find a written tutorial below! Also below is the pre-buit version of OpenOCB.

Why do you want to debug the Pico?

Debugging is an integral part of software development. It offers a peak ‘under the hood’ of your code so to speak by allowing you to inspect variables that are set whilst the program is actually running on your hardware. Debugging also allows you to set breakpoints in your code which essentially pauses the code execution at any point you want. This tutorial walks you through how to debug the Raspberry Pi Pico using a Picoprobe and OpenOCD in the VSCode environment.

Prebuilt OpenOCD for windows and PicoProbe

You can download the ZIP file here. Ensure to extract the files somewhere sensible as you will need the files elsewhere.

You can build your own version of OpenOCD by following the steps in Appendix A of the getting started guide. My pre-built folder is simply intended as a time saver but if you are going to build your own version then you will have to source the libusb-1.0.dll file from libusb.

settings.json

Add the following lines of code to your settings.json file which you can access by using the ctrl+, shortcut and clicking the open JSON file button in the top right corner of the VSCode window. Alter the “PATH TO openocd.exe” to wherever your openocd.exe is, including the openocd.exe for example: “c:/pico/openocd.openocd.exe”.

"cortex-debug.openocdPath": "PATH TO openocd.exe",
"cortex-debug.gdbPath": "arm-none-eabi-gdb"

launch.json

As above, replace the “PATH TO X” with the actual path to X. And the location of the elf file to the actual path of the ELF file.

{
    // 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": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceRoot}",
            "executable": "${workspaceRoot}/LOCATION OF ELF",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "openocd",
            "device": "Pico2040",
            "runToMain": true,
            "configFiles": ["interface/picoprobe.cfg", "target/rp2040.cfg"],
            "searchDir": ["PATH TO tcl folder"],
            "svdFile": "PATH TO rp2040.svd",
        }
    ]
}

Leave a comment

Your email address will not be published. Required fields are marked *