reboot -> lock device; disconnect battery -> shutdown

This commit is contained in:
bunnie 2022-10-17 00:19:35 +08:00
parent 3a2b901f49
commit 3bc2860eb0
4 changed files with 69 additions and 44 deletions

View file

@ -278,10 +278,12 @@ perform the Xous firmware upgrade. This requires running manual update commands,
- backups now take about an extra minute to run, due to the inclusion of the extra checksums
- backups are no longer abortable, because in order to do the checksums, we have to unmount the PDDB and put the system into a semi-shutdown state. A confirmation screen now gates backups to avoid users accidentally triggering backups with a fat-fingered menu selection.
## New in 0.9.11
- Various infrastructure fixes contributed by @eupn and @jeandudey
- "Lock device" feature added; PDDB unmount before reboots
- Successive failed PIN attempts will re-suspend the device if it is suspendable
## Roadmap to 1.0
## Roadmap
- Lots of testing and bug fixes
- Understanding what the gap is to get TLS working
- Fixing performance issues in `pddb`
- Refactoring `modals` to not have N^2 space growth with feature set

View file

@ -24,10 +24,10 @@
"en-tts": "Ignore this update"
},
"socup.unmount_fail": {
"ja": "バックアップの準備で PDDB をアンマウントできませんでした。 バックアップが中止されました。",
"en": "Couldn't unmount PDDB in preparation for backup. Backup aborted.",
"zh": "无法卸载 PDDB 以准备备份。 备份中止。",
"en-tts": "Couldn't unmount PDDB in preparation for backup. Backup aborted."
"ja": "PDDB をアンマウントできませんでした。\n操作は中止されました!",
"en": "Couldn't unmount PDDB.\nOperation aborted!",
"zh": "无法卸载 PDDB。\n操作中止!",
"en-tts": "Couldn't unmount PDDB.\nOperation aborted!"
},
"backup.confirm": {
"ja": "PDDB とルート キーのバックアップの準備をしますか?\n\nプロセスは、いったん開始すると中止できません。",
@ -241,10 +241,16 @@
"en-tts": "Keyboard layout submenu"
},
"mainmenu.battery_disconnect": {
"en": "Disconnect battery",
"ja": "バッテリーを外します",
"zh": "断开电池",
"en-tts": "Disconnect battery"
"en": "Shutdown",
"ja": "シャットダウン",
"zh": "关闭",
"en-tts": "Shutdown"
},
"mainmenu.shutdown_confirm": {
"en": "Confirm shutdown:\nDevice will reamin off until a charging cable is plugged in. Proceed?",
"ja": "シャットダウンの確認:\n充電ケーブルが差し込まれるまで、デバイスはオフのままになります。続行しますか?",
"zh": "确认关机:\n设备将保持关闭状态,直到插入充电线。继续?",
"en-tts": "Confirm shutdown:\nDevice will reamin off until a charging cable is plugged in. Proceed?"
},
"mainmenu.reboot": {
"en": "Reboot",
@ -252,6 +258,12 @@
"zh": "重启",
"en-tts": "Reboot"
},
"mainmenu.lockdevice": {
"en": "Lock device",
"ja": "ロック装置",
"zh": "锁定装置",
"en-tts": "Lock device"
},
"mainmenu.prep_backup": {
"en": "Prepare for backup...",
"ja": "バックアップの準備...",
@ -265,10 +277,10 @@
"en-tts": "Close menu"
},
"mainmenu.cant_sleep": {
"en": "Can't sleep while charging",
"en": "Can't power off while charging",
"ja": "充電中は眠れません",
"zh": "充电时睡不着",
"en-tts": "Can't sleep while charging"
"en-tts": "Can't power off while charging"
},
"appmenu.shellchat": {
"en": "Shellchat",

View file

@ -936,23 +936,13 @@ fn wrapped_main() -> ! {
stats_phase = stats_phase.wrapping_add(1);
}
Some(StatusOpcode::Reboot) => {
if ((llio.adc_vbus().unwrap() as u32) * 503) > 150_000 { // 0.005033 * 100_000 against 1.5V * 100_000
// power plugged in, do a reboot using a warm boot method
susres.reboot(true).expect("couldn't issue reboot command");
Some(StatusOpcode::Reboot) => { // this is described as "Lock device" on the menu
let pddb = pddb::Pddb::new();
if !pddb.try_unmount() { // sync the pddb prior to lock
modals.show_notification(t!("socup.unmount_fail", xous::LANG), None).ok();
} else {
// ensure the self-boosting facility is turned off, this interferes with a cold boot
com.set_boost(false).ok();
llio.boost_on(false).ok();
// do a full cold-boot if the power is cut. This will force a re-load of the SoC contents.
gam.shipmode_blank_request().ok();
ticktimer.sleep_ms(500).ok(); // screen redraw time after the blank request
llio.set_wakeup_alarm(4).expect("couldn't set wakeup alarm");
llio.allow_ec_snoop(true).ok();
llio.allow_power_off(true).ok();
com.power_off_soc().ok();
ticktimer.sleep_ms(4000).ok();
panic!("system did not reboot");
pddb.pddb_halt();
susres.reboot(true).expect("couldn't issue reboot command");
}
}
Some(StatusOpcode::SubmenuPddb) => {
@ -1015,16 +1005,37 @@ fn wrapped_main() -> ! {
}
}
},
Some(StatusOpcode::BatteryDisconnect) => {
Some(StatusOpcode::BatteryDisconnect) => { // this is described as "Shutdown" on the menu
if ((llio.adc_vbus().unwrap() as u32) * 503) > 150_000 {
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG), None).expect("couldn't notify that power is plugged in");
} else {
gam.shipmode_blank_request().ok();
ticktimer.sleep_ms(500).unwrap();
llio.allow_ec_snoop(true).unwrap();
llio.allow_power_off(true).unwrap();
com.ship_mode().unwrap();
com.power_off_soc().unwrap();
// show a note to inform the user that you can't turn it on without an external power source...
modals.add_list_item(t!("rootkeys.gwup.yes", xous::LANG)).expect("couldn't build radio item list");
modals.add_list_item(t!("rootkeys.gwup.no", xous::LANG)).expect("couldn't build radio item list");
match modals.get_radiobutton(t!("mainmenu.shutdown_confirm", xous::LANG)) {
Ok(response) => {
if response.as_str() == t!("rootkeys.gwup.yes", xous::LANG) {
{}
} else {
// abort the flow now by returning to the main dispatch handler
continue;
}
}
_ => (),
}
// unmount things before shutting down
let pddb = pddb::Pddb::new();
if !pddb.try_unmount() {
modals.show_notification(t!("socup.unmount_fail", xous::LANG), None).ok();
} else {
pddb.pddb_halt();
gam.shipmode_blank_request().ok();
ticktimer.sleep_ms(500).unwrap();
llio.allow_ec_snoop(true).unwrap();
llio.allow_power_off(true).unwrap();
com.ship_mode().unwrap();
com.power_off_soc().unwrap();
}
}
},

View file

@ -117,14 +117,6 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, menu_management_sid: xous::S
});
}
menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.reboot", xous::LANG)),
action_conn: Some(status_conn),
action_opcode: StatusOpcode::Reboot.to_u32().unwrap(),
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
close_on_select: true,
});
menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.pddb", xous::LANG)),
action_conn: Some(status_conn),
@ -149,6 +141,14 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, menu_management_sid: xous::S
close_on_select: true,
});
menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.lockdevice", xous::LANG)),
action_conn: Some(status_conn),
action_opcode: StatusOpcode::Reboot.to_u32().unwrap(),
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
close_on_select: true,
});
if key_init {
menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.prep_backup", xous::LANG)),