Hi! This is my first post here, so please forgive me if I did something wrong or missed a rule somewhere!
I am trying to configure PlatformIO to be able to debug a Raspberry Pi Pico. I used pico-debug to be able to use the CMSIS-DAP debug interface with my Pico, and am able to connect using openocd and gdb-multiarch, using the command openocd -f interface/cmsis-dap.cfg -c "transport select swd" -c "adapter speed 4000" -f target/rp2040-core0.cfg,
but when I attempt to debug with PlatformIO, I am faced with an error:
Reading symbols from /home/neilbaner/Documents/PlatformIO/Projects/pico-demo/.pio/build/pico/firmware.elf...
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target...
Open On-Chip Debugger 0.11.0+dev-gec0240e6a-dirty (2021-03-09-09:49)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : tcl server disabled
Info : telnet server disabled
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Serial# = E6605838830B8B34
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Error: CMSIS-DAP command CMD_DAP_SWJ_CLOCK failed.
.pioinit:13: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.
I have tried this using VS Code on both Windows 10 and Linux (Mint); both throw the same error. I thought this may be to do with the debug clock speed being set incorrectly, so I tried setting debug_speed to various values: 4000 (because thatâs what was in the command I used), 133000 (clock speed of the Pico), 4 (just in case) - none of these worked.
Edited to add: Here are the contents of my platformio.ini file:
Btw, I have debugging working via a Picoprobe (aka another Pico loaded with a CMSIS-DAP firmware provided by the Raspberry Pi foundation), and it can debug the Arduino-mbed core just fine. Even sees both Cortex-M0+ cores.
I tried hard to make your example work on a Windows10 OS with the latest PlatfomIO installed. I have two Picos wired together, one working as picoprobe and with USB driver changed.
Finally I more or less copy-pasted your .ini file, everything got updated and recompiled without a problem. But finally I canât upload, I always get this error:
Open On-Chip Debugger 0.10.0+dev-g18b4c35 (2021-07-16-01:02)
Licensed under GNU GPL v2
For bug reports, read OpenOCD: Bug Reporting
debug_level: 1
Warn : Transport âswdâ was already selected
adapter speed: 5000 kHz
*** [upload] Error 5
Any ideas? I could connect with openocd on comandline level, maybe itâs a configuration issue?
Thanks!
toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder â Library Dependency Finder (LDF) â PlatformIO latest documentation
LDF Modes: Finder ~ chain, Compatibility ~ soft
Framework incompatible library C:\Users\Christoph.platformio\packages\framework-arduino-mbed@2.4.1\libraries\LittleVGL
Framework incompatible library C:\Users\Christoph.platformio\packages\framework-arduino-mbed@2.4.1\libraries\Portenta_SDCARD
Found 30 compatible libraries
More details about âLibrary Compatibility Modeâ: Redirecting...
Scanning dependenciesâŚ
No dependencies
Building in release mode
([âcheckprogsizeâ], [â.pio\build\pico_standard\firmware.elfâ])
Flash size: 2.00MB
Sketch size: 2.00MB
Filesystem size: 0.00MB
Maximium size: 2093056 Flash Length: 2093056 EEPROM Start: 270528512 Filesystem start 270528512 Filesystem end 270528512
MethodWrapper([âcheckprogsizeâ], [â.pio\build\pico_standard\firmware.elfâ])
Advanced Memory Usage is available via âPlatformIO Home > Project Inspectâ
RAM: [== ] 18.6% (used 50240 bytes from 270336 bytes)
Flash: [ ] 3.5% (used 72664 bytes from 2093056 bytes)
.pio\build\pico_standard\firmware.elf :
section size addr
.boot2 256 268435456
.text 52400 268435712
.rodata 8884 268488112
.ARM.exidx 8 268496996
.ram_vector_table 192 536870912
.data 11372 536871104
.uninitialized_ram.magic_location 12 536882476
.uninitialized_data 0 536882488
.scratch_x 0 537133056
.scratch_y 0 537137152
.bss 38868 536882488
.heap 210676 536921356
.ARM.attributes 40 0
.comment 132 0
.debug_frame 5284 0
.stab 60 0
.stabstr 118 0
Total 328302
([âuploadâ], [â.pio\build\pico_standard\firmware.binâ])
AVAILABLE: cmsis-dap, jlink, picoprobe, picotool, raspberrypi-swd
CURRENT: upload_protocol = picoprobe
openocd -d2 -s C:\Users\Christoph.platformio\packages\tool-openocd-raspberrypi/share/openocd/scripts -f interface/picoprobe.cfg -f target/rp2040.cfg -c âprogram {.pio\build\pico_standard\firmware.bin} 0x10000000 verify reset; shutdown;â
Open On-Chip Debugger 0.10.0+dev-g18b4c35 (2021-07-16-01:02)
Licensed under GNU GPL v2
For bug reports, read OpenOCD: Bug Reporting
debug_level: 2
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
*** [upload] Error 5
===================================================== [FAILED] Took 3.37 seconds =====================================================
Environment Status Duration
pico_earlephilhower IGNORED
pico_earlephilhower_picoprobe_debugging IGNORED
pico_standard FAILED 00:00:03.370
================================================ 1 failed, 0 succeeded in 00:00:03.370 ================================================The terminal process âC:\Users\Christoph.platformio\penv\Scripts\platformio.exe ârunâ, ââverboseâ, ââtargetâ, âuploadâ, ââenvironmentâ, âpico_standardââ terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Any help/explanation welcome. I am an old-school electronic engineer, but I am new to PlatformIO, so I still have to get used to understand the underlying mecanisms and workflow (and of course the âhiddenâ options). Thanks a lot.
Hi Max, I have also managed to get this debugging on the earlephilhower using Picoprobe using your advice in this thread. However, using this core, the debug only seems to work when using Arduino libraries, but when I use the pico sdk libraries such as pico/stdlib.h, it is not debugging correctly. Is this what you have found as well or there something that will make this work? Thanks, Tom
As expected since both the Arduino-mbed core and earlephilhower/arduino-pico use the Pico SDK in a precompiled library form (see libpico.a), so stepping inside Pico SDK functions in source code form wonât work.
Thanks Max, that makes sense. Is there currently any method to fully debug the philhower core using the Pico SDK and Arduino libraries? If not, is this something that will likely be included once it becomes supported in PlatformIO?
PlatformIO follows what the Arduino core do regarding the compilation of their core. Since the Arduino cores use pre-compiled libraries, so does PlatformIO, otherwise we canât necessarily garuantee the same result. So for framework = arduino this will wonât be included since thatâs how the cores work.
The SDK sources are still there however, so with some tweaks (adding source paths) it might be possible to step into the code and have it display in the source code, but since it isnât compiled from source and this optimized precompiled library is used, the debugging experience wonât be good (lots of optimized-away variables, etc.)