Skip to content

Flashing binary via debugprobe randomly fails with recently added FreeRTOS SMP config #189

@jan-krieg

Description

@jan-krieg

Using a Raspberry Pi Pico 2 as debugprobe with firmware built from current master repo, I get seemingly random failures when flashing an ELF binary to the target (Pico 2W) via OpenOCD.

Sometimes flashing works fine, but sometimes OpenOCD hangs for a while until it eventually fails and I have to re-plug the USB cable to fully resolve it. In some cases the old binary on the target Pico is then still intact, sometimes it's corrupted, presumably based on whether the failure occurs before or during the write to flash. The bug occurs both when flashing directly via OpenOCD and indirectly from GDB.

Bisecting this problem, it seems to be caused by 457e048: with latest stable release 2.2.3 of debugprobe I don't observe the problem, while cherry-picking that commit on top of 2.2.3 makes the problem appear.

As a side note: debugging via GDB & OpenOCD seems to always work fine based on brief checks, I'm only observing issues with flashing.

Hardware:

  • x86-64 Linux Desktop
  • Pico 2 as debugprobe
  • Pico 2W as target MCU (soldered connections to Pico 2 to exclude fragile cabling as failure trigger)
Terminal output - Sample 1
user@gentoo-laptop ~/rpi_pico/blink_pico_w/build $ rpi-openocd -s tcl -f /usr/share/openocd-rpi/openocd/scripts/interface/cmsis-dap.cfg -f /usr/share/openocd-rpi/openocd/scripts/target/rp2350.cfg -c "adapter speed 5000" -c "program blink.elf verify reset exit"
Open On-Chip Debugger 0.12.0+dev-00002-gcd4873400 (2025-12-27-22:46)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : [rp2350.cm0] Hardware thread awareness created
Info : [rp2350.cm1] Hardware thread awareness created
ocd_process_reset_inner
adapter speed: 5000 kHz
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=9755E1275FBE9B51
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 5000 kHz
Info : SWD DPIDR 0x4c013477 DPv3
Info : [rp2350.cm0] Cortex-M33 r1p0 processor detected
Info : [rp2350.cm0] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.cm0] Examination succeed
Info : [rp2350.cm1] Cortex-M33 r1p0 processor detected
Info : [rp2350.cm1] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.cm1] Examination succeed
Info : [rp2350.cm0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
[rp2350.cm0] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
[rp2350.cm1] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
Info : RP2350 rev 2, QSPI Flash win w25q32fv/jv id = 0x1640ef size = 4096 KiB in 1024 sectors
Info : RP2xxx ROM API function FC @ 3711
** Programming Started **
Info : Padding image section 2 at 0x10040560 with 160 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x10040600 .. 0x10040fff
[--- here the process temporarily hangs for the first time ---]
Error: Error connecting DP: cannot read IDR
Error: Failed to read memory and, additionally, failed to find out where
Error: Could not allocate stack for flash programming code -- insufficient space
Speicherzugriffsfehler     rpi-openocd -s tcl -f /usr/share/openocd-rpi/openocd/scripts/interface/cmsis-dap.cfg -f /usr/share/openocd-rpi/openocd/scripts/target/rp2350.cfg -c "adapter speed 5000" -c "program blink.elf verify reset exit"
Terminal output - Sample 2
user@gentoo-laptop ~/rpi_pico/blink_pico_w/build $ rpi-openocd -s tcl -f /usr/share/openocd-rpi/openocd/scripts/interface/cmsis-dap.cfg -f /usr/share/openocd-rpi/openocd/scripts/target/rp2350.cfg -c "adapter speed 5000" -c "program blink.elf verify reset exit"
Open On-Chip Debugger 0.12.0+dev-00002-gcd4873400 (2025-12-27-22:46)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : [rp2350.cm0] Hardware thread awareness created
Info : [rp2350.cm1] Hardware thread awareness created
ocd_process_reset_inner
adapter speed: 5000 kHz
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=9755E1275FBE9B51
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 5000 kHz
Info : SWD DPIDR 0x4c013477 DPv3
Info : [rp2350.cm0] Cortex-M33 r1p0 processor detected
Info : [rp2350.cm0] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.cm0] Examination succeed
Info : [rp2350.cm1] Cortex-M33 r1p0 processor detected
Info : [rp2350.cm1] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.cm1] Examination succeed
Info : [rp2350.cm0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
[rp2350.cm0] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
[rp2350.cm1] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
Info : RP2350 rev 2, QSPI Flash win w25q32fv/jv id = 0x1640ef size = 4096 KiB in 1024 sectors
[--- here the process temporarily hangs for the first time ---]
Error: Error connecting DP: cannot read IDR
Error: Failed to read memory and, additionally, failed to find out where
Error: Could not allocate stack for flash programming code -- insufficient space
Error: Error connecting DP: cannot read IDR
Error: Failed to read memory and, additionally, failed to find out where
Warn : [rp2350.cm0] Error reading DAUTHSTATUS register
Error: [rp2350.cm0] Execution of event reset-init failed:
embedded:startup.tcl:1427: Error:
in procedure 'program'
in procedure 'ocd_process_reset'
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 1427
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm0] Execution of event check-availability failed:
embedded:startup.tcl:1906: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1906
Error: [rp2350.cm0] Polling failed, trying to reexamine
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm0] Execution of event check-availability failed:
embedded:startup.tcl:1906: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1906
Error: [rp2350.cm0] Examination failed
Error: [rp2350.cm0] Examination failed, GDB will be halted. Polling again in 100ms
** Unable to reset target **
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm1] Execution of event check-availability failed:
embedded:startup.tcl:1906: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1906
Error: [rp2350.cm1] Polling failed, trying to reexamine
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm1] Execution of event check-availability failed:
embedded:startup.tcl:1906: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1906
Error: [rp2350.cm1] Examination failed
Error: [rp2350.cm1] Examination failed, GDB will be halted. Polling again in 100ms
shutdown command invoked

Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: CMSIS-DAP command CMD_LED failed.
Error: CMSIS-DAP command CMD_LED failed.
Terminal output - Sample 3
user@gentoo-laptop ~/rpi_pico/blink_pico_w/build $ rpi-openocd -s tcl -f /usr/share/openocd-rpi/openocd/scripts/interface/cmsis-dap.cfg -f /usr/share/openocd-rpi/openocd/scripts/target/rp2350.cfg -c "adapter speed 5000" -c "program blink.elf verify reset exit"
Open On-Chip Debugger 0.12.0+dev-00002-gcd4873400 (2025-12-27-22:46)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : [rp2350.cm0] Hardware thread awareness created
Info : [rp2350.cm1] Hardware thread awareness created
ocd_process_reset_inner
adapter speed: 5000 kHz
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=9755E1275FBE9B51
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 5000 kHz
Info : SWD DPIDR 0x4c013477 DPv3
Info : [rp2350.cm0] Cortex-M33 r1p0 processor detected
Info : [rp2350.cm0] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.cm0] Examination succeed
Info : [rp2350.cm1] Cortex-M33 r1p0 processor detected
Info : [rp2350.cm1] target has 8 breakpoints, 4 watchpoints
Info : [rp2350.cm1] Examination succeed
Info : [rp2350.cm0] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
[rp2350.cm0] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
[rp2350.cm1] halted due to debug-request, current mode: Thread
xPSR: 0xf9000000 pc: 0x00000088 msp: 0xf0000000
Info : RP2350 rev 2, QSPI Flash win w25q32fv/jv id = 0x1640ef size = 4096 KiB in 1024 sectors
Info : RP2xxx ROM API function FC @ 3711
** Programming Started **
Info : Padding image section 2 at 0x10040560 with 160 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x10040600 .. 0x10040fff
Info :   Erase chunk: 0x00000000 -> 0x0001ffff
Info :   Erase chunk: 0x00020000 -> 0x0003ffff
Info :   Erase chunk: 0x00040000 -> 0x00040fff
[--- here the process temporarily hangs for the first time ---]
Error: Error connecting DP: cannot read IDR
Error: Failed to read memory and, additionally, failed to find out where
Error: Could not allocate bounce buffer for flash programming. Can't continue
Error: Error connecting DP: cannot read IDR
Error: Failed to write memory and, additionally, failed to find out where
Error: Failed to write ROM batch algorithm to RAM code space
Error: RP2xxx: failed to flush flash cache/restore XIP
Error: Error connecting DP: cannot read IDR
Error: Failed to write memory and, additionally, failed to find out where
Error: Error connecting DP: cannot read IDR
Error: Failed to read memory and, additionally, failed to find out where
Warn : [rp2350.cm0] Error reading DAUTHSTATUS register
Warn : RP2xxx: security state was not restored properly. Debug 'resume' will probably fail, use 'reset' instead
Error: Error connecting DP: cannot read IDR
Error: Failed to write memory and, additionally, failed to find out where
Error: failed to restore 1024 bytes of working area at address 0x20010000
Error: Error connecting DP: cannot read IDR
Error: Failed to write memory and, additionally, failed to find out where
Error: failed to restore 1024 bytes of working area at address 0x20010400
Error: error writing to flash at address 0x10000000 at offset 0x00000000
Error: [rp2350.cm0] Execution of event check-availability failed:
embedded:startup.tcl:1934: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1934
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm0] Polling failed, trying to reexamine
Error: [rp2350.cm0] Execution of event check-availability failed:
embedded:startup.tcl:1934: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1934
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm0] Examination failed
Error: [rp2350.cm0] Examination failed, GDB will be halted. Polling again in 100ms
** Programming Failed **
Error: [rp2350.cm1] Execution of event check-availability failed:
embedded:startup.tcl:1934: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1934
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm1] Polling failed, trying to reexamine
Error: [rp2350.cm1] Execution of event check-availability failed:
embedded:startup.tcl:1934: Error:
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 1934
Error: Error connecting DP: cannot read IDR
Error: [rp2350.cm1] Examination failed
Error: [rp2350.cm1] Examination failed, GDB will be halted. Polling again in 100ms
shutdown command invoked

Error: BUG: refcount AP#0xf00 used without get
Error: Error connecting DP: cannot read IDR
Error: Failed to write memory and, additionally, failed to find out where
Error: failed to restore 1024 bytes of working area at address 0x20010000
Error: Error connecting DP: cannot read IDR
Error: Failed to write memory and, additionally, failed to find out where
Error: failed to restore 1024 bytes of working area at address 0x20010400
Error: BUG: refcount AP#0 still 1 at exit
Error: CMSIS-DAP command CMD_DISCONNECT failed.
Error: CMSIS-DAP command CMD_LED failed.
Error: CMSIS-DAP command CMD_LED failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions