Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7995

General • read flash to file via SWD

$
0
0
Dear reader,
I'll have here two "Raspberry Pi Pico W", one defective (no USB, not even with BOOTSEL pressed when plugged in) and one fully functional, both running circuitpython with sht45 sensor (both reachable via WLAN).

Because I wanted to copy the image with corrected code.py from the functional to the defective, I've tried to get the content of the flash via SWD. Therefore I used my Raspberry Pi 3 Model B+ (running Raspberry Pi OS - Bookworm). The (functional) PICO is plugged in USB to the Pi 3 and SWCLK/GND/SWDIO as documented in "Getting started ... .pdf" (Version 2024-05-02) with 15cm Dupont cables.

openocd log:

Code:

$ openocd -f /usr/share/openocd/scripts/interface/raspberrypi-swd.cfg -f /usr/share/openocd/scripts/target/rp2040.cfgOpen On-Chip Debugger 0.12.0+dev (2026-01-24-12:00)Licensed under GNU GPL v2For bug reports, read        http://openocd.org/doc/doxygen/bugs.htmlWarn : TMS/SWDIO moved to GPIO 8 (pin 24). Check the wiring please!adapter speed: 5000 kHzInfo : [rp2040.core0] Hardware thread awareness createdInfo : [rp2040.core1] Hardware thread awareness createdInfo : Listening on port 6666 for tcl connectionsInfo : Listening on port 4444 for telnet connectionsInfo : BCM2835 GPIO JTAG/SWD bitbang driverInfo : clock speed 5000 kHzInfo : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001Info : SWD DPIDR 0x0bc12477, DLPIDR 0x10000001Info : [rp2040.core0] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core0] target has 4 breakpoints, 2 watchpointsInfo : [rp2040.core0] Examination succeedInfo : [rp2040.core1] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core1] target has 4 breakpoints, 2 watchpointsInfo : [rp2040.core1] Examination succeedInfo : [rp2040.core0] starting gdb server on 3333Info : Listening on port 3333 for gdb connectionsInfo : [rp2040.core1] Hardware thread awareness createdInfo : Listening on port 6666 for tcl connectionsInfo : Listening on port 4444 for telnet connectionsInfo : BCM2835 GPIO JTAG/SWD bitbang driverInfo : clock speed 5000 kHzInfo : SWD DPIDR 0x0bc12477, DLPIDR 0x00000001Info : SWD DPIDR 0x0bc12477, DLPIDR 0x10000001Info : [rp2040.core0] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core0] target has 4 breakpoints, 2 watchpointsInfo : [rp2040.core0] Examination succeedInfo : [rp2040.core1] Cortex-M0+ r0p1 processor detectedInfo : [rp2040.core1] target has 4 breakpoints, 2 watchpointsInfo : [rp2040.core1] Examination succeedInfo : [rp2040.core0] starting gdb server on 3333Info : Listening on port 3333 for gdb connectionsInfo : accepting 'telnet' connection on tcp/4444[rp2040.core0] halted due to debug-request, current mode: ThreadxPSR: 0x61000000 pc: 0x1002a2ce msp: 0x20040db0[rp2040.core1] halted due to debug-request, current mode: ThreadxPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00Info : RP2040 rev 2, QSPI Flash win w25q16jv id = 0x1540ef size = 2048 KiB in 512 sectors
telnet session:

Code:

$ telnet localhost 4444Trying ::1...Connection failed: Verbindungsaufbau abgelehntTrying 127.0.0.1...Connected to localhost.Escape character is '^]'.Open On-Chip Debugger> halt[rp2040.core0] halted due to debug-request, current mode: ThreadxPSR: 0x61000000 pc: 0x1002a2ce msp: 0x20040db0[rp2040.core1] halted due to debug-request, current mode: ThreadxPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00> flash read_bank rp2040.flash picow.flashRP2040 rev 2, QSPI Flash win w25q16jv id = 0x1540ef size = 2048 KiB in 512 sectorswrote 2097152 bytes to file picow.flash from flash bank 0 at offset 0x00000000 in 8.698780s (235.435 KiB/s)>
but picow.flash is almost completely zero:

Code:

$ xz -9 -c picow.flash | wc -c620
... but circuitpython (v10.0.3) is surely larger than this.

What I'm doing wrong here?

Reading SRAM (via gdb) or ROM (via gdb) contains reasonable data. Also tried getting flash via gdb yesterday (no log, sorry), but what I've got from gdb looked very similar. And because I've thought "why use gdb when openocd can do it on it's own", today I've tried it with openocd.

Tried "adapter speed 1000", too — didn't help.

Statistics: Posted by kopfsalat — Sun Jan 25, 2026 9:38 pm



Viewing all articles
Browse latest Browse all 7995

Trending Articles