minor fixes in the autoupdate flow

- do not try to create root keys if we just did an SoC update.
that's just too many things going on, we should definitely force
a clean reboot first.

- add a clean reboot step after a no-key soc update

- try to switch USB debug mode on if a backup was created
This commit is contained in:
bunnie 2022-07-14 19:26:09 +08:00
parent f7dcbe0ab0
commit abade9e1af
4 changed files with 10 additions and 1 deletions

1
Cargo.lock generated
View file

@ -2891,6 +2891,7 @@ dependencies = [
"ticktimer-server", "ticktimer-server",
"trng", "trng",
"tts-frontend", "tts-frontend",
"usb-device-xous",
"utralib", "utralib",
"xous", "xous",
"xous-ipc 0.9.7", "xous-ipc 0.9.7",

View file

@ -48,6 +48,7 @@ tts-frontend = {path="../tts"}
# aes-gcm-siv = {version = "0.11.0-pre", default-features = false, features = ["alloc"]} # aes-gcm-siv = {version = "0.11.0-pre", default-features = false, features = ["alloc"]}
aes-gcm-siv = {git="https://github.com/RustCrypto/AEADs.git", branch="master"} aes-gcm-siv = {git="https://github.com/RustCrypto/AEADs.git", branch="master"}
subtle = {version = "2.4.1", default-features = false} subtle = {version = "2.4.1", default-features = false}
usb-device-xous = {path="../usb-device-xous"}
# private keys # private keys
#sha2 = {version = "0.9.5", default-features = false, features = []} #sha2 = {version = "0.9.5", default-features = false, features = []}

View file

@ -1278,6 +1278,10 @@ fn main() -> ! {
}), }),
Some(Opcode::TryNoKeySocUpdate) => msg_blocking_scalar_unpack!(msg, _, _, _, _, { Some(Opcode::TryNoKeySocUpdate) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
if keys.try_nokey_soc_update(&mut rootkeys_modal, main_cid) { if keys.try_nokey_soc_update(&mut rootkeys_modal, main_cid) {
// this will unblock the status thread, but also pop up our reboot flow
send_message(main_cid,
xous::Message::new_scalar(Opcode::UxTryReboot.to_usize().unwrap(), 0, 0, 0, 0)
).expect("couldn't initiate dialog box");
xous::return_scalar(msg.sender, 1).unwrap(); xous::return_scalar(msg.sender, 1).unwrap();
} else { } else {
xous::return_scalar(msg.sender, 0).unwrap(); xous::return_scalar(msg.sender, 0).unwrap();
@ -1377,6 +1381,9 @@ fn main() -> ! {
// this final statement has a take/unwrap to set backup_header back to None // this final statement has a take/unwrap to set backup_header back to None
match keys.write_backup(backup_header.take().unwrap(), backup_ct) { match keys.write_backup(backup_header.take().unwrap(), backup_ct) {
Ok(_) => { Ok(_) => {
let usbd = usb_device_xous::UsbHid::new();
usbd.switch_to_core(usb_device_xous::UsbDeviceType::Debug).unwrap();
usbd.debug_usb(Some(false)).unwrap();
modals.show_notification(t!("rootkeys.backup_staged", xous::LANG), Some("https://github.com/betrusted-io/betrusted-wiki/wiki/Backups")).ok(); modals.show_notification(t!("rootkeys.backup_staged", xous::LANG), Some("https://github.com/betrusted-io/betrusted-wiki/wiki/Backups")).ok();
} }
Err(_) => { Err(_) => {

View file

@ -473,7 +473,7 @@ fn wrapped_main() -> ! {
}); });
if let Some(staged) = staged_sv { if let Some(staged) = staged_sv {
let soc = llio.soc_gitrev().expect("error querying SoC gitrev; this is fatal"); let soc = llio.soc_gitrev().expect("error querying SoC gitrev; this is fatal");
if staged > soc { if (staged > soc) && !soc_updated { // if the soc was updated, we should reboot before we try this
if keys.lock().unwrap().prompt_for_update() { if keys.lock().unwrap().prompt_for_update() {
// prompt to apply the update // prompt to apply the update
modals.add_list_item(t!("rootkeys.gwup.yes", xous::LANG)).expect("couldn't build radio item list"); modals.add_list_item(t!("rootkeys.gwup.yes", xous::LANG)).expect("couldn't build radio item list");