raspberrypi/openocd

Unable to upload elf file - picoprobe - rp2040

ghubcoder opened this issue ยท 3 comments

Hello,

I'm following the guides here and here (second one has more wires ๐Ÿ™‚ ). This wasn't working via vscode however so I'm using the following from the cli:

openocd -f interface/picoprobe.cfg -f target/rp2040.cfg

I then connect via gdb and try to load an elf file:

arm-none-eabi-gdb sleep.elf
Type "apropos word" to search for commands related to "word"...
Reading symbols from sleep.elf...
(No debugging symbols found in sleep.elf)
(gdb) target extended-remote localhost:3333
Remote debugging using localhost:3333
0x000000ee in ?? ()
(gdb) load
Error erasing flash with vFlashErase packet

From the openocd side I see:

Open On-Chip Debugger 0.11.0-g4f2ae6197 (2021-11-06-08:17)
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
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
Info : accepting 'gdb' connection on tcp/3333
Info : RP2040 B0 Flash Probe: 2097152 bytes @10000000, in 512 sectors

Info : New GDB Connection: 1, Target rp2040.core0, state: halted
undefined debug reason 8 - target needs reset
Warn : Prefer GDB command "target extended-remote 3333" instead of "target remote 3333"
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
Error: SWD Read data parity mismatch
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Error: Failed to read memory at 0x0000007c
Error: Debug trampoline not found in RP2040 ROM.
Error: RP2040 exit xip: failed to connect internal flash
Error: failed erasing sectors 0 to 2
Error: flash_erase returned -4
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : New GDB Connection: 1, Target rp2040.core0, state: halted
Error: SWD Read data parity mismatch
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
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
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Error: Failed to read memory at 0x0000007c
Error: Debug trampoline not found in RP2040 ROM.
Error: RP2040 exit xip: failed to connect internal flash
Error: failed erasing sectors 0 to 2
Error: flash_erase returned -4
Info : SWD DPIDR 0x0bc12477

This does seem to have actually worked at some point however as I can see the target pico device is running my simple program to switch on the led (after having the flash wiped).

Any idea what I'm doing wrong?

This is how it looks when running with debugging:

Debug: 1270 7114 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
Debug: 1271 7114 target.c:2613 target_read_u16(): address: 0x0000007a, value: 0xd9b0
Debug: 1272 7114 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
Debug: 1273 7114 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
Debug: 1274 7114 picoprobe.c:453 picoprobe_swd_switch_seq(): DORMANT-to-SWD
Info : 1275 7115 adi_v5_swd.c:269 swd_multidrop_connect(): SWD DPIDR 0x0bc12477
Info : 1276 7115 adi_v5_swd.c:270 swd_multidrop_connect(): SWD DLPIDR 0x00000001
Debug: 1277 7115 arm_adi_v5.c:653 dap_dp_init(): rp2040.core0.dap
Debug: 1278 7115 arm_adi_v5.c:685 dap_dp_init(): DAP: wait CDBGPWRUPACK
Debug: 1279 7115 arm_adi_v5.h:512 dap_dp_poll_register(): DAP: poll 4, mask 0x20000000, value 0x20000000
Debug: 1280 7115 arm_adi_v5.c:693 dap_dp_init(): DAP: wait CSYSPWRUPACK
Debug: 1281 7115 arm_adi_v5.h:512 dap_dp_poll_register(): DAP: poll 4, mask 0x80000000, value 0x80000000
Debug: 1282 7116 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
Error: 1283 7116 arm_adi_v5.c:544 mem_ap_read(): Failed to read memory at 0x0000007c
Debug: 1284 7116 target.c:2617 target_read_u16(): address: 0x0000007e failed
Error: 1285 7116 rp2040.c:90 rp2040_call_rom_func(): Debug trampoline end not found in RP2040 ROM.
Error: 1286 7116 rp2040.c:176 rp2040_flash_exit_xip(): RP2040 exit xip: failed to exit flash XIP mode
Error: 1287 7116 core.c:47 flash_driver_erase(): failed erasing sectors 0 to 5
Debug: 1288 7116 target.c:1827 target_call_event_callbacks(): target event 25 (gdb-flash-erase-end) for core rp2040.core0
Error: 1289 7116 gdb_server.c:3075 gdb_v_packet(): flash_erase returned -4
Debug: 1290 7216 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
Debug: 1291 7216 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
Debug: 1292 7216 picoprobe.c:364 picoprobe_swd_queue_cmd(): Add 8 idle cycles
lurch commented

I managed to get this working by having both pico's powered by separate usb cables.

The swd ground pin on the target pico was then connected directly to a ground pin on the picoprobe pico....

It also works as per the guides by powering the second pico from the first, but having the ground swd pin from the target pico connected directly back to a ground pin on the picoprobe.

Apologies for the noise!

lurch commented

Yes, it's always important to have a common ground shared by all the parts of your circuit. Glad to hear that you managed to solve your problem ๐Ÿ‘