summaryrefslogtreecommitdiffstats
path: root/shell/src/lib.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-02 15:21:34 +0200
committersalmonik <salmonik@tuta.io>2026-08-02 15:21:34 +0200
commitc7d92071e1dd11c45999457b16554b4abaa73b28 (patch)
treeaff7c7f19adcffe1dd91e1c2514af02c77fd524e /shell/src/lib.rs
parentv0.5.5: fix real-hardware boot crash — shadow back in heap as first allocation (diff)
downloadrs-dos-c7d92071e1dd11c45999457b16554b4abaa73b28.tar.gz
rs-dos-c7d92071e1dd11c45999457b16554b4abaa73b28.zip
v0.5.5: crash reports go to a dedicated CRASHLOG USB stick
The fault handler now writes crash.log to the volume labeled CRASHLOG (label-selected via fat::crash_vol), falling back to slot 0. On real hardware the boot USB may be unwritable, so a second stick labeled CRASHLOG survives the write; the shell auto-prints the previous crash report from it at next boot (read_crash_log resolves /disk/<uid>/crash.log through the FAT path, since Disk nodes hold no cached children). - fat.rs: volume_label() + crash_vol() (no allocation) - fs.rs: write_crash_log targets crash_vol(); read_crash_log prefers the CRASHLOG disk node; drop now-unused first_disk() - mkdisk.sh: --label option - test-fault.sh: boots with a dedicated CRASHLOG stick (mkfs -F 32 -n CRASHLOG), verifies crash.log lands there and NOT on the ESP
Diffstat (limited to '')
-rw-r--r--shell/src/lib.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/shell/src/lib.rs b/shell/src/lib.rs
index b2c4a1b..a32d259 100644
--- a/shell/src/lib.rs
+++ b/shell/src/lib.rs
@@ -41,6 +41,24 @@ pub fn run() -> ! {
41 env!("CARGO_PKG_VERSION") 41 env!("CARGO_PKG_VERSION")
42 )); 42 ));
43 43
44 // A crash report from a previous run survives on the disk (the fault
45 // handler writes crash.log on the mounted volume before halting; real
46 // hardware has no serial console). Surface it so the user can report it.
47 if let Some(h) = rsnix::fs::read_crash_log() {
48 term_println("!!! PREVIOUS CRASH REPORT:");
49 let mut buf = [0u8; 256];
50 if let Ok(n) = rsnix::fs::read(h, &mut buf, 0)
51 && n > 0 {
52 let s = core::str::from_utf8(&buf[..n]).unwrap_or("?");
53 for line in s.split('\n') {
54 if !line.is_empty() {
55 term_println(line);
56 }
57 }
58 }
59 term_println("!!! end of crash report");
60 }
61
44 loop { 62 loop {
45 // Push any deferred scrolls so the prompt renders on a current 63 // Push any deferred scrolls so the prompt renders on a current
46 // framebuffer (e.g. after a streaming command's batch of output). 64 // framebuffer (e.g. after a streaming command's batch of output).
@@ -722,6 +740,7 @@ write `{} <path> TIL <marker>`",
722 "kill" => cmd_kill(&parsed), 740 "kill" => cmd_kill(&parsed),
723 "demo" => cmd_demo(&parsed), 741 "demo" => cmd_demo(&parsed),
724 "fault" => cmd_fault(), 742 "fault" => cmd_fault(),
743 "crashlog" => cmd_crashlog(),
725 "stall" => cmd_stall(&parsed), 744 "stall" => cmd_stall(&parsed),
726 _ => term_err(&alloc::format!("unknown command: {}", cmd)), 745 _ => term_err(&alloc::format!("unknown command: {}", cmd)),
727 } 746 }
@@ -820,6 +839,14 @@ fn cmd_fault() {
820 } 839 }
821} 840}
822 841
842/// Debug hook: run the crash-log FAT write from the *shell* context (not
843/// the fault ISR) to compare behaviour.
844fn cmd_crashlog() {
845 let lines = ["!!! test crashlog write", "second line", "third line"];
846 rsnix::fs::write_crash_log(&lines);
847 term_println("crashlog: done");
848}
849
823/// Set the display-store stall (cycles per word) — diagnostics knob that 850/// Set the display-store stall (cycles per word) — diagnostics knob that
824/// simulates the per-write cost of an uncached real-GPU framebuffer so 851/// simulates the per-write cost of an uncached real-GPU framebuffer so
825/// the preemptive scheduler races long scroll pushes like on real 852/// the preemptive scheduler races long scroll pushes like on real