mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
clean up bitrot in dbg-ecupdate configuration
This commit is contained in:
parent
69cf629329
commit
5a0e3e5c19
2 changed files with 53 additions and 39 deletions
|
|
@ -17,7 +17,7 @@ impl<'a> ShellCmdApi<'a> for EcUpdate {
|
|||
|
||||
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||
let mut ret = String::<1024>::new();
|
||||
let helpstring = "ecup [gw] [fw] [wf200] [reset] [auto]";
|
||||
let helpstring = "ecup [gw] [fw] [wf200] [auto]";
|
||||
|
||||
log::debug!("ecup handling {}", args.as_str().unwrap());
|
||||
let mut tokens = args.as_str().unwrap().split(' ');
|
||||
|
|
@ -26,41 +26,45 @@ impl<'a> ShellCmdApi<'a> for EcUpdate {
|
|||
if let Some(sub_cmd) = tokens.next() {
|
||||
match sub_cmd {
|
||||
"fw" => {
|
||||
xous::send_message(ecup_conn,
|
||||
let result = xous::send_message(ecup_conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
1, // hard coded to match UpdateOp
|
||||
0, 0, 0, 0
|
||||
)
|
||||
).unwrap();
|
||||
write!(ret, "Starting EC firmware update").unwrap();
|
||||
env.ticktimer.sleep_ms(200).unwrap();
|
||||
write!(ret, "EC firmware update: {:?}", result).unwrap();
|
||||
}
|
||||
"gw" => {
|
||||
xous::send_message(ecup_conn,
|
||||
let result = xous::send_message(ecup_conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
0, // hard coded to match UpdateOp
|
||||
0, 0, 0, 0
|
||||
)
|
||||
).unwrap();
|
||||
write!(ret, "Starting EC gateware update").unwrap();
|
||||
env.ticktimer.sleep_ms(200).unwrap();
|
||||
write!(ret, "EC gateware update: {:?}", result).unwrap();
|
||||
}
|
||||
// note: "reset" has been moved to `ver ecreset`
|
||||
"wf200" => {
|
||||
xous::send_message(ecup_conn,
|
||||
let result = xous::send_message(ecup_conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
2, // hard coded to match UpdateOp
|
||||
0, 0, 0, 0
|
||||
)
|
||||
).unwrap();
|
||||
write!(ret, "Starting EC wf200 update").unwrap();
|
||||
env.ticktimer.sleep_ms(200).unwrap();
|
||||
write!(ret, "EC wf200 update: {:?}", result).unwrap();
|
||||
}
|
||||
"auto" => {
|
||||
xous::send_message(ecup_conn,
|
||||
let result = xous::send_message(ecup_conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
3, // hard coded to match UpdateOp
|
||||
0, 0, 0, 0
|
||||
)
|
||||
).unwrap();
|
||||
write!(ret, "Starting full EC firmware update").unwrap();
|
||||
env.ticktimer.sleep_ms(200).unwrap();
|
||||
write!(ret, "Full EC firmware update: {:?}", result).unwrap();
|
||||
}
|
||||
_ => {
|
||||
write!(ret, "{}", helpstring).unwrap();
|
||||
|
|
|
|||
|
|
@ -97,65 +97,75 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
|
|||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
#[cfg(feature="dbg-ecupdate")]
|
||||
Some(UpdateOp::UpdateGateware) => { // blocking scalar
|
||||
netmgr.connection_manager_stop().unwrap();
|
||||
com.wlan_leave().ok();
|
||||
ticktimer.sleep_ms(4000).unwrap(); // give a few seconds for any packets/updates to clear so we don't tigger panics as the EC is about to disappear...
|
||||
|
||||
let package = unsafe{ core::slice::from_raw_parts(ec_package.as_ptr() as *const u8, xous::EC_FW_PKG_LEN as usize)};
|
||||
if !validate_package(package,PackageType::Ec) {
|
||||
log::error!("firmware package did not pass validation");
|
||||
modals.show_notification(
|
||||
&format!("{} gateware", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
||||
} else {
|
||||
log::info!("updating GW");
|
||||
netmgr.connection_manager_stop().ok();
|
||||
llio.com_event_enable(false).ok();
|
||||
susres.set_suspendable(false).unwrap(); // block suspend/resume operations
|
||||
do_update(&mut com, &modals, package, CTRL_PAGE_LEN, EC_GATEWARE_BASE, EC_GATEWARE_LEN, "gateware");
|
||||
if !do_update(&mut com, &modals, package, CTRL_PAGE_LEN, EC_GATEWARE_BASE,
|
||||
EC_GATEWARE_LEN,
|
||||
"gateware") {
|
||||
xous::return_scalar(msg.sender, UpdateResult::Abort.to_usize().unwrap()).unwrap();
|
||||
continue;
|
||||
}
|
||||
susres.set_suspendable(true).unwrap(); // resume suspend/resume operations
|
||||
}
|
||||
xous::return_scalar(msg.sender, 0).unwrap();
|
||||
},
|
||||
#[cfg(feature="dbg-ecupdate")]
|
||||
Some(UpdateOp::UpdateFirmware) => { // blocking scalar
|
||||
netmgr.connection_manager_stop().unwrap();
|
||||
com.wlan_leave().ok();
|
||||
ticktimer.sleep_ms(4000).unwrap(); // give a few seconds for any packets/updates to clear so we don't tigger panics as the EC is about to disappear...
|
||||
|
||||
let package = unsafe{ core::slice::from_raw_parts(ec_package.as_ptr() as *const u8, xous::EC_FW_PKG_LEN as usize)};
|
||||
let mut temp: [u8; 4] = Default::default();
|
||||
temp.copy_from_slice(&package[0x28..0x2c]);
|
||||
let length = u32::from_le_bytes(temp); // total length of package
|
||||
|
||||
if !validate_package(package,PackageType::Ec) {
|
||||
log::error!("firmware package did not pass validation");
|
||||
modals.show_notification(
|
||||
&format!("{} firmware", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
||||
} else {
|
||||
let length = u32::from_le_bytes(package[0x28..0x2c].try_into().unwrap());
|
||||
if length == 0xffff_ffff { // nothing was staged at all
|
||||
xous::return_scalar(msg.sender, UpdateResult::PackageInvalid.to_usize().unwrap()).unwrap();
|
||||
continue;
|
||||
}
|
||||
log::info!("updating FW");
|
||||
netmgr.connection_manager_stop().unwrap();
|
||||
llio.com_event_enable(false).ok();
|
||||
susres.set_suspendable(false).unwrap(); // block suspend/resume operations
|
||||
do_update(&mut com, &modals, package, EC_GATEWARE_LEN + CTRL_PAGE_LEN,
|
||||
EC_FIRMWARE_BASE, length - (EC_GATEWARE_LEN), "firmware");
|
||||
if !do_update(&mut com, &modals, package, EC_GATEWARE_LEN + CTRL_PAGE_LEN,
|
||||
EC_FIRMWARE_BASE, length - (EC_GATEWARE_LEN),
|
||||
"firmware") {
|
||||
xous::return_scalar(msg.sender, UpdateResult::Abort.to_usize().unwrap()).unwrap();
|
||||
continue;
|
||||
}
|
||||
susres.set_suspendable(true).unwrap(); // resume suspend/resume operations
|
||||
}
|
||||
xous::return_scalar(msg.sender, 0).unwrap();
|
||||
},
|
||||
#[cfg(feature="dbg-ecupdate")]
|
||||
Some(UpdateOp::UpdateWf200) => { // blocking scalar
|
||||
netmgr.connection_manager_stop().unwrap();
|
||||
com.wlan_leave().ok();
|
||||
ticktimer.sleep_ms(4000).unwrap(); // give a few seconds for any packets/updates to clear so we don't tigger panics as the EC is about to disappear...
|
||||
|
||||
let package = unsafe{ core::slice::from_raw_parts(wf_package.as_ptr() as *const u8, xous::EC_WF200_PKG_LEN as usize)};
|
||||
let mut temp: [u8; 4] = Default::default();
|
||||
temp.copy_from_slice(&package[0x28..0x2c]);
|
||||
let length = u32::from_le_bytes(temp); // total length of package
|
||||
|
||||
if !validate_package(package,PackageType::Wf200) {
|
||||
log::error!("WF200 firmware package did not pass validation");
|
||||
modals.show_notification(
|
||||
&format!("{} wf200", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
||||
} else {
|
||||
if validate_package(package,PackageType::Wf200) {
|
||||
log::info!("updating Wf200");
|
||||
netmgr.connection_manager_stop().unwrap();
|
||||
llio.com_event_enable(false).ok();
|
||||
let length = u32::from_le_bytes(package[0x28..0x2c].try_into().unwrap());
|
||||
susres.set_suspendable(false).unwrap(); // block suspend/resume operations
|
||||
do_update(&mut com, &modals, package, CTRL_PAGE_LEN,
|
||||
WF200_FIRMWARE_BASE, length, "wf200");
|
||||
if !do_update(&mut com, &modals, package, CTRL_PAGE_LEN,
|
||||
WF200_FIRMWARE_BASE, length,
|
||||
"WF200") {
|
||||
xous::return_scalar(msg.sender, UpdateResult::Abort.to_usize().unwrap()).unwrap();
|
||||
continue;
|
||||
}
|
||||
susres.set_suspendable(true).unwrap(); // resume suspend/resume operations
|
||||
} else {
|
||||
log::error!("wf200 package did not pass validation");
|
||||
modals.show_notification(
|
||||
&format!("{} WF200", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
||||
xous::return_scalar(msg.sender, UpdateResult::PackageInvalid.to_usize().unwrap()).unwrap();
|
||||
continue;
|
||||
}
|
||||
|
||||
xous::return_scalar(msg.sender, 0).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue