August 11, 2022

Raspberry Pi Pico - OpenOCD and the Pico Probe

I now have one of my Pico units flashed with the PicoProbe firmware. I plug it in and see:
Aug 11 12:29:04 trona kernel: usb 1-1: new full-speed USB device number 4 using xhci_hcd
Aug 11 12:29:04 trona kernel: usb 1-1: New USB device found, idVendor=2e8a, idProduct=000c, bcdDevice= 1.01
Aug 11 12:29:04 trona kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Aug 11 12:29:04 trona kernel: usb 1-1: Product: Picoprobe (CMSIS-DAP)
Aug 11 12:29:04 trona kernel: usb 1-1: Manufacturer: Raspberry Pi
Aug 11 12:29:04 trona kernel: usb 1-1: SerialNumber: E6616407E36C3227
Aug 11 12:29:04 trona kernel: cdc_acm 1-1:1.1: ttyACM0: USB ACM device
It is presenting itself as a USB to serial device. Can we use it simultaneously with openOCD?

My Fedora 38 system tells me that I have:

Open On-Chip Debugger 0.12.0
I have read that 0.11.0 did not support the Pico, maybe "12" does?
I look at the directory:
/usr/share/openocd/scripts/interface

Nothing jumps out at me as being a interface config file for the picoprobe.

My notes on the Blue Pill

To get myself back up to speed, I recall that I used OpenOCD (along with GDB) with the STM32F103 in years gone by (back in 2016!).

Use cmsis-dap

Apparenly at one time, the picoprobe was unique and used a specific file of its own -- picoprobe.cfg. But the latest version(s) of the picoprobe firmware acts like a CMSIS-DAP debugger (whatever that is) and don't need the special driver. Use:
openocd -f /usr/share/openocd/scripts/interface/cmsis-dap.cfg -f /usr/share/openocd/scripts/target/rp2040.cfg

Or perhaps better, use this:

openocd -f /usr/share/openocd/scripts/board/pico-debug.cfg

As a side note, when I look at the "target" directory, I see two files:

rp2040.cfg
rp2040-core0.cfg
Without the probe connected to a target, it just gives up. But with it properly connected to a target, we get:
Open On-Chip Debugger 0.12.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Warn : An adapter speed is not selected in the init scripts. OpenOCD will try to run the adapter at the low speed (100 kHz)
Warn : To remove this warnings and achieve reasonable communication speed with the target, set "adapter speed" or "jtag_rclk" in the init scripts.
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=E6616407E36C3227
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: Test domain timer supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 100 kHz
Info : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001
Info : SWD DPIDR 0x0bc12477, DLPIDR 0x10000001
Info : [rp2040.core0] Cortex-M0+ r0p1 processor detected
Info : [rp2040.core0] target has 4 breakpoints, 2 watchpoints
Info : [rp2040.core1] Cortex-M0+ r0p1 processor detected
Info : [rp2040.core1] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core0 on 3333
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for rp2040.core1 on 3334
Info : Listening on port 3334 for gdb connections
We always get these lame warnings about the adapter speed. I used to always see those with the blue pill. I wonder why somebody doesn't either put this in the config files or make this "normal" and not bother with the warning. I'll take that back (at least in part). You can use the following command line:
openocd -f interface/cmsis-dap.cfg -c "adapter speed 5000" -f target/rp2040.cfg -s tcl
This works fine and sets the speed to 5000 Khz, which can only be a good thing. Note also that full paths are not needed. It seems to "know" that everything starts at /usr/share/openocd/scripts which certainly saves some typing.


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org