Module panic_persist

Module panic_persist 

Source
Expand description

Persist panic messages across resets.

On nRF52840 a region of RAM can be marked as noinit so its contents survive a soft reset (warm boot, watchdog, panic-driven SCB::sys_reset()). This module provides the framing layer for that region — it lives here in umsh-bsp-nrf52840 because every nRF52840-based board (T1000-E, T-Echo, …) shares this mechanism.

The PanicSlot API operates on a borrowed &'static mut [u8], so the framing is purely portable and unit-testable on the host. The caller is responsible for declaring the .noinit static and passing a mutable slice of it; see umsh-bsp-nrf52840::gpregret and the board BSPs for the typical integration pattern.

§On-region layout

  offset  field      bytes  notes
  ------  --------   -----  -----------------------------------------
    0     magic        4    PANIC_MAGIC; distinguishes a captured
                            record from uninitialized RAM noise.
    4     length       2    payload length in bytes (truncated if
                            larger than the region).
    6     checksum     2    Fletcher-16 of magic ++ length ++ payload.
    8     payload      N    UTF-8 panic message, `length` bytes.

Total header = 8 bytes. Maximum payload = region.len() - 8.

Structs§

PanicSlot
Framing wrapper around a borrowed RAM region.
SliceWriter
A core::fmt::Write sink over a fixed-size byte slice.
SyncNoinit
A Sync wrapper around UnsafeCell<MaybeUninit<T>> for use with #[link_section = ".uninit"] statics.