Guides

The RPi page on how to do it is here.

The guide is in “Appendix A: Using Picoprobe” of the Pico Getting Started Guide.

Installing OpenOCD and Picoprobe on Windows

You can follow the guide, or you can use the pico-setup-windows tool kindly created by ndabas below which offers an automatic way to do it. If this is how you installed your deve environment then picotools will be there (look in “C:\Users\ibexdev\Documents\Pico\tools\openocd-picoprobe\”)

Installing the USB driver

It looks like the ndabas tool doesn’t do this step. Follow the “Install Picoprobe driver (only needed on Windows)” steps in the Pico Getting Started Guide (download zadig and select the correct driver to install).

In the main “ReadMe.txt” you’ll see:

Using Picoprobe

Hardware Connections
PICO AS PICOPROBE       Target Pico

Required pins:
3 (any GND) GND
4 SWCLK
5 SWDIO

Optional pins if you want to access UART serial:
6 UART0RX (Pico pin 2)
7 UART0TX (Pico pin 1)

Testing Connection

Ensure your RP2040 is powered, and running (does not have RUN held low).

Run the “Developer Command Prompt for Pico” shortcut created by the ndabas install tool.

Then use command: openocd -f interface/picoprobe.cfg -f target/rp2040.cfg

If all is well you will see something like this:

C:\Users\ibexdev\Documents\Pico>openocd -f interface/picoprobe.cfg -f target/rp2040.cfg
Open On-Chip Debugger 0.10.0+dev-geb22ace-dirty (2021-02-23-23:12)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
Warn : Transport "swd" was already selected
adapter speed: 5000 kHz

Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 5000 kHz
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x10000001
Info : rp2040.core0: hardware has 4 breakpoints, 2 watchpoints
Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core0 on 3333
Info : Listening on port 3333 for gdb connections

Setting Visual Studio Code to use picoprobe

Menu > File > Preferences > Settings
Extensions > Cortex Debug Configuration. Trying to change anything will open the json file
Add the entries for “cortex-debug.gdbPath” and “cortex-debug.openocdPath” (Adjust path to match your install) (Check you have the commas correct after each entry)

{
    "workbench.colorTheme": "Default Light+",
    "editor.insertSpaces": false,
    "editor.comments.insertSpace": false,
	"editor.detectIndentation": false,
	"cmake.configureOnOpen": true,

	"cortex-debug.gdbPath": "arm-none-eabi-gdb",
	"cortex-debug.openocdPath": "C:/Users/YOURUSERNAME/Documents/Pico/tools/openocd-picoprobe/openocd.exe"
}

Edit Launch.json for your project

Try CTRL+SHIFT_P to open the Command Palette and type “Open launch.json”. If that doesn’t work then Visual Studio Code likely hasn’t created a launch.json file for your project yet, so do the following: Menu > Run > Add Configuration, which will open a new launch.json file.

You want something like this, with the “configFiles”, “searchDir” and “svdFile” being important:

{
	// 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}/build/YOUR-PROJECT-NAME.elf",
			"request": "launch",
			"type": "cortex-debug",
			"servertype": "openocd",
			"device": "Pico2040",
			"configFiles": [
				"interface/picoprobe.cfg",
				"target/rp2040.cfg"
			],
			"searchDir": ["C:/Users/YOURUSERNAME/Documents/Pico/tools/openocd-picoprobe/scripts"],
			"svdFile": "C:/Users/YOURUSERNAME/Documents/Pico/pico-sdk/src/rp2040/hardware_regs/rp2040.svd"
		}
	]
}

Save the .json files

Debugging Your Project

From the left menu bar select “Run and Debug”.

Click on the green arrow next to Cortex Debug. gdb and openocd will deploy your most recently built code to the Pico and run.

The debugger control options appear as a centre mini toolbar. To close the debugger click the dropdown arrow > More > Disconnect.

Coming back to a project and debugging this way – a mental refresher on how it all works!

  1. Open project
  2. Build it (Small “Build” button on bottom toolbar)
  3. Press “Run and Debug” button on side toolbar
  4. Click on the green arrow next to Cortex Debug. gdb selected in dropdown.
  5. Select “Debug Console” tab of the bottom output window (can also be selected using 3 dots button next to next to Cortex Debug. gdb selected in dropdown). This will show you the state of the debugger.
If it doesn’t work properly
  • Look in Terminal tab of bottom output window, see if there is an error showing for it here (this is where you’ll discover if it can’t find the picoprobe device for instance).
  • Reset the RP2040 (Pull its RUN pin to 0V
  • Pull the USB to the picopobe and re-connect. Then reset RP2040 (RUN to 0V).
  • Check your connections between the picoprobe and the PCB are right.

These usually solve it and then it just magically works again!

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

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