add bootwait command line API to test

also refactor the test argument parsing so that i can use the
more modern version of the api
This commit is contained in:
bunnie 2026-01-16 17:35:41 +08:00
parent 2b19c4bd21
commit 2a7cffb86e
2 changed files with 228 additions and 210 deletions

View file

@ -25,6 +25,7 @@ pddb = { path = "../pddb", optional = true }
xous-swapper = { path = "../xous-swapper", optional = true } xous-swapper = { path = "../xous-swapper", optional = true }
bytemuck = "1.24.0" bytemuck = "1.24.0"
susres = { package = "xous-api-susres", version = "0.9.68" } susres = { package = "xous-api-susres", version = "0.9.68" }
keystore = { path = "../keystore" }
# pddb testing # pddb testing
rand = { version = "0.8.5", features = ["getrandom"], optional = true } rand = { version = "0.8.5", features = ["getrandom"], optional = true }

View file

@ -15,16 +15,39 @@ impl<'a> ShellCmdApi<'a> for Test {
let mut ret = String::new(); let mut ret = String::new();
#[allow(unused_variables)] #[allow(unused_variables)]
let helpstring = "test [proc] [freemem] [interrupts]; see code for other test commands."; let helpstring = "test [proc] [freemem] [interrupts] [bootwait]; see code for other test commands.";
#[cfg(feature = "bmp180")] #[cfg(feature = "bmp180")]
let helpstring = "Usage: let helpstring = "Usage:
temp - reads temperature from bmp180."; temp - reads temperature from bmp180.";
let mut tokens = args.split(' '); let mut parts = args.split_whitespace();
let cmd = parts.next().unwrap_or("").to_string();
let args: Vec<String> = parts.map(|s| s.to_string()).collect();
if let Some(sub_cmd) = tokens.next() { match cmd.as_str() {
match sub_cmd { "bootwait" => {
let keystore = keystore::Keystore::new(&_env.xns);
if args.len() != 1 {
write!(ret, "bootwait [check | enable | disable]").ok();
}
if args[0] == "check" {
write!(ret, "bootwait is {:?}", keystore.bootwait(None).unwrap()).ok();
} else if args[0] == "enable" {
keystore.bootwait(Some(true)).unwrap();
write!(ret, "bootwait enabled").ok();
log::info!(
"{}BOOTWAIT.ENABLED,{}",
bao1x_hal::board::BOOKEND_START,
bao1x_hal::board::BOOKEND_END
);
} else if args[0] == "disable" {
keystore.bootwait(Some(false)).unwrap();
write!(ret, "bootwait disabled").ok();
} else {
write!(ret, "bootwait [check | enable | disable]").ok();
}
}
"timer" => { "timer" => {
let start = _env.ticktimer.elapsed_ms(); let start = _env.ticktimer.elapsed_ms();
log::info!("Starting test"); log::info!("Starting test");
@ -85,8 +108,7 @@ impl<'a> ShellCmdApi<'a> for Test {
use bao1x_hal::i2c::I2c; use bao1x_hal::i2c::I2c;
let mut i2c = I2c::new(); let mut i2c = I2c::new();
let mut axp2101 = let mut axp2101 = bao1x_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't get AXP2101");
bao1x_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't get AXP2101");
log::info!("sending shipmode to axp2101 pmic...in four seconds"); log::info!("sending shipmode to axp2101 pmic...in four seconds");
let tt = ticktimer::Ticktimer::new().unwrap(); let tt = ticktimer::Ticktimer::new().unwrap();
tt.sleep_ms(4000).ok(); tt.sleep_ms(4000).ok();
@ -151,8 +173,7 @@ impl<'a> ShellCmdApi<'a> for Test {
// can break, but also this routine is not meant for public // can break, but also this routine is not meant for public
// consumption and coding it here avoids breaking dependencies to the Xous API crate. // consumption and coding it here avoids breaking dependencies to the Xous API crate.
let page_buf = xous::PageBuf::new(); let page_buf = xous::PageBuf::new();
xous::rsyscall(xous::SysCall::PlatformSpecific(2, page_buf.as_ptr(), 0, 0, 0, 0, 0)) xous::rsyscall(xous::SysCall::PlatformSpecific(2, page_buf.as_ptr(), 0, 0, 0, 0, 0)).unwrap();
.unwrap();
log::info!("Process listing:"); log::info!("Process listing:");
for line in page_buf.as_str().lines() { for line in page_buf.as_str().lines() {
@ -164,8 +185,7 @@ impl<'a> ShellCmdApi<'a> for Test {
// can break, but also this routine is not meant for public // can break, but also this routine is not meant for public
// consumption and coding it here avoids breaking dependencies to the Xous API crate. // consumption and coding it here avoids breaking dependencies to the Xous API crate.
let page_buf = xous::PageBuf::new(); let page_buf = xous::PageBuf::new();
xous::rsyscall(xous::SysCall::PlatformSpecific(1, page_buf.as_ptr(), 0, 0, 0, 0, 0)) xous::rsyscall(xous::SysCall::PlatformSpecific(1, page_buf.as_ptr(), 0, 0, 0, 0, 0)).unwrap();
.unwrap();
log::info!("RAM usage:"); log::info!("RAM usage:");
for line in page_buf.as_str().lines() { for line in page_buf.as_str().lines() {
@ -177,8 +197,7 @@ impl<'a> ShellCmdApi<'a> for Test {
// can break, but also this routine is not meant for public // can break, but also this routine is not meant for public
// consumption and coding it here avoids breaking dependencies to the Xous API crate. // consumption and coding it here avoids breaking dependencies to the Xous API crate.
let page_buf = xous::PageBuf::new(); let page_buf = xous::PageBuf::new();
xous::rsyscall(xous::SysCall::PlatformSpecific(3, page_buf.as_ptr(), 0, 0, 0, 0, 0)) xous::rsyscall(xous::SysCall::PlatformSpecific(3, page_buf.as_ptr(), 0, 0, 0, 0, 0)).unwrap();
.unwrap();
log::info!("Interrupt handlers:"); log::info!("Interrupt handlers:");
for line in page_buf.as_str().lines() { for line in page_buf.as_str().lines() {
@ -248,9 +267,7 @@ impl<'a> ShellCmdApi<'a> for Test {
write!(ret, "{}", helpstring).unwrap(); write!(ret, "{}", helpstring).unwrap();
} }
} }
} else {
write!(ret, "{}", helpstring).unwrap();
}
Ok(Some(ret)) Ok(Some(ret))
} }
} }