Porting Pico Debug Probe

Today I’m porting the official RPi Pico Debug probe to the Bus Pirate. There is another more advanced version I will do later, but I’ve ported this one before and it has less features to worry about.

It’s been updated to the new pirate-lib, but I’m having some trouble compiling. It seems to be trying to store some const variables in ram. Specifically the background image I suspect.

[build] Memory region         Used Size  Region Size  %age Used
[build]            FLASH:       60436 B         2 MB      2.88%
[build]              RAM:      150748 B       256 KB     57.51%
[build]        SCRATCH_X:          2 KB         4 KB     50.00%
[build]        SCRATCH_Y:          0 GB         4 KB      0.00%

When I disable the function that draws the background on the LCD.

[build]            FLASH:      220652 B         2 MB     10.52%
[build]              RAM:      310972 B       256 KB    118.63%
[build]        SCRATCH_X:          2 KB         4 KB     50.00%
[build]        SCRATCH_Y:          0 GB         4 KB      0.00%

When the function is enabled there’s not enough ram.

This uses TinyOS, so maybe that has something to do with it? Anyone familiar with this kind of setup? Here is the repo.

1 Like
pico_set_binary_type(picoprobe copy_to_ram)

it’s this in cmakelists… what are the consequences of disabling it. Let’s find out :slight_smile:

Looks like its going. It enumerates as a pico debug probe. I’ll test it a bit.

picoprobe.zip (57.1 KB)

NOTE: currently you must connect VIN/VOUT/VREF to the target power supply to power the buffers at whatever voltage the target is using.

Since 3.3volt directly powered debug is the norm for RP2xxx, I’ll make a second version with power enabled by default.

The odd arrangement of the SWDIO and SWCLK pins is due to the use of side set in the PIO program.

Todo:

  • test with a target
  • 3.3volt power enabled
2 Likes

debugprobe.zip (55.6 KB)

Yeah! This version does connect to OpenOCD. I will actually try it tomorrow, it has been a long day.

2 Likes

Not that this would change this firmware, but for future BP designs…

Does this mean that the pins used will change, depending on the model of the buspirate, because PIO can only side-set consecutive pins, and the BP’s eight outputs are not necessarily consecutive? (e.g., BP5 will use IO0/IO7 as shown above, BP6 might use IO2/IO3, BP5XL might use IO1/IO6?) Inquiring minds want to know…

2 Likes

All the board versions use the same. 0 to 7 for buffer direction and 8 to 15 for IO.

The very first revision did every other pin, but that makes the side set thing even more problematic:

In the PIO some pins can be set at the same time as the main pins. So for example data is main pin, and side set is clock, which enables two clock tick IO.

When there are multiple side set pins (imagine clock plus cs and reset for example) that control IO, then we would use twice as many side set pins because we have to skip every other pin which is a control pin. There are only five bits I think and side set eats into the delay bits as well.

Then we think about in pins. For example the 8 pins into the logic analyzer. You can’t skip any, so we have to read in 16 bits and than remove the invalid data.

After experimenting it was pretty clear that banks of 8 consecutive pins was the best compromise. The PIO is cool, but not to be confused with a FPGA or CPLD, it is extremely constrained in many ways.

In the case of the pico probe, there is existing code to use a bidirectional buffer that seems to have been an internal dev tool. The main pin is data, the side set pins are data-buffer-direction and clock. So, data needs to be a io pin, and side set needs to control a direction pin and clock a consecutive Io pin.

So the only possible pin assignment is:

Gpio 7 (io7 direction) swdio buffer direction
Gpio 8 (io1 Io) swclk output
GPIO 15 (io7 io) swdio output input

This program is an oddity, none of our other pio stuff has quirks like this. Most of the RPi teams PIO programs are a bit cringe. They designed it and do really clever stuff, but its often very ridigly suited to a specific use case.

3 Likes

debugprobe.zip (59.3 KB)

It is detected as a pico probe and can connect to devices/upload/debug :partying_face:

A 3.3volt power supply is enabled by default. To disable the supply, press and hold the button at startup and bring your own power supply via the Vin pin.

The firmware name is now displayed at the top.

Limitations:

  • This is picoprobe v2.0.1. It is that latest version that doesn’t require SDK2.0. It will not run on RP2350 yet. I will mess with multiple SDKs when I setup the build system.
4 Likes