Debugging the Pico

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 *