This adds some UX feedback in the edge case that a suspend could not
happen due to a blocking sever, e.g. a sha512 hash pending or
a SPINOR flash write/erase pending.

The UI will tell the user to retry again; usually the ops in
a normally functioning system for hashes or SPI are very short,
so we could almost just retry automatically but I think for now
I want to see if this edge case actually happens.
This commit is contained in:
bunnie 2022-09-24 02:40:11 +08:00
parent d3daca9c5e
commit 85279566f0
6 changed files with 51 additions and 18 deletions

View file

@ -555,16 +555,6 @@ pub(crate) fn ci_tests(pddb_os: &mut PddbOs) -> Result<()> {
log::info!("CI done"); log::info!("CI done");
/*
// abortive attempt to get CI to exit cleanly
#[cfg(not(any(target_os = "none", target_os = "xous")))]
{
let xns = xous_names::XousNames::new().unwrap();
let susres = susres::Susres::new_without_hook(&xns).unwrap();
susres.initiate_suspend().expect("couldn't initiate suspend op");
//xous::rsyscall(xous::SysCall::Shutdown).expect("unable to quit");
}*/
Ok(()) Ok(())
} }
} }

View file

@ -64,7 +64,15 @@ impl<'a> ShellCmdApi<'a> for Sleep {
write!(ret, "crypto power is now off").unwrap(); write!(ret, "crypto power is now off").unwrap();
} }
"sus" => { "sus" => {
self.susres.initiate_suspend().unwrap(); match self.susres.initiate_suspend() {
Err(xous::Error::Timeout) => {
write!(ret, "Couldn't suspend, a server was blocking suspend.\n").ok();
}
Ok(_) => {},
Err(e) => {
write!(ret, "Unknown error on suspend: {:?}", e).ok();
}
}
// the message below is sent after we wake up // the message below is sent after we wake up
write!(ret, "Resumed from sleep!").unwrap(); write!(ret, "Resumed from sleep!").unwrap();
} }
@ -82,7 +90,15 @@ impl<'a> ShellCmdApi<'a> for Sleep {
loop { loop {
log::info!("suspend/resume cycle: {}", iters); log::info!("suspend/resume cycle: {}", iters);
llio.set_wakeup_alarm(4).unwrap(); llio.set_wakeup_alarm(4).unwrap();
susres.initiate_suspend().unwrap(); match susres.initiate_suspend() {
Err(xous::Error::Timeout) => {
log::warn!("Couldn't suspend, a server was blocking suspend.\n");
}
Ok(_) => {},
Err(e) => {
log::error!("Unknown error on suspend: {:?}", e);
}
}
ticktimer.sleep_ms(8000).unwrap(); ticktimer.sleep_ms(8000).unwrap();
iters += 1; iters += 1;
} }

View file

@ -1,4 +1,10 @@
{ {
"suspend.fail": {
"ja": "中断不可能な操作が保留中です。 数秒後にスリープ リクエストを再試行してください。",
"en": "Uninterruptible operation pending. Please retry the sleep request in a couple seconds.",
"zh": "不间断操作挂起。 请在几秒钟后重试睡眠请求。",
"en-tts": "Uninterruptible operation pending. Please retry the sleep request in a couple seconds."
},
"socup.candidate": { "socup.candidate": {
"ja": "ゲートウェアの更新候補が見つかりました。\n\n適用する必要がありますか?", "ja": "ゲートウェアの更新候補が見つかりました。\n\n適用する必要がありますか?",
"en": "An update candidate for the SoC was found.\n\nShould we apply it?\n\nNOTE: if you just installed an update, try rebooting using a paperclip in the hole in the lower right hand corner. This forces the latest image to load.", "en": "An update candidate for the SoC was found.\n\nShould we apply it?\n\nNOTE: if you just installed an update, try rebooting using a paperclip in the hole in the lower right hand corner. This forces the latest image to load.",

View file

@ -1001,7 +1001,15 @@ fn wrapped_main() -> ! {
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG), None).expect("couldn't notify that power is plugged in"); modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG), None).expect("couldn't notify that power is plugged in");
} else { } else {
// log::set_max_level(log::LevelFilter::Debug); // log::set_max_level(log::LevelFilter::Debug);
susres.initiate_suspend().expect("couldn't initiate suspend op"); match susres.initiate_suspend() {
Ok(_) => {},
Err(xous::Error::Timeout) => {
modals.show_notification(t!("suspend.fail", xous::LANG), None).unwrap();
}
Err(_e) => {
panic!("Unhandled error on suspend request");
}
}
} }
}, },
Some(StatusOpcode::BatteryDisconnect) => { Some(StatusOpcode::BatteryDisconnect) => {

View file

@ -53,7 +53,6 @@ impl Susres {
}) })
} }
pub fn conn(&self) -> CID { self.conn } pub fn conn(&self) -> CID { self.conn }
pub fn getop_suspend(&self) -> u32 { Opcode::SuspendRequest.to_u32().unwrap() }
pub fn new_without_hook(xns: &xous_names::XousNames) -> Result<Self, xous::Error> { pub fn new_without_hook(xns: &xous_names::XousNames) -> Result<Self, xous::Error> {
REFCOUNT.fetch_add(1, Ordering::Relaxed); REFCOUNT.fetch_add(1, Ordering::Relaxed);
@ -66,9 +65,19 @@ impl Susres {
pub fn initiate_suspend(&self) -> Result<(), xous::Error> { pub fn initiate_suspend(&self) -> Result<(), xous::Error> {
log::trace!("suspend initiated"); log::trace!("suspend initiated");
send_message(self.conn, match send_message(self.conn,
Message::new_scalar(Opcode::SuspendRequest.to_usize().unwrap(), 0, 0, 0, 0) Message::new_blocking_scalar(Opcode::SuspendRequest.to_usize().unwrap(), 0, 0, 0, 0)
).map(|_|()) ) {
Ok(xous::Result::Scalar1(result)) => {
if result == 1 {
Ok(())
} else {
// indicate that we couldn't initiate the suspend
Err(xous::Error::Timeout)
}
},
_ => Err(xous::Error::InternalError)
}
} }
pub fn suspend_until_resume(&mut self, token: usize) -> Result<bool, xous::Error> { pub fn suspend_until_resume(&mut self, token: usize) -> Result<bool, xous::Error> {

View file

@ -699,6 +699,9 @@ fn main() -> ! {
// if the 2-second timeout is still pending from a previous suspend, deny the suspend request. // if the 2-second timeout is still pending from a previous suspend, deny the suspend request.
// ...just don't suspend that quickly after resuming??? // ...just don't suspend that quickly after resuming???
if allow_suspend && !timeout_pending { if allow_suspend && !timeout_pending {
// ack the request early
xous::return_scalar(msg.sender, 1).ok();
susres_hw.ignore_wfi(); susres_hw.ignore_wfi();
suspend_requested = true; suspend_requested = true;
// clear the resume gate // clear the resume gate
@ -726,7 +729,8 @@ fn main() -> ! {
// let the events fire // let the events fire
xous::yield_slice(); xous::yield_slice();
} else { } else {
log::warn!("suspend requested, but the system was not allowed to suspend. Ignoring request.") log::warn!("suspend requested, but the system was not allowed to suspend. Ignoring request.");
xous::return_scalar(msg.sender, 0).ok();
} }
}, },
Some(Opcode::SuspendTimeout) => { Some(Opcode::SuspendTimeout) => {