mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
test case now failing, now we can solve the problem faster
This commit is contained in:
parent
0234b4b22d
commit
0ccd487f5a
6 changed files with 136 additions and 103 deletions
|
|
@ -1268,7 +1268,7 @@ impl<'a> Modal<'a> {
|
||||||
xous::create_thread_3(crate::forwarding_thread, addr, size, offset).expect("couldn't spawn a helper thread");
|
xous::create_thread_3(crate::forwarding_thread, addr, size, offset).expect("couldn't spawn a helper thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn redraw(&mut self) {
|
pub fn redraw(&self) {
|
||||||
log::debug!("modal redraw");
|
log::debug!("modal redraw");
|
||||||
let canvas_size = self.gam.get_canvas_bounds(self.canvas).unwrap();
|
let canvas_size = self.gam.get_canvas_bounds(self.canvas).unwrap();
|
||||||
let do_redraw = self.top_dirty || self.bot_dirty;
|
let do_redraw = self.top_dirty || self.bot_dirty;
|
||||||
|
|
@ -1404,6 +1404,8 @@ impl<'a> Modal<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let style = if let Some(style) = update_style {
|
let style = if let Some(style) = update_style {
|
||||||
|
self.top_dirty = true;
|
||||||
|
self.bot_dirty = true;
|
||||||
style
|
style
|
||||||
} else {
|
} else {
|
||||||
self.style
|
self.style
|
||||||
|
|
@ -1460,7 +1462,6 @@ impl<'a, 'b> ProgressBar<'a, 'b> {
|
||||||
Some(crate::ActionType::Slider(*self.slider)),
|
Some(crate::ActionType::Slider(*self.slider)),
|
||||||
None, false, None, false, None);
|
None, false, None, false, None);
|
||||||
self.modal.redraw(); // stage the modal box pixels to the back buffer
|
self.modal.redraw(); // stage the modal box pixels to the back buffer
|
||||||
self.modal.gam.redraw().expect("couldn't cause back buffer to be sent to the screen");
|
|
||||||
xous::yield_slice(); // this gives time for the GAM to do the sending
|
xous::yield_slice(); // this gives time for the GAM to do the sending
|
||||||
self.current_progress_percent = new_percent;
|
self.current_progress_percent = new_percent;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -485,15 +485,15 @@ mod implementation {
|
||||||
// a stub to try to avoid breaking hosted mode for as long as possible.
|
// a stub to try to avoid breaking hosted mode for as long as possible.
|
||||||
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
#[cfg(not(any(target_os = "none", target_os = "xous")))]
|
||||||
mod implementation {
|
mod implementation {
|
||||||
pub struct JtagMach {
|
pub struct JtagPhy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JtagMach {
|
impl JtagPhy {
|
||||||
pub fn new() -> JtagMach {
|
pub fn new() -> JtagPhy {
|
||||||
JtagMach {
|
JtagPhy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn sync(&mut self, tdi: bool, tms: bool) -> bool {
|
pub fn sync(&mut self, tdi: bool, tms: bool) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,9 @@
|
||||||
"en-audio": "Unplug the charging cable so I can reboot!"
|
"en-audio": "Unplug the charging cable so I can reboot!"
|
||||||
},
|
},
|
||||||
"rootkeys.init.finished": {
|
"rootkeys.init.finished": {
|
||||||
"en": "Reboot in 5 seconds...\n\n\n",
|
"en": "Rebooting now...\n\n\n",
|
||||||
"zh": "准备重启...\n\n",
|
"zh": "准备重启...\n\n",
|
||||||
"en-audio": "Reboot in 5 seconds."
|
"en-audio": "Rebooting now."
|
||||||
},
|
},
|
||||||
"rootkeys.init.fail_verify": {
|
"rootkeys.init.fail_verify": {
|
||||||
"en": "Verification failed,\naborting!",
|
"en": "Verification failed,\naborting!",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ pub(crate) enum Opcode {
|
||||||
UxGetPolicy,
|
UxGetPolicy,
|
||||||
UxPolicyReturn,
|
UxPolicyReturn,
|
||||||
UxTryReboot,
|
UxTryReboot,
|
||||||
|
UxDoReboot,
|
||||||
/// provision a gateware update with our secret data
|
/// provision a gateware update with our secret data
|
||||||
UxUpdateGateware,
|
UxUpdateGateware,
|
||||||
/// self-sign kernel/loader
|
/// self-sign kernel/loader
|
||||||
|
|
|
||||||
|
|
@ -956,10 +956,12 @@ impl<'a> RootKeys {
|
||||||
self.spinor.set_staging_write_protect(false).expect("couldn't un-protect the staging area");
|
self.spinor.set_staging_write_protect(false).expect("couldn't un-protect the staging area");
|
||||||
|
|
||||||
// finalize the progress bar on exit -- always leave at 100%
|
// finalize the progress bar on exit -- always leave at 100%
|
||||||
pb.update_text(t!("rootkeys.init.finished", xous::LANG));
|
|
||||||
pb.set_percentage(100);
|
pb.set_percentage(100);
|
||||||
|
|
||||||
self.ticktimer.sleep_ms(2000).expect("couldn't show final message");
|
self.ticktimer.sleep_ms(500).expect("couldn't show final message");
|
||||||
|
|
||||||
|
// the stop emoji, when sent to the slider action bar in progress mode, will cause it to close and relinquish focus
|
||||||
|
rootkeys_modal.key_event(['🛑', '\u{0000}', '\u{0000}', '\u{0000}']);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -975,60 +977,86 @@ impl<'a> RootKeys {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "hazardous-debug")]
|
pub fn test(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> {
|
||||||
pub fn test(&mut self) -> bool {
|
let mut progress_action = Slider::new(main_cid, Opcode::UxGutter.to_u32().unwrap(),
|
||||||
let pcache: &mut PasswordCache = unsafe{&mut *(self.pass_cache.as_mut_ptr() as *mut PasswordCache)};
|
0, 100, 10, Some("%"), 0, true, true
|
||||||
|
);
|
||||||
|
progress_action.set_is_password(true);
|
||||||
|
// now show the init wait note...
|
||||||
|
rootkeys_modal.modify(
|
||||||
|
Some(ActionType::Slider(progress_action)),
|
||||||
|
Some(t!("rootkeys.setup_wait", xous::LANG)), false,
|
||||||
|
None, true, None);
|
||||||
|
rootkeys_modal.activate();
|
||||||
|
|
||||||
// setup the local cache
|
xous::yield_slice(); // give some time to the GAM to render
|
||||||
let sensitive_slice = self.sensitive_data.as_slice_mut::<u32>();
|
// capture the progress bar elements in a convenience structure
|
||||||
for addr in 0..256 {
|
let mut pb = ProgressBar::new(rootkeys_modal, &mut progress_action);
|
||||||
self.keyrom.wfo(utra::keyrom::ADDRESS_ADDRESS, addr);
|
|
||||||
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[addr as usize] = self.keyrom.rf(utra::keyrom::DATA_DATA);
|
// kick the progress bar to indicate we've entered the routine
|
||||||
log::info!("{:02x}: 0x{:08x}", addr, self.sensitive_data.borrow_mut().as_slice::<u32>()[addr as usize]);
|
for i in 1..100 {
|
||||||
|
pb.set_percentage(i);
|
||||||
|
self.ticktimer.sleep_ms(50).unwrap();
|
||||||
}
|
}
|
||||||
|
self.ticktimer.sleep_ms(1000).unwrap();
|
||||||
|
// the stop emoji, when sent to the slider action bar in progress mode, will cause it to close and relinquish focus
|
||||||
|
rootkeys_modal.key_event(['🛑', '\u{0000}', '\u{0000}', '\u{0000}']);
|
||||||
|
|
||||||
for (word, key) in sensitive_slice[KeyRomLocs::FPGA_KEY as usize..KeyRomLocs::FPGA_KEY as usize + 256/(size_of::<u32>()*8)].iter()
|
#[cfg(feature = "hazardous-debug")]
|
||||||
.zip(pcache.fpga_key.chunks_mut(4).into_iter()) {
|
{
|
||||||
for (&s, d) in word.to_be_bytes().iter().zip(key.iter_mut()) {
|
let pcache: &mut PasswordCache = unsafe{&mut *(self.pass_cache.as_mut_ptr() as *mut PasswordCache)};
|
||||||
*d = s;
|
|
||||||
|
// setup the local cache
|
||||||
|
let sensitive_slice = self.sensitive_data.as_slice_mut::<u32>();
|
||||||
|
for addr in 0..256 {
|
||||||
|
self.keyrom.wfo(utra::keyrom::ADDRESS_ADDRESS, addr);
|
||||||
|
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[addr as usize] = self.keyrom.rf(utra::keyrom::DATA_DATA);
|
||||||
|
log::info!("{:02x}: 0x{:08x}", addr, self.sensitive_data.borrow_mut().as_slice::<u32>()[addr as usize]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (word, key) in sensitive_slice[KeyRomLocs::FPGA_KEY as usize..KeyRomLocs::FPGA_KEY as usize + 256/(size_of::<u32>()*8)].iter()
|
||||||
|
.zip(pcache.fpga_key.chunks_mut(4).into_iter()) {
|
||||||
|
for (&s, d) in word.to_be_bytes().iter().zip(key.iter_mut()) {
|
||||||
|
*d = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pcache.fpga_key_valid = 1;
|
||||||
|
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[KeyRomLocs::CONFIG as usize] |= keyrom_config::INITIALIZED.ms(1);
|
||||||
|
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x30] = 0xc0de_600d;
|
||||||
|
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x31] = 0x1234_5678;
|
||||||
|
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x32] = 0x8000_0000;
|
||||||
|
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x33] = 0x5555_3333;
|
||||||
|
|
||||||
|
// one time only
|
||||||
|
/*
|
||||||
|
match self.make_gateware_backup(30, 50, progress_modal, progress_action) {
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("got spinor error: {:?}", e);
|
||||||
|
panic!("got spinor error, halting");
|
||||||
|
}
|
||||||
|
_ => ()
|
||||||
|
};*/
|
||||||
|
|
||||||
|
// make the oracles
|
||||||
|
assert!(pcache.fpga_key_valid == 1);
|
||||||
|
// copy from staging
|
||||||
|
let src_oracle = BitstreamOracle::new(&pcache.fpga_key, &pcache.fpga_key, self.staging(), self.staging_base()).unwrap();
|
||||||
|
// write to gateware
|
||||||
|
let dst_oracle = BitstreamOracle::new(&pcache.fpga_key, &pcache.fpga_key, self.gateware(), self.gateware_base()).unwrap();
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
if self.gateware_copy_and_patch(&src_oracle, &dst_oracle, None).is_err() {
|
||||||
|
log::error!("error occured in patch_keys.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.verify_gateware(&dst_oracle, None).is_err() {
|
||||||
|
log::error!("error occurred in gateware verification");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcache.fpga_key_valid = 1;
|
|
||||||
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[KeyRomLocs::CONFIG as usize] |= keyrom_config::INITIALIZED.ms(1);
|
|
||||||
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x30] = 0xc0de_600d;
|
|
||||||
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x31] = 0x1234_5678;
|
|
||||||
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x32] = 0x8000_0000;
|
|
||||||
self.sensitive_data.borrow_mut().as_slice_mut::<u32>()[0x33] = 0x5555_3333;
|
|
||||||
|
|
||||||
// one time only
|
Ok(())
|
||||||
/*
|
|
||||||
match self.make_gateware_backup(30, 50, progress_modal, progress_action) {
|
|
||||||
Err(e) => {
|
|
||||||
log::error!("got spinor error: {:?}", e);
|
|
||||||
panic!("got spinor error, halting");
|
|
||||||
}
|
|
||||||
_ => ()
|
|
||||||
};*/
|
|
||||||
|
|
||||||
// make the oracles
|
|
||||||
assert!(pcache.fpga_key_valid == 1);
|
|
||||||
// copy from staging
|
|
||||||
let src_oracle = BitstreamOracle::new(&pcache.fpga_key, &pcache.fpga_key, self.staging(), self.staging_base()).unwrap();
|
|
||||||
// write to gateware
|
|
||||||
let dst_oracle = BitstreamOracle::new(&pcache.fpga_key, &pcache.fpga_key, self.gateware(), self.gateware_base()).unwrap();
|
|
||||||
|
|
||||||
// TEST
|
|
||||||
if self.gateware_copy_and_patch(&src_oracle, &dst_oracle, None).is_err() {
|
|
||||||
log::error!("error occured in patch_keys.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.verify_gateware(&dst_oracle, None).is_err() {
|
|
||||||
log::error!("error occurred in gateware verification");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// copy data from a source region to a destination region, re-encrypting and patching as we go along.
|
/// copy data from a source region to a destination region, re-encrypting and patching as we go along.
|
||||||
|
|
|
||||||
|
|
@ -33,20 +33,23 @@ mod implementation {
|
||||||
use gam::{ActionType, ProgressBar};
|
use gam::{ActionType, ProgressBar};
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub struct RootKeys {
|
pub struct RootKeys {
|
||||||
password_type: Option<PasswordType>,
|
password_type: Option<PasswordType>,
|
||||||
jtag: jtag::Jtag,
|
jtag: jtag::Jtag,
|
||||||
xns: xous_names::XousNames,
|
xns: xous_names::XousNames,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
impl RootKeys {
|
impl RootKeys {
|
||||||
pub fn new() -> RootKeys {
|
pub fn new() -> RootKeys {
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
let jtag = jtag::Jtag::new(&xns).expect("couldn't connect to jtag server");
|
||||||
RootKeys {
|
RootKeys {
|
||||||
password_type: None,
|
password_type: None,
|
||||||
xns,
|
xns,
|
||||||
// must occupy tihs connection for the system to boot properly
|
// must occupy tihs connection for the system to boot properly
|
||||||
jtag: jtag::Jtag::new(&xns).expect("couldn't connect to jtag server"),
|
jtag,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn suspend(&self) {
|
pub fn suspend(&self) {
|
||||||
|
|
@ -103,7 +106,7 @@ fn xmain() -> ! {
|
||||||
use crate::implementation::RootKeys;
|
use crate::implementation::RootKeys;
|
||||||
|
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
log::set_max_level(log::LevelFilter::Info);
|
log::set_max_level(log::LevelFilter::Debug);
|
||||||
log::info!("my PID is {}", xous::process::id());
|
log::info!("my PID is {}", xous::process::id());
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
|
@ -185,9 +188,10 @@ fn xmain() -> ! {
|
||||||
Opcode::ModalDrop.to_u32().unwrap(),
|
Opcode::ModalDrop.to_u32().unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut reboot_initiated = false;
|
||||||
loop {
|
loop {
|
||||||
let msg = xous::receive_message(keys_sid).unwrap();
|
let msg = xous::receive_message(keys_sid).unwrap();
|
||||||
log::trace!("message: {:?}", msg);
|
log::debug!("message: {:?}", msg);
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(Opcode::SuspendResume) => msg_scalar_unpack!(msg, token, _, _, _, {
|
Some(Opcode::SuspendResume) => msg_scalar_unpack!(msg, token, _, _, _, {
|
||||||
keys.suspend();
|
keys.suspend();
|
||||||
|
|
@ -204,9 +208,16 @@ fn xmain() -> ! {
|
||||||
|
|
||||||
// UX flow opcodes
|
// UX flow opcodes
|
||||||
Some(Opcode::UxTryInitKeys) => msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(Opcode::UxTryInitKeys) => msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if false { // short-circuit for testing subroutines
|
if true { // short-circuit for testing subroutines
|
||||||
#[cfg(feature = "hazardous-debug")]
|
let _success = keys.test(&mut rootkeys_modal, main_cid);
|
||||||
let _success = keys.test();
|
|
||||||
|
keys.finish_key_init();
|
||||||
|
log::info!("going to into reboot arc");
|
||||||
|
send_message(main_cid,
|
||||||
|
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't initiate dialog box");
|
||||||
|
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// overall flow:
|
// overall flow:
|
||||||
// - setup the init
|
// - setup the init
|
||||||
|
|
@ -321,25 +332,17 @@ fn xmain() -> ! {
|
||||||
// this routine will update the rootkeys_modal with the current Ux state
|
// this routine will update the rootkeys_modal with the current Ux state
|
||||||
let result = keys.do_key_init(&mut rootkeys_modal, main_cid);
|
let result = keys.do_key_init(&mut rootkeys_modal, main_cid);
|
||||||
|
|
||||||
// the stop emoji, when sent to the slider action bar in progress mode, will cause it to close and relinquish focus
|
log::info!("set_ux_password result: {:?}", result);
|
||||||
rootkeys_modal.key_event(['🛑', '\u{0000}', '\u{0000}', '\u{0000}']);
|
|
||||||
|
// clear all the state, re-enable suspend/resume
|
||||||
|
keys.finish_key_init();
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
keys.finish_key_init();
|
log::info!("going to into reboot arc");
|
||||||
|
|
||||||
// summon a modal that brings us to a reboot
|
|
||||||
dismiss_modal_action.set_action_opcode(Opcode::UxTryReboot.to_u32().unwrap());
|
|
||||||
rootkeys_modal.modify(
|
|
||||||
Some(ActionType::Notification(dismiss_modal_action)),
|
|
||||||
Some(t!("rootkeys.init.finished", xous::LANG)), false,
|
|
||||||
None, false, None);
|
|
||||||
rootkeys_modal.activate();
|
|
||||||
|
|
||||||
send_message(main_cid,
|
send_message(main_cid,
|
||||||
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)).expect("couldn't initiate dialog box");
|
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't initiate dialog box");
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
Err(RootkeyResult::AlignmentError) => {
|
Err(RootkeyResult::AlignmentError) => {
|
||||||
dismiss_modal_action.set_action_opcode(Opcode::UxGutter.to_u32().unwrap());
|
dismiss_modal_action.set_action_opcode(Opcode::UxGutter.to_u32().unwrap());
|
||||||
|
|
@ -378,9 +381,6 @@ fn xmain() -> ! {
|
||||||
xous::yield_slice();
|
xous::yield_slice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all the state, re-enable suspend/resume
|
|
||||||
keys.finish_key_init();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -388,6 +388,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Opcode::UxTryReboot) => {
|
Some(Opcode::UxTryReboot) => {
|
||||||
|
log::info!("entering reboot handler");
|
||||||
// ensure the boost is off so that the reboot will not fail
|
// ensure the boost is off so that the reboot will not fail
|
||||||
com.set_boost(false).unwrap();
|
com.set_boost(false).unwrap();
|
||||||
llio.boost_on(false).unwrap();
|
llio.boost_on(false).unwrap();
|
||||||
|
|
@ -403,45 +404,47 @@ fn xmain() -> ! {
|
||||||
Some(t!("rootkeys.init.unplug_power", xous::LANG)), false,
|
Some(t!("rootkeys.init.unplug_power", xous::LANG)), false,
|
||||||
None, false, None);
|
None, false, None);
|
||||||
rootkeys_modal.activate();
|
rootkeys_modal.activate();
|
||||||
rootkeys_modal.redraw();
|
|
||||||
xous::yield_slice();
|
|
||||||
ticktimer.sleep_ms(500).unwrap();
|
|
||||||
|
|
||||||
send_message(main_cid,
|
|
||||||
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
|
||||||
).expect("couldn't initiate dialog box");
|
|
||||||
|
|
||||||
log::info!("vbus is high, holding off on reboot");
|
log::info!("vbus is high, holding off on reboot");
|
||||||
} else {
|
} else {
|
||||||
dismiss_modal_action.set_action_opcode(Opcode::UxGutter.to_u32().unwrap());
|
log::info!("initiating reboot");
|
||||||
|
dismiss_modal_action.set_action_opcode(Opcode::UxTryReboot.to_u32().unwrap());
|
||||||
rootkeys_modal.modify(
|
rootkeys_modal.modify(
|
||||||
Some(ActionType::Notification(dismiss_modal_action)),
|
Some(ActionType::Notification(dismiss_modal_action)),
|
||||||
Some(t!("rootkeys.init.finished", xous::LANG)), false,
|
Some(t!("rootkeys.init.finished", xous::LANG)), false,
|
||||||
None, false, None);
|
None, false, None);
|
||||||
|
log::info!("calling activate");
|
||||||
rootkeys_modal.activate();
|
rootkeys_modal.activate();
|
||||||
|
xous::yield_slice(); // these are necessary to get the messages in place to do a full redraw before the reboot happens
|
||||||
rootkeys_modal.redraw();
|
rootkeys_modal.redraw();
|
||||||
xous::yield_slice();
|
xous::yield_slice();
|
||||||
|
log::info!("going to reboot state");
|
||||||
|
send_message(main_cid,
|
||||||
|
xous::Message::new_scalar(Opcode::UxDoReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't initiate dialog box");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(Opcode::UxDoReboot) => {
|
||||||
|
ticktimer.sleep_ms(1500).unwrap();
|
||||||
|
if !reboot_initiated {
|
||||||
// set a wakeup alarm a couple seconds from now -- this is the coldboot
|
// set a wakeup alarm a couple seconds from now -- this is the coldboot
|
||||||
rtc.set_wakeup_alarm(4).unwrap();
|
rtc.set_wakeup_alarm(3).unwrap();
|
||||||
|
|
||||||
// allow EC to snoop, so that it can wake up the system
|
// allow EC to snoop, so that it can wake up the system
|
||||||
llio.allow_ec_snoop(true).unwrap();
|
llio.allow_ec_snoop(true).unwrap();
|
||||||
// allow the EC to power me down
|
// allow the EC to power me down
|
||||||
llio.allow_power_off(true).unwrap();
|
llio.allow_power_off(true).unwrap();
|
||||||
// now send the power off command
|
// now send the power off command
|
||||||
com.power_off_soc().unwrap();
|
com.power_off_soc().unwrap(); // not that at this point, the screen freezes with the last thing displayed...
|
||||||
|
|
||||||
log::info!("reboot in 4 seconds!");
|
log::info!("rebooting now!");
|
||||||
// pause execution, nothing after this should be reachable
|
reboot_initiated = true;
|
||||||
ticktimer.sleep_ms(5000).unwrap();
|
|
||||||
log::info!("if you can read this, reboot failed!");
|
|
||||||
|
|
||||||
// try it again, anyways...
|
|
||||||
send_message(main_cid,
|
|
||||||
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
|
||||||
).expect("couldn't initiate dialog box");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// refresh the message if it goes away
|
||||||
|
send_message(main_cid,
|
||||||
|
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't initiate dialog box");
|
||||||
}
|
}
|
||||||
Some(Opcode::UxUpdateGateware) => {
|
Some(Opcode::UxUpdateGateware) => {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue