add a magic word check to the wf200 routine

avoids running an update if nothing is staged at all.
This commit is contained in:
bunnie 2022-07-12 03:31:54 +08:00
parent fa21e01b94
commit 941d72f3c5

View file

@ -281,16 +281,18 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
} }
_ => {} _ => {}
} }
// NOTE: this means we *always* assume there is a staged WF200 update, even if it didn't // do a shallow check to see if the firmware magic word 'KEYS' is in the location. The intention is that we would
// change from the previous revision -- otherwise a "PackageInvalid" error will be thrown. // not even try to run the update if nothing valid has been staged and the location would read as 0xFFFFFFFF.
// so the USB updater script should always copy over the WF200 package whenever there's an EC update, if package[CTRL_PAGE_LEN as usize..CTRL_PAGE_LEN as usize + 4] == [0x4b, 0x45, 0x59, 0x53] {
// because we must have it in order to make sure the version on the device is in sync with the intended version.
if package[CTRL_PAGE_LEN as usize..CTRL_PAGE_LEN as usize + WF200_HASH_LEN] != ver_wf200_raw[..WF200_HASH_LEN] { if package[CTRL_PAGE_LEN as usize..CTRL_PAGE_LEN as usize + WF200_HASH_LEN] != ver_wf200_raw[..WF200_HASH_LEN] {
run_wf200_update = true; run_wf200_update = true;
log::info!("wf200 rev is different"); log::info!("wf200 rev is different");
log::info!("package : {:x?}", &package[CTRL_PAGE_LEN as usize..CTRL_PAGE_LEN as usize + WF200_HASH_LEN]); log::info!("package : {:x?}", &package[CTRL_PAGE_LEN as usize..CTRL_PAGE_LEN as usize + WF200_HASH_LEN]);
log::info!("readback: {:x?}", &ver_wf200_raw[..WF200_HASH_LEN]); log::info!("readback: {:x?}", &ver_wf200_raw[..WF200_HASH_LEN]);
} }
} else {
log::warn!("Staged WF200 magic number is incorrect, refusing to perform any updates");
}
} else { } else {
// ancient version of EC, must run all the updates if any update was run before on the GW // ancient version of EC, must run all the updates if any update was run before on the GW
run_wf200_update = did_something; run_wf200_update = did_something;