code wiki / _hdl_build / nx_fw_robust_flash.nx
nx_fw_robust_flash.nx
buildroot/runtime/_hdl_build/nx_fw_robust_flash.nx
about
nx_fw_robust_flash.nx -- S-CLASS never-brick: survives suboptimal/adverse conditions.
module: nishi-core.genealogy.fw_robust_flash
capability: CORE_COMPUTE (never-brick that holds through power loss at ANY step + double faults)
THE PROBLEM (operator 2026-06-16: "make our never brick s class even in suboptimal situations"):
nx_fw_safeflash's golden recovery assumes the golden anchor is always intact and the recovery
itself completes. Real devices brick from the SUBOPTIMAL cases: power loss MID-flash, power loss
MID-recovery, a corrupted recovery copy, torn writes, double faults. S-class never-brick must
survive ALL of them. The proven field design (dual-BIOS + flashback ROM) is modeled here:
* TWO banks A/B + an IMMUTABLE FACTORY anchor (the write-protected last resort).
* A flash writes ONLY the INACTIVE bank, verifies it (sha256), then ATOMICALLY flips a tiny
selector (write-temp + rename -- power loss leaves it fully-old or fully-new, never torn).
The ACTIVE bank is NEVER overwritten, so a crash before the commit leaves the OLD image
selected = still bootable.
* rf_select (what firmware runs at power-on): preferred bank -> the other bank (self-heal) ->
the immutable factory. It returns a BOOTABLE image unless EVEN THE FACTORY is gone.
INVARIANT (S-class never-brick): as long as the immutable factory survives (it is write-
protected by design), rf_select returns a bootable image after ANY interruption sequence.
Sandboxed (/tmp only). Sovereign: reuses nx_fw_safeflash image+sha256 primitives. license_tier: ORIGINAL
dependencies 2 imports · 1 importers
imports: nx_fw_safeflash.nxnx_syscalls.nx
imported by: nx_fw_robust_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 26 | const RF_HELD: i64 = 6 // inactive write failed verify -> NOT committed, active retained (no brick) |
| 27 | const RF_BANK_A: i64 = 65 // 'A' |
| 28 | const RF_BANK_B: i64 = 66 // 'B' |
functions
| 30 | func rf_tmp(sel: *u8, out: *u8) -> i64 |
| 38 | func rf_read_sel(sel: *u8) -> i64 |
| 51 | func rf_write_sel_atomic(sel: *u8, bankc: i64) -> i64 |
| 60 | func rf_other(bankc: i64) -> i64 { if bankc == RF_BANK_B { return RF_BANK_A } return RF_BANK_B } called by 1: rf_safe_flash |
| 64 | func rf_select(sel: *u8, ba: *u8, bb: *u8, fac: *u8) -> *u8 |
| 71 | func rf_selectable(sel: *u8, ba: *u8, bb: *u8, fac: *u8) -> i64 |
| 78 | func rf_safe_flash(sel: *u8, ba: *u8, bb: *u8, fac: *u8, newimg: *u8, corrupt: i64) -> i64 |
| 100 | func main() -> i64 |