mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +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> {
|
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||||
let mut ret = String::<1024>::new();
|
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());
|
log::debug!("ecup handling {}", args.as_str().unwrap());
|
||||||
let mut tokens = args.as_str().unwrap().split(' ');
|
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() {
|
if let Some(sub_cmd) = tokens.next() {
|
||||||
match sub_cmd {
|
match sub_cmd {
|
||||||
"fw" => {
|
"fw" => {
|
||||||
xous::send_message(ecup_conn,
|
let result = xous::send_message(ecup_conn,
|
||||||
xous::Message::new_blocking_scalar(
|
xous::Message::new_blocking_scalar(
|
||||||
1, // hard coded to match UpdateOp
|
1, // hard coded to match UpdateOp
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
)
|
)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
write!(ret, "Starting EC firmware update").unwrap();
|
env.ticktimer.sleep_ms(200).unwrap();
|
||||||
|
write!(ret, "EC firmware update: {:?}", result).unwrap();
|
||||||
}
|
}
|
||||||
"gw" => {
|
"gw" => {
|
||||||
xous::send_message(ecup_conn,
|
let result = xous::send_message(ecup_conn,
|
||||||
xous::Message::new_blocking_scalar(
|
xous::Message::new_blocking_scalar(
|
||||||
0, // hard coded to match UpdateOp
|
0, // hard coded to match UpdateOp
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
)
|
)
|
||||||
).unwrap();
|
).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`
|
// note: "reset" has been moved to `ver ecreset`
|
||||||
"wf200" => {
|
"wf200" => {
|
||||||
xous::send_message(ecup_conn,
|
let result = xous::send_message(ecup_conn,
|
||||||
xous::Message::new_blocking_scalar(
|
xous::Message::new_blocking_scalar(
|
||||||
2, // hard coded to match UpdateOp
|
2, // hard coded to match UpdateOp
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
)
|
)
|
||||||
).unwrap();
|
).unwrap();
|
||||||
write!(ret, "Starting EC wf200 update").unwrap();
|
env.ticktimer.sleep_ms(200).unwrap();
|
||||||
|
write!(ret, "EC wf200 update: {:?}", result).unwrap();
|
||||||
}
|
}
|
||||||
"auto" => {
|
"auto" => {
|
||||||
xous::send_message(ecup_conn,
|
let result = xous::send_message(ecup_conn,
|
||||||
xous::Message::new_blocking_scalar(
|
xous::Message::new_blocking_scalar(
|
||||||
3, // hard coded to match UpdateOp
|
3, // hard coded to match UpdateOp
|
||||||
0, 0, 0, 0
|
0, 0, 0, 0
|
||||||
)
|
)
|
||||||
).unwrap();
|
).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();
|
write!(ret, "{}", helpstring).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -97,65 +97,75 @@ pub(crate) fn ecupdate_thread(sid: xous::SID) {
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
#[cfg(feature="dbg-ecupdate")]
|
#[cfg(feature="dbg-ecupdate")]
|
||||||
Some(UpdateOp::UpdateGateware) => { // blocking scalar
|
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)};
|
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) {
|
if !validate_package(package,PackageType::Ec) {
|
||||||
log::error!("firmware package did not pass validation");
|
log::error!("firmware package did not pass validation");
|
||||||
modals.show_notification(
|
modals.show_notification(
|
||||||
&format!("{} gateware", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
&format!("{} gateware", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
||||||
} else {
|
} 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
|
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
|
susres.set_suspendable(true).unwrap(); // resume suspend/resume operations
|
||||||
}
|
}
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
},
|
},
|
||||||
#[cfg(feature="dbg-ecupdate")]
|
#[cfg(feature="dbg-ecupdate")]
|
||||||
Some(UpdateOp::UpdateFirmware) => { // blocking scalar
|
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 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) {
|
if !validate_package(package,PackageType::Ec) {
|
||||||
log::error!("firmware package did not pass validation");
|
log::error!("firmware package did not pass validation");
|
||||||
modals.show_notification(
|
modals.show_notification(
|
||||||
&format!("{} firmware", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
&format!("{} firmware", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
||||||
} else {
|
} 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
|
susres.set_suspendable(false).unwrap(); // block suspend/resume operations
|
||||||
do_update(&mut com, &modals, package, EC_GATEWARE_LEN + CTRL_PAGE_LEN,
|
if !do_update(&mut com, &modals, package, EC_GATEWARE_LEN + CTRL_PAGE_LEN,
|
||||||
EC_FIRMWARE_BASE, length - (EC_GATEWARE_LEN), "firmware");
|
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
|
susres.set_suspendable(true).unwrap(); // resume suspend/resume operations
|
||||||
}
|
}
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
},
|
},
|
||||||
#[cfg(feature="dbg-ecupdate")]
|
#[cfg(feature="dbg-ecupdate")]
|
||||||
Some(UpdateOp::UpdateWf200) => { // blocking scalar
|
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 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();
|
if validate_package(package,PackageType::Wf200) {
|
||||||
temp.copy_from_slice(&package[0x28..0x2c]);
|
log::info!("updating Wf200");
|
||||||
let length = u32::from_le_bytes(temp); // total length of package
|
netmgr.connection_manager_stop().unwrap();
|
||||||
|
llio.com_event_enable(false).ok();
|
||||||
if !validate_package(package,PackageType::Wf200) {
|
let length = u32::from_le_bytes(package[0x28..0x2c].try_into().unwrap());
|
||||||
log::error!("WF200 firmware package did not pass validation");
|
|
||||||
modals.show_notification(
|
|
||||||
&format!("{} wf200", t!("ecup.invalid", xous::LANG)), None).unwrap();
|
|
||||||
} else {
|
|
||||||
susres.set_suspendable(false).unwrap(); // block suspend/resume operations
|
susres.set_suspendable(false).unwrap(); // block suspend/resume operations
|
||||||
do_update(&mut com, &modals, package, CTRL_PAGE_LEN,
|
if !do_update(&mut com, &modals, package, CTRL_PAGE_LEN,
|
||||||
WF200_FIRMWARE_BASE, length, "wf200");
|
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
|
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();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue