From fb3dabbd5dd1449615a79f82a694682228ea216e Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 9 Mar 2023 04:45:26 +0800 Subject: [PATCH] fix #326 - add some ux lag - checks link integrity previous commit also revises message on precursorupdater per @nworbnhoj's comments. --- services/status/locales/i18n.json | 15 +++++++++++---- services/status/src/ecup.rs | 18 +++++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/services/status/locales/i18n.json b/services/status/locales/i18n.json index 5f1fc22e1..93931801d 100644 --- a/services/status/locales/i18n.json +++ b/services/status/locales/i18n.json @@ -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": "写作..." diff --git a/services/status/src/ecup.rs b/services/status/src/ecup.rs index 59ddc5115..d7afd1431 100644 --- a/services/status/src/ecup.rs +++ b/services/status/src/ecup.rs @@ -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);