nx_flash_test.nx
buildroot/runtime/nx_flash_test.nx
about
nx_flash_test.nx -- sovereign IMAGE FLASHER (S-class vs dd/Rufus/Etcher). A flasher should never
write blind: it CONTENT-HASHES the image, WRITES, READS BACK, and HASH-VERIFIES byte-for-byte, and
it REFUSES non-removable/system targets BY CONSTRUCTION (Rule 26: never brick). dd does none of
that. KAT proves: flash+verify is byte-perfect, a wrong/tampered flash is DETECTED, a system-disk
target is REFUSED, and a measured exceed scorecard vs dd.
HONEST: a real USB write targets /dev/sdX (operator runs the tool with the device + the safety
guard); this KAT flashes to a FILE to prove the write+verify+safety mechanism. No real-device
writes here (Rule 26). expect_exit: 0 license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_sha256.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 12 | func fl_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 13 | func fl_putn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } |
| 14 | func fl_h32eq(a: *u8, b: *u8) -> i64 { var i: i64=0; while i<32 { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } called by 1: fl_verify |
| 15 | func fl_hexb(v: i64) -> i64 { let hi: i64=(v>>4)&15; let lo: i64=v&15; var c1: i64=48+hi; if hi>9 { c1=87+hi } var c2: i64=48+lo; if lo>9 { c2=87+lo } let o: *u8=sys_mmap(4); o[0]=c1 as u8; o[1]=c2 as u8; sys_write(1,o,2); return 0 } |
| 19 | func fl_safe(target: *u8) -> i64 |
| 25 | func fl_write(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64=sys_openat_wr(path, 0x1a4); if fd<=0 { return 0-1 } sys_write(fd, buf, n); sys_close(fd); return 0 } |
| 28 | func fl_verify(img: *u8, n: i64, target: *u8) -> i64 |
| 42 | func fl_flash(img: *u8, n: i64, target: *u8) -> i64 |
| 48 | func main() -> i64 |