From ee22ff783c43f912cad88d599085e2ac06f885e8 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 11 May 2025 12:32:05 +0800 Subject: [PATCH] incorporate arch migrations to status --- services/status/Cargo.toml | 1 + services/status/src/ecup.rs | 40 ++++++++++++------------------------- services/status/src/main.rs | 11 +++++----- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/services/status/Cargo.toml b/services/status/Cargo.toml index e69a753fb..0f22b7f13 100644 --- a/services/status/Cargo.toml +++ b/services/status/Cargo.toml @@ -33,6 +33,7 @@ userprefs = { path = "../../libs/userprefs" } dns = { path = "../dns" } early_settings = { path = "../early_settings" } blitstr2 = { path = "../../libs/blitstr2" } +precursor-hal = { path = "../../libs/precursor-hal" } num-derive = { version = "0.4.2", default-features = false } num-traits = { version = "0.2.14", default-features = false } diff --git a/services/status/src/ecup.rs b/services/status/src/ecup.rs index f32a7d39b..8dcb14c92 100644 --- a/services/status/src/ecup.rs +++ b/services/status/src/ecup.rs @@ -3,6 +3,7 @@ use std::convert::TryInto; use locales::t; use modals::Modals; use num_traits::*; +use precursor_hal::board::*; use sha2::Digest; use xous::msg_blocking_scalar_unpack; use xous_semver::SemVer; @@ -60,17 +61,17 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { #[cfg(any(feature = "precursor", feature = "renode"))] let ec_package = xous::syscall::map_memory( - xous::MemoryAddress::new((xous::EC_FW_PKG_LOC + xous::FLASH_PHYS_BASE) as usize), + xous::MemoryAddress::new((EC_FW_PKG_LOC + FLASH_PHYS_BASE) as usize), None, - xous::EC_FW_PKG_LEN as usize, + EC_FW_PKG_LEN as usize, xous::MemoryFlags::R | xous::MemoryFlags::W, ) .expect("couldn't map EC firmware package memory range"); #[cfg(any(feature = "precursor", feature = "renode"))] let wf_package = xous::syscall::map_memory( - xous::MemoryAddress::new((xous::EC_WF200_PKG_LOC + xous::FLASH_PHYS_BASE) as usize), + xous::MemoryAddress::new((EC_WF200_PKG_LOC + FLASH_PHYS_BASE) as usize), None, - xous::EC_WF200_PKG_LEN as usize, + EC_WF200_PKG_LEN as usize, xous::MemoryFlags::R | xous::MemoryFlags::W, ) .expect("couldn't map EC wf200 package memory range"); @@ -78,7 +79,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { let mut ec_package = xous::syscall::map_memory( None, None, - xous::EC_FW_PKG_LEN as usize, + EC_FW_PKG_LEN as usize, xous::MemoryFlags::R | xous::MemoryFlags::W, ) .expect("couldn't map EC firmware package memory range"); @@ -90,7 +91,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { let mut wf_package = xous::syscall::map_memory( None, None, - xous::EC_WF200_PKG_LEN as usize, + EC_WF200_PKG_LEN as usize, xous::MemoryFlags::R | xous::MemoryFlags::W, ) .expect("couldn't map EC wf200 package memory range"); @@ -107,10 +108,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { Some(UpdateOp::UpdateGateware) => { // blocking scalar let package = unsafe { - core::slice::from_raw_parts( - ec_package.as_ptr() as *const u8, - xous::EC_FW_PKG_LEN as usize, - ) + core::slice::from_raw_parts(ec_package.as_ptr() as *const u8, EC_FW_PKG_LEN as usize) }; if !validate_package(package, PackageType::Ec) { log::error!("firmware package did not pass validation"); @@ -142,10 +140,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { Some(UpdateOp::UpdateFirmware) => { // blocking scalar let package = unsafe { - core::slice::from_raw_parts( - ec_package.as_ptr() as *const u8, - xous::EC_FW_PKG_LEN as usize, - ) + core::slice::from_raw_parts(ec_package.as_ptr() as *const u8, EC_FW_PKG_LEN as usize) }; if !validate_package(package, PackageType::Ec) { log::error!("firmware package did not pass validation"); @@ -184,10 +179,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { Some(UpdateOp::UpdateWf200) => { // blocking scalar let package = unsafe { - core::slice::from_raw_parts( - wf_package.as_ptr() as *const u8, - xous::EC_WF200_PKG_LEN as usize, - ) + core::slice::from_raw_parts(wf_package.as_ptr() as *const u8, EC_WF200_PKG_LEN as usize) }; if validate_package(package, PackageType::Wf200) { log::info!("updating Wf200"); @@ -281,17 +273,14 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { let mut did_something = false; let package = unsafe { - core::slice::from_raw_parts( - ec_package.as_ptr() as *const u8, - xous::EC_FW_PKG_LEN as usize, - ) + core::slice::from_raw_parts(ec_package.as_ptr() as *const u8, EC_FW_PKG_LEN as usize) }; // the semver *could* be bogus at this point, but we'll validate the package (which contains // the semver) before we use it. however, this check is much less // computationally expensive than the package validation. let length = u32::from_le_bytes(package[0x28..0x2c].try_into().unwrap()); - if length > xous::EC_FW_PKG_LEN { + if length > EC_FW_PKG_LEN { // nothing was staged, or it is bogus (blank FLASH is 0xFFFF_FFFF "length") // only show the warning if the update was forced; otherwise we shouldn't show the warning // because it'll pop up every time on a new unit @@ -409,10 +398,7 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) { } let package = unsafe { - core::slice::from_raw_parts( - wf_package.as_ptr() as *const u8, - xous::EC_WF200_PKG_LEN as usize, - ) + core::slice::from_raw_parts(wf_package.as_ptr() as *const u8, EC_WF200_PKG_LEN as usize) }; let mut run_wf200_update = false; // check to see if we need to do an update. For the WF200, we can only say if the hash is diff --git a/services/status/src/main.rs b/services/status/src/main.rs index fdb4f9c9c..45517959d 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -27,6 +27,7 @@ use gam::{GamObjectList, GamObjectType}; use keystore_api::*; use locales::t; use num_traits::*; +use precursor_hal::board::*; use ux_api::minigfx::*; use ux_api::service::api::*; use xous::{CID, Message, msg_scalar_unpack, send_message}; @@ -1448,7 +1449,7 @@ fn wrapped_main() -> ! { } #[cfg(feature = "efuse")] Some(StatusOpcode::BurnBackupKey) => { - log::info!("{}BURNKEY.TYPE,{}", xous::BOOKEND_START, xous::BOOKEND_END); + log::info!("{}BURNKEY.TYPE,{}", BOOKEND_START, BOOKEND_END); thread::spawn({ let keys = keys.clone(); move || { @@ -1467,14 +1468,14 @@ fn wrapped_main() -> ! { Ok(response) => { if response.as_str() == t!("burnkey.bbram", locales::LANG) { // do BBRAM flow - log::info!("{}BBRAM.CONFIRM,{}", xous::BOOKEND_START, xous::BOOKEND_END); + log::info!("{}BBRAM.CONFIRM,{}", BOOKEND_START, BOOKEND_END); // punts to a script-driven flow on the pi modals.show_notification( t!("burnkey.bbram_exec", locales::LANG), Some("https://github.com/betrusted-io/betrusted-wiki/wiki/FAQ:-FPGA-AES-Encryption-Key-(eFuse-BBRAM)"), ).ok(); } else if response.as_str() == t!("burnkey.efuse", locales::LANG) { - log::info!("{}EFUSE.CONFIRM,{}", xous::BOOKEND_START, xous::BOOKEND_END); + log::info!("{}EFUSE.CONFIRM,{}", BOOKEND_START, BOOKEND_END); // do eFuse flow modals .add_list_item(t!("rootkeys.gwup.yes", locales::LANG)) @@ -1514,7 +1515,7 @@ fn wrapped_main() -> ! { modals .add_list_item(t!("rootkeys.gwup.no", locales::LANG)) .expect("couldn't build radio item list"); - log::info!("{}BACKUP.CONFIRM,{}", xous::BOOKEND_START, xous::BOOKEND_END); + log::info!("{}BACKUP.CONFIRM,{}", BOOKEND_START, BOOKEND_END); match modals.get_radiobutton(t!("backup.confirm", locales::LANG)) { Ok(response) => { if response.as_str() == t!("rootkeys.gwup.yes", locales::LANG) { @@ -1573,7 +1574,7 @@ fn wrapped_main() -> ! { pddb.pddb_halt(); // now trigger phase 2 of the backup - log::info!("{}BACKUP.PHASE2,{}", xous::BOOKEND_START, xous::BOOKEND_END); + log::info!("{}BACKUP.PHASE2,{}", BOOKEND_START, BOOKEND_END); send_message( cb_cid, Message::new_scalar(