Skip to content

Commit 781776b

Browse files
committed
move the mount initiator back into status; fix waiting signal
mount initiator is now back inside of the status thread (woo, no more app-specific dependency) and there is now a wait on "attempted to mount" inside the status thread which is the signal to clear the "waiting on boot" message.
1 parent 0646ec2 commit 781776b

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

services/shellchat/src/main.rs

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use std::alloc::System;
6767
#[global_allocator]
6868
static GLOBAL: Allocator<System> = Allocator::system();
6969
#[cfg(feature="tracking-alloc")]
70-
use core::sync::atomic::{AtomicIsize, Ordering};
70+
use core::sync::atomic::AtomicIsize;
7171
#[cfg(feature="tracking-alloc")]
7272
struct StdoutTracker {
7373
pub total: AtomicIsize,
@@ -308,7 +308,6 @@ impl Repl{
308308
write!(init_tv.text, "{}", t!("shellchat.bootwait", xous::LANG)).ok();
309309
self.gam.post_textview(&mut init_tv).expect("couldn't render wait text");
310310
self.gam.redraw().expect("couldn't redraw screen");
311-
return Ok(())
312311
}
313312

314313
// this defines the bottom border of the text bubbles as they stack up wards
@@ -417,54 +416,17 @@ fn wrapped_main() -> ! {
417416

418417
let mut allow_redraw = true;
419418
let pddb_init_done = Arc::new(AtomicBool::new(false));
420-
421-
// spawn a thread to auto-mount the PDDB. It's important that this spawn happens after
422-
// our GAM context has been registered (which happened in the `Repl::new()` call above)
423-
repl.redraw(false).ok();
424-
let _ = thread::spawn({
419+
repl.redraw(pddb_init_done.load(Ordering::SeqCst)).ok();
420+
thread::spawn({
425421
let pddb_init_done = pddb_init_done.clone();
426422
let main_conn = xous::connect(shch_sid).unwrap();
427423
move || {
428-
let tt = ticktimer_server::Ticktimer::new().unwrap();
429-
let xns = xous_names::XousNames::new().unwrap();
430-
let gam = gam::Gam::new(&xns).unwrap();
431-
while !gam.trusted_init_done().unwrap() {
432-
tt.sleep_ms(50).ok();
433-
}
434-
loop {
435-
// Force the "please wait" message to disappear *prior* to the context switch out to the PDDB login box
436-
// this is necessary because if the mounting process is extremely fast, the subsequent redraw message
437-
// to clear the please wait message will get missed on the return.
438-
xous::send_message(main_conn,
439-
xous::Message::new_blocking_scalar(ShellOpcode::ForceRedraw.to_usize().unwrap(), 0, 0, 0, 0)
440-
).ok();
441-
let (no_retry_failure, count) = pddb::Pddb::new().try_mount();
442-
pddb_init_done.store(true, Ordering::SeqCst);
443-
if no_retry_failure {
444-
// this includes both successfully mounted, and user abort of mount attempt
445-
break;
446-
} else {
447-
// this indicates system was guttered due to a retry failure
448-
let xns = xous_names::XousNames::new().unwrap();
449-
let susres = susres::Susres::new_without_hook(&xns).unwrap();
450-
let llio = llio::Llio::new(&xns);
451-
if ((llio.adc_vbus().unwrap() as u32) * 503) < 150_000 {
452-
// try to force suspend if possible, so that users who are just playing around with
453-
// the device don't run the battery down accidentally.
454-
susres.initiate_suspend().ok();
455-
tt.sleep_ms(1000).unwrap();
456-
let modals = modals::Modals::new(&xns).unwrap();
457-
modals.show_notification(
458-
&t!("login.fail", xous::LANG).replace("{fails}", &count.to_string()),
459-
None
460-
).ok();
461-
} else {
462-
// otherwise force a reboot cycle to slow down guessers
463-
susres.reboot(true).expect("Couldn't reboot after too many failed password attempts");
464-
tt.sleep_ms(5000).unwrap();
465-
}
466-
}
467-
}
424+
let pddb = pddb::Pddb::new();
425+
pddb.mount_attempted_blocking();
426+
pddb_init_done.store(true, Ordering::SeqCst);
427+
xous::send_message(main_conn,
428+
xous::Message::new_scalar(ShellOpcode::Redraw.to_usize().unwrap(), 0, 0, 0, 0)
429+
).ok();
468430
}
469431
});
470432

services/status/src/main.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,44 @@ fn wrapped_main() -> ! {
633633
#[cfg(any(feature="precursor", feature="renode"))]
634634
llio.clear_wakeup_alarm().unwrap(); // this is here to clear any wake-up alarms that were set by a prior coldboot command
635635

636+
// spawn a thread to auto-mount the PDDB
637+
let _ = thread::spawn({
638+
move || {
639+
let xns = xous_names::XousNames::new().unwrap();
640+
let tt = ticktimer_server::Ticktimer::new().unwrap();
641+
let gam = gam::Gam::new(&xns).unwrap();
642+
while !gam.trusted_init_done().unwrap() {
643+
tt.sleep_ms(100).ok();
644+
}
645+
loop {
646+
let (no_retry_failure, count) = pddb::Pddb::new().try_mount();
647+
if no_retry_failure {
648+
// this includes both successfully mounted, and user abort of mount attempt
649+
break;
650+
} else {
651+
// this indicates system was guttered due to a retry failure
652+
let susres = susres::Susres::new_without_hook(&xns).unwrap();
653+
let llio = llio::Llio::new(&xns);
654+
if ((llio.adc_vbus().unwrap() as u32) * 503) < 150_000 {
655+
// try to force suspend if possible, so that users who are just playing around with
656+
// the device don't run the battery down accidentally.
657+
susres.initiate_suspend().ok();
658+
tt.sleep_ms(1000).unwrap();
659+
let modals = modals::Modals::new(&xns).unwrap();
660+
modals.show_notification(
661+
&t!("login.fail", xous::LANG).replace("{fails}", &count.to_string()),
662+
None
663+
).ok();
664+
} else {
665+
// otherwise force a reboot cycle to slow down guessers
666+
susres.reboot(true).expect("Couldn't reboot after too many failed password attempts");
667+
tt.sleep_ms(5000).unwrap();
668+
}
669+
}
670+
}
671+
}
672+
});
673+
636674
pump_run.store(true, Ordering::Relaxed); // start status thread updating
637675
loop {
638676
let msg = xous::receive_message(status_sid).unwrap();

0 commit comments

Comments
 (0)