OpenOCD/RPi Debug Probe Setup

I’m trying to help with the BP debugging. I hooked up a RPi Debug Probe to the 3-hole on the bottom. I’m following the directions the RPi site

Here are some tips

  • Use the right plug on the RPi Debug Probe - the one that says JTAG - See picture

  • Starting from the, edge,the color of the wires are Red, Yellow, Black (SWCLK, SWDIO,GND)

  • Plugging in the male connectors from the probe didn’t seem to fit well. I cut a female header down to 3 wires and used that in-between.

  • I had gdb installed. I also installed the multi-archtecture version using "
    sudo apt install gdb-multiarch

  • I installed openocd from github but the standard package might work

  • I started openocd using "
    sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000"

  • instead of using “cmake …” I used
    "cmake -DCMAKE_BUILD_TYPE=Debug ..

  • I copied the new firmware onto the BP

  • I started the debugger using

$ gdb-multiarch bus_pirate5_rev10.elf
target remote localhost:3333
monitor reset init
continue

Let’s see how this goes

7 Likes

Great contribution, thanks for sharing.

How do you like the debug probe? I got one, but haven’t figured out an adapter for the pins yet to fit my BP5. I have 3P milled pins that I solder to a little PCB breakout I use for debugging with a PICO.

The DuPont crimps on their cable are probably the cheapest stuff I’ve ever seen. My jaw dropped a little.

TBH, this is the first time I used it. For the adapter, I used a piece of female header. It worked.
PXL_20240409_131252097

But I also had some milled male headers, and made an adapter as well
PXL_20240409_125638914

1 Like

The second one is where I plan to end up :slight_smile:

Really appreciate this post!

Once this is setup for cmd-line connection…

gdb-multiarch bus_pirate5_rev10.elf      \
    --ex "target remote localhost:3333"  \
    --ex "monitor reset init"            \
    --ex "continue"

I’m getting closer. I can get VSCode to build, upload, and appear to be debugging by adding the following contents as file ./.vscode/launch.json:

click to expand

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "BP5_Rev10",
			"type": "cppdbg",
			"request": "launch",
			"cwd": "${workspaceFolder}",
			"program": "${workspaceRoot}/build/bus_pirate5_rev10.elf",
			"MIMode": "gdb",
			"miDebuggerPath": "gdb-multiarch",
			"miDebuggerServerAddress": "localhost:3333",
			"useExtendedRemote": false,
			"postRemoteConnectCommands": [
                //{"text": "target remote localhost:3333"},
				{"text": "monitor reset init"},
				{"text": "load"}
			]
		}
	]
}


The first time I run this, setting breakpoints in VSCode does not appear to do anything. I can break in after the fact, but … that’s not much use when I want to trace what’s happening within a function.

Except for the first time (even after restarting openOCD), attempts to debug just complains with:

ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". During startup program exited with code 126.
The program './bp5/build/bus_pirate5_rev10.elf' has exited with code 0 (0x00000000).

Anyone else using this type of setup? If so, any ideas why the breakpoints are not being set?

Just a guess, is the PICO probe firmware up to date? They made some changes at one point and when I upgraded the VSCODE side I had to update the probe firmware too.

At the moment I have a zombie setup where I have to manually change stuff in the config because the vscode pico extension kind of messed up my whole toolchain.

1 Like

Yes, it’s v2.0.1 (the latest release).

I’ve also been using the wrong term… I’m using the official debugprobe hardware (not a pico setup as a debug probe), because the debugprobe kit was the cheapest way (at the time) to get the RP2040 debug cables. :laughing:

Bummer. Still going to try to find a way to get this working.
OpenOCD server is working, and cmd-line I can break in, but doesn’t seem to have initial breakpoints working.

If I can’t figure this out, my ability to put together the more complex improvements will be severely impaired.

2 Likes