probe-rs icon indicating copy to clipboard operation
probe-rs copied to clipboard

Unable to do anything with a blank STM32F103

Open xobs opened this issue 6 months ago • 0 comments

Describe the bug

probe-rs is unable to do anything with a blank STM32F103. Flash is comprised entirely of 0xffffffff due to a mass-erase. Attempting to do anything results in an endlress stream of lockup messages:

❯ cargo run -p probe-rs-tools  -- read --protocol swd --chip STM32F103C8 b32 0x08000000 1
    Blocking waiting for file lock on build directory
   Compiling probe-rs v0.29.0 (/Users/seancross/Code/probe-rs/probe-rs)
   Compiling probe-rs-debug v0.29.0 (/Users/seancross/Code/probe-rs/probe-rs-debug)
   Compiling probe-rs-tools v0.29.0 (/Users/seancross/Code/probe-rs/probe-rs-tools)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 10.21s
     Running `target/debug/probe-rs read --protocol swd --chip STM32F103C8 b32 0x08000000 1`
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
ERROR probe_rs::architecture::arm::core::armv7m: The core is in locked up status as a result of an unrecoverable exception
...

To Reproduce

  1. Blank an STM32F103. This can be done with a board straight from the factory, or using openocd or blackmagic.
  2. Attempt to read from flash, RAM, or use GDB. cargo run -p probe-rs-tools -- read --protocol swd --chip STM32F103C8 b32 0x08000000 1 is a good usecase.

Expected behavior

The target should be able to attach to a device even if it's blank. Other tools are able to attach to this device, even when using the same debug probes.

Stacktrace


Operating System

None

Additional context

The following patch results in a device that is usable:

diff --git a/probe-rs/src/architecture/arm/core/armv7m.rs b/probe-rs/src/architecture/arm/core/armv7m.rs
index d093d3414..2f0ff6a38 100644
--- a/probe-rs/src/architecture/arm/core/armv7m.rs
+++ b/probe-rs/src/architecture/arm/core/armv7m.rs
@@ -672,6 +672,9 @@ impl CoreInterface for Armv7m<'_> {
             tracing::error!(
                 "The core is in locked up status as a result of an unrecoverable exception"
             );
+            self.reset_catch_set()?;
+            self.reset()?;
+            self.reset_catch_clear()?;

             self.set_core_status(CoreStatus::LockedUp);

xobs avatar Jun 03 '25 14:06 xobs