Debug rp2040 Raspberry pi pico

Hello, i have an picoprobe debug setup, guess done properly?
Openocd and gdb seem to work properly, i want to debug my platformio project.

Using this wiring

Running: openocd.exe -s tcl -f interface/picoprobe.cfg -f target/rp2040.cfg

Open On-Chip Debugger 0.10.0+dev-g14c0d0d-dirty (2021-01-27-15:43)
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

I can upload binary files via GDB:

.\arm-none-eabi-gdb.exe D:\the\path\to\project\.pio\build\pico\firmware.elf
target remote localhost:3333
load

But “Upload and monitor” goes:

Linking .pio\build\pico\firmware.elf
Generating UF2 image
elf2uf2 ".pio\build\pico\firmware.elf" ".pio\build\pico\firmware.uf2"
Checking size .pio\build\pico\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.1% (used 40696 bytes from 270336 bytes)
Flash: [          ]   0.2% (used 4034 bytes from 2097152 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, picotool, raspberrypi-swd
CURRENT: upload_protocol = picotool
Looking for upload port...
Auto-detected: COM8
Forcing reset using 1200bps open/close on port COM8
Uploading .pio\build\pico\firmware.elf
rp2040load 1.0.1 - compiled with go1.15.8
.....................
*** [upload] Error 1

And platformio.ini is as follows:

[env:pico]
platform = raspberrypi
board = pico
framework = arduino
upload_protocol = picotool
debug_tool = custom
debug_server = D:\some\path\openocd_picoprobe\openocd.exe -s tcl -f interface/picoprobe.cfg -f target/rp2040.cfg

Thank you very much, debugging my projects might be a BIG breaktrough.

Regards.

Either it’s attempting to reset the wrong COM port back into bootloader mode or you haven’t used Zadig to load libusb-win32 drivers per this.

Either case, the stock platform = raspberrypi does not support Picoprobe out of the box, but you seem to have already found that out since you’re using debug_tool = custom. On the other hand, I’ve expanded the platform code to properly work with picotool a long time ago in this PR.

Which means you can give this platformio.ini a try, eliminating the need for custom debug servers…

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
upload_protocol = picoprobe
debug_tool = picoprobe

TL-DR → GREAT :tada::confetti_ball::fireworks::sparkler:

Using platformio pre-release version v2.99.0, hope this will be merged ASAP❤.

Some hardware serial UART rendres breakpoints unusable, like:
UART Serial2(0, 1 -1, -1);

Pico running code usb shall not be connected, debugging renders it unusable… well, found out, i can use , and a ttl-serial-usb adapter to archieve serial monitoring.

UART Serial2(p16, p17);

Some breakpoints sets debugging GUI in a weird/bugged status, but a pause+play gets all back, no problem.

Some [warning || info ] tell user to use `Run and Debug’ panel might be great, confusing at first glance.

Lots of warinings on debug console , the 1st one might be important ‘cache dir’

Tool undefined
C:\Users\myUser\.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
Reading symbols from c:\Users\myUser\Documents\PlatformIO\Projects\testpicoDisplay\.pio\build\pico\firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = picoprobe
PlatformIO: Initializing remote target...
Open On-Chip Debugger 0.11.0-g610f137 (2022-02-11-13:57)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
adapter speed: 5000 kHz

Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
adapter speed: 1000 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : clock speed 1000 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 pipe
Info : accepting 'gdb' connection from pipe
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x21000000 pc: 0x10006a90 psp: 0x20008a18
Info : RP2040 B0 Flash Probe: 2097152 bytes @10000000, in 512 sectors

Info : New GDB Connection: 1, Target rp2040.core0, state: halted
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1049 ms). Workaround: increase "set remotetimeout" in GDB
0x10006a90 in USBDevice::read_start(unsigned char, unsigned char*, unsigned long) ()
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1013 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
Loading section .boot2, size 0x100 lma 0x10000000
Loading section .text, size 0x7de lma 0x10000100
Loading section .text.frame_dummy, size 0x20 lma 0x100008e0
Loading section .text.setup, size 0x6c lma 0x10000900
Loading section .text.loop, size 0x64 lma 0x1000096c
Loading section .text._ZN7arduino11RingBufferNILi256EE5clearEv, size 0x12 lma 0x100009d0
---too long
Loading section .text.__ascii_wctomb, size 0x1a lma 0x1000faa4
Loading section .text._getpid, size 0x10 lma 0x1000fac0
Loading section .text._kill, size 0x10 lma 0x1000fad0
Loading section .rodata, size 0xc0 lma 0x1000fae0
Loading section .rodata.setup.str1.4, size 0x5 lma 0x1000fba0
Loading section .rodata._Z41__static_initialization_and_destruction_0ii.str1.4, size 0xa lma 0x1000fba8
Loading section .rodata._ZL11magic_token, size 0xc lma 0x1000fbb4
Loading section .rodata._ZZN4mbed8CallbackIFvvEE8generateIZNS2_C4IPN7arduino4UARTEMS6_FvvELi0EEET_T0_EUlvE_vEEvOSA_E3ops, size 0xc lma 0x1000fbc0
Loading section .rodata._ZTVN7arduino4UARTE, size 0x34 lma 0x1000fbcc
---too long
Loading section .rodata.p05.6127, size 0xc lma 0x10011f20
Loading section .rodata._svfprintf_r.str1.1, size 0x11 lma 0x10011f2c
Loading section .ARM.exidx, size 0x8 lma 0x10011f40
Loading section .data, size 0x720 lma 0x10011f48
Loading section .uninitialized_ram.magic_location, size 0xc lma 0x10012668
Info : Padding image section 0 at 0x100008de with 2 bytes
---too long
Info : Padding image section 85 at 0x10011f3d with 3 bytes
Info : Writing 75380 bytes starting at 0x0
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1015 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1011 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1012 ms). Workaround: increase "set remotetimeout" in GDB
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1005 ms). Workaround: increase "set remotetimeout" in GDB
Start address 0x100001d4, load size 75198
Transfer rate: 5 KB/sec, 75 bytes/write.
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
Temporary breakpoint 1 at 0x10002bae: file C:\Users\myUser\.platformio\packages\framework-arduino-mbed\cores\arduino\main.cpp, line 36.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000178 msp: 0x20041f00

Thread 1 hit Temporary breakpoint 1, main () at C:\Users\myUser\.platformio\packages\framework-arduino-mbed\cores\arduino\main.cpp:36