nx_printer_fw_sim.nx
buildroot/runtime/nx_printer_fw_sim.nx
about
nx_printer_fw_sim.nx -- VIRTUAL printer firmware/flash SIMULATOR. The operator wants to let a user flash OUR
firmware to escape vendor DRM -- but FLASHING WRITES PERSISTENT HARDWARE STATE, the exact hazard global rule
#26 (NEVER BRICK THE ELECTRONICS -- brand-critical, ABSOLUTE) governs. So we model the printer + the flash
process IN SOFTWARE, iterate here (a simulator cannot brick anything), and PROVE the flash is fail-safe BY
CONSTRUCTION before any real device is touched. **NO real hardware is written by this file.**
NEVER-BRICK ARCHITECTURE = A/B DUAL-BANK (the only safe way to field-flash): write the INACTIVE bank, verify
its signature, then ATOMICALLY flip the boot pointer. The ACTIVE (running) bank is NEVER modified during a
flash, so a power loss at ANY step leaves a bootable bank -> never bricked. A bad-signature image is rejected
before the flip; an image that doesn't boot is rolled back by the bootloader to the prior bank. The gate
injects power loss at EVERY step x EVERY firmware quality and proves the printer ALWAYS boots something --
the #26 guarantee proven MECHANICALLY, not asserted -- with a NAIVE in-place flash as the negative control
(it CAN brick, proving A/B is what saves us).
State = i64[9]: [0]=active_bank(0=A,1=B); bank b at base (1 + b*4) = [present, sig_valid, boots, version].
PURE (caller-owned state, no syscalls) -> safe by construction. license_tier: ORIGINAL
genealogy_id: project-printer-management-ipp-sclass-2026-06-20 ; honors global rule #26.
dependencies 0 imports · 1 importers
imports: none
imported by: nx_printer_fw_sim_test.nx
structs
| none |
consts
| 19 | const NX_FW_BRICKED: i64 = 0 - 1 |
functions
| 21 | func fw_base(b: i64) -> i64 { return 1 + b * 4 } |
| 23 | func fw_set_bank(st: *i64, b: i64, present: i64, sig: i64, boots: i64, ver: i64) -> i64 |
| 30 | func fw_bank_bootable(st: *i64, b: i64) -> i64 |
| 40 | func fw_boot(st: *i64) -> i64 |
| 51 | func fw_flash_ab(st: *i64, new_ver: i64, new_sig: i64, new_boots: i64, power_loss_step: i64) -> i64 |
| 69 | func fw_flash_naive(st: *i64, new_ver: i64, new_sig: i64, new_boots: i64, power_loss_step: i64) -> i64 |