Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

os.mjs: retry initramfs + detect pre-Phase-2 OTA mismatch

Two OTA robustness improvements for shipped os.mjs (bronze-swallow-root
and forward):

1. Retry initramfs download once on failure. Most "initramfs download
failed" reports in MongoDB are transient network hiccups — a 326 MB
fetch over flaky wifi + a strict curl --max-time gives plenty of
opportunity for a single-packet TCP reset. Second attempt almost
always succeeds.

2. Recognize the Phase-2 OTA mismatch. Pre-Phase-2 installs have a
runtime that only fetches + flashes the kernel (13 MB). When the OTA
target is a Phase-2 build, the C flash verify fails because the
expected payload includes initramfs. The old error "flash verify
failed" was accurate but unhelpful — the real fix is a USB install.
Now: if verify fails AND initramfsDownloaded=false, error becomes
"needs USB install (pre-Phase-2 OTA)" with telemetry hints
explaining the boot-USB + `w` path.

Also adds elapsed-seconds to initramfs progress telemetry — useful for
MongoDB forensic analysis of timeout-vs-flaky-network failures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+25 -5
+25 -5
fedac/native/pieces/os.mjs
··· 16 16 // kernel and the initramfs and flash them atomically, otherwise the device 17 17 // boots a new kernel against a stale initramfs and code-path drift follows. 18 18 let initramfsDownloaded = false; 19 + let initramfsRetried = false; // one-shot retry on transient fetch failure 19 20 20 21 // States: idle | checking | up-to-date | available 21 22 // | downloading (kernel) | downloading-initramfs | flashing ··· 842 843 } 843 844 } 844 845 845 - // Download progress (initramfs) — kicks off flash once both files are local 846 + // Download progress (initramfs) — kicks off flash once both files are local. 847 + // Auto-retry once on failure (flaky wifi / TLS hiccups account for most 848 + // "initramfs download failed" reports in MongoDB). 846 849 if (state === "downloading-initramfs") { 847 850 const prevProgress = progress; 848 851 progress = system?.fetchBinaryProgress ?? progress; 849 852 if (progress > 0 && Math.floor(progress * 10) > Math.floor(prevProgress * 10)) { 850 853 const pct = Math.round(progress * 100); 851 - addTelemetry(`initramfs ${pct}%`); 854 + addTelemetry(`initramfs ${pct}% (${(progress * 336 / 100 * 100).toFixed(1)}MB, elapsed ${Math.round((frame - checkFrame) / 60)}s)`); 852 855 } 853 856 if (system?.fetchBinaryDone) { 854 857 if (system?.fetchBinaryOk) { ··· 860 863 // Four-arg flashUpdate: (kernelSrc, device, initramfsSrc) 861 864 // Device may be omitted — null lets C auto-detect the boot device. 862 865 system?.flashUpdate?.("/tmp/vmlinuz.new", dev || null, "/tmp/initramfs.cpio.gz.new"); 866 + } else if (!initramfsRetried) { 867 + initramfsRetried = true; 868 + addTelemetry("initramfs download failed — retrying once"); 869 + progress = 0; 870 + system?.fetchBinary?.(OS_INITRAMFS_URL, "/tmp/initramfs.cpio.gz.new", 336_000_000); 863 871 } else { 864 - setError("initramfs download failed", "downloading-initramfs"); 872 + setError("initramfs download failed (after retry)", "downloading-initramfs"); 865 873 } 866 874 } 867 875 } ··· 900 908 addTelemetry(`verified OK: ${flashedMB}MB`); 901 909 state = "confirm-reboot"; 902 910 } else { 903 - addTelemetry("VERIFY FAILED"); 911 + // Detect the Phase-2 OTA mismatch: verify fails because the 912 + // running os.mjs pushed only the kernel (13MB) but the C flash 913 + // layer expected kernel + initramfs. Surface the real cause so 914 + // the user knows to USB-install instead of retrying OTA forever. 915 + const wroteBytes = system?.flashVerifiedBytes ?? 0; 916 + const wroteMB = (wroteBytes / 1048576).toFixed(1); 917 + addTelemetry(`VERIFY FAILED wrote=${wroteMB}MB`); 904 918 for (const line of flog) addTelemetry("[c] " + line); 905 - setError("flash verify failed", "flashing"); 919 + if (!initramfsDownloaded) { 920 + addTelemetry("hint: this build needs a separate initramfs."); 921 + addTelemetry("hint: boot from USB + press 'w' to reinstall."); 922 + setError("needs USB install (pre-Phase-2 OTA)", "flashing"); 923 + } else { 924 + setError("flash verify failed", "flashing"); 925 + } 906 926 } 907 927 } 908 928 }