- add some ux lag
- checks link integrity

previous commit also revises message on precursorupdater
per @nworbnhoj's comments.
This commit is contained in:
bunnie 2023-03-09 04:45:26 +08:00
parent b68e7cb03a
commit fb3dabbd5d
2 changed files with 28 additions and 5 deletions

View file

@ -63,8 +63,8 @@
"zh": "更新因错误而中止!(EC)"
},
"ecup.erasing": {
"en": "EC Autoupdate\n\nErasing",
"en-tts": "EC Autoupdate\n\nErasing",
"en": "EC Autoupdate. Do not reset!\n\nErasing",
"en-tts": "EC Autoupdate. Do not reset!\n\nErasing",
"fr": "EC mise à jour automatique\n\nEffacement",
"ja": "消去...",
"zh": "擦除..."
@ -76,6 +76,13 @@
"ja": "ECファームウェアパッケージが破損しているか無効です: ",
"zh": "固件包已损坏或无效: "
},
"ecup.preparing": {
"en": "EC Updating. Do not reset or power off!",
"en-tts": "EC Updating. Do not reset or power off!",
"fr": "Mise à jour EC. Ne réinitialisez pas et ne mettez pas hors tension ! *MT*",
"ja": "EC firmware package is corrupted or invalid: ",
"zh": "EC 更新中。 不要复位或关闭电源!"
},
"ecup.resetting": {
"en": "Resetting EC...",
"en-tts": "Resetting EC...",
@ -91,8 +98,8 @@
"zh": "已应用 USB 加载更新."
},
"ecup.writing": {
"en": "EC Autoupdate\n\nWriting",
"en-tts": "EC Autoupdate\n\nWriting",
"en": "EC Autoupdate. Do not reset!\n\nWriting",
"en-tts": "EC Autoupdate. Do not reset!\n\nWriting",
"fr": "EC mise à jour automatique\n\nÉcriture",
"ja": "書き込み...",
"zh": "写作..."

View file

@ -375,12 +375,28 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
/// copies an image stored in a `package` slice, starting from `pkg_offset` in the `package` with length `len`
/// and writing to FLASH starting at a hardware offset of `flash_start`
fn do_update(com: &mut com::Com, modals: &Modals, package: &[u8], pkg_offset: u32, flash_start: u32, image_len: u32, name: &str) -> bool {
let tt = ticktimer_server::Ticktimer::new().unwrap();
// grab an uptime measurement from the EC
let ut = com.get_ec_uptime().unwrap();
// pop up a dialog box to warn users, in case they are in the process of resetting the device
modals.dynamic_notification(Some(
&format!("{}", t!("ecup.preparing", xous::LANG))
), None).unwrap();
tt.sleep_ms(3000).ok();
// check the uptime again as a very basic link-up check
// (usually the link is either stuck at 0, 0xffff, or 0xdddd if the EC is misbehaving)
let ut_after = com.get_ec_uptime().unwrap();
if ut_after <= ut || (ut_after - ut) > 5000 {
log::error!("EC link is not stable, aborting update");
return false;
}
if (pkg_offset + image_len) > package.len() as u32 {
log::error!("Requested image is larger than the package length");
return false;
}
// erase
modals.dynamic_notification(Some(
modals.dynamic_notification_update(Some(
&format!("{}\n({})", t!("ecup.erasing", xous::LANG), name)
), None).unwrap();
log::info!("{}, erasing from 0x{:08x}, 0x{:x} bytes", name, flash_start, image_len);