feat(persistence): add SD mount + atomic save/load module

Graduate the proven Spike 3 storage stack into firmware::persistence so the
editor and the spike share one implementation. Storage::mount brings up the
dedicated SPI3 bus (ADR-012) and mounts FAT with format_if_mount_failed=false
(never reformat the user's card). save() does the FAT-safe atomic write
(tmp -> fsync -> unlink -> rename); recover() reconciles a leftover *.tmp at
boot, keeping the committed file when the crash point is ambiguous and only
promoting the tmp when the target was already unlinked. load() caps reads at
256 KiB.
This commit is contained in:
Julien Calixte
2026-07-11 12:02:15 +02:00
parent 5540f901de
commit 9c338571f0
2 changed files with 329 additions and 4 deletions

View File

@@ -2,9 +2,12 @@
//!
//! The editor binary (`src/main.rs`) and the spike binaries under `src/bin/`
//! are each separate crate roots; anything they need to share lives here and is
//! reached as `firmware::…`. Currently that is just the resilient Wi-Fi
//! bring-up, extracted from three duplicated `connect_wifi` copies so the retry
//! logic lives in exactly one place and the eventual editor integration reuses
//! it instead of growing a fourth copy.
//! reached as `firmware::…`:
//!
//! - [`net`] — resilient Wi-Fi bring-up, extracted from three duplicated
//! `connect_wifi` copies so the retry logic lives in exactly one place.
//! - [`persistence`] — SD mount + atomic save/load, graduated from the Spike 3
//! bench binary so the editor and the spike share one implementation.
pub mod net;
pub mod persistence;