From 81f35b17be0b64d1df45d15cddd821d66a0fd6ac Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 17:25:47 +0800 Subject: [PATCH 1/6] add the missing 4 bytes from the public key block after some discussion with a cryptographer it's just safer to do this even if it might mean some compatibility issues in the future --- bao1x-boot/blobs/pubkey-extra-ifr-0x240.bin | Bin 0 -> 32 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 bao1x-boot/blobs/pubkey-extra-ifr-0x240.bin diff --git a/bao1x-boot/blobs/pubkey-extra-ifr-0x240.bin b/bao1x-boot/blobs/pubkey-extra-ifr-0x240.bin new file mode 100644 index 0000000000000000000000000000000000000000..dce7ef222f949a76c6c5bd4f116a51fa65fa86a9 GIT binary patch literal 32 PcmcEOSiYM9H?RT#K+^(W literal 0 HcmV?d00001 From 2b19c4bd2162658b5a992d6fd69cb904eaf3fff5 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 17:32:12 +0800 Subject: [PATCH 2/6] add a command for setting the bootwait flag The keystore is a sensitive server, and the one-way counters have security-critical propoerties. So instead of revealing a generic one-way counter API to the world, specific, limited requests to do things are going to be created for the keystore. In this case, the bootwait flag would be convenient to be able to set from userspace. The motivation for this requirement is actually continuous integration - a normal human could just hold down a button while turning on power, but in CI, I don't have a robotic thumb (or an alternative electrical signal) to simulate the nerve-pinch on boot. Previously I was "cheating" and simulating this by nuking the loader, which effectively forces a bootwait. However, in production, this is *not possible* because the JTAG port is sealed off. Thus, this may be the first of a series of small PRs to incorporate CI tooling that clears up tech debt like nuking the loader to get into boot wait. --- libs/keystore-api/src/gen2_api.rs | 4 ++++ services/keystore/src/lib.rs | 23 +++++++++++++++++++ .../keystore/src/platform/baosec/server.rs | 16 +++++++++++++ .../keystore/src/platform/baosec/store.rs | 18 ++++++++++++++- 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/libs/keystore-api/src/gen2_api.rs b/libs/keystore-api/src/gen2_api.rs index 87098ea4c..290c60e63 100644 --- a/libs/keystore-api/src/gen2_api.rs +++ b/libs/keystore-api/src/gen2_api.rs @@ -18,6 +18,10 @@ pub enum Opcode { /// Ephemeral secret operations EphemeralOp = 256, + // ----- below are non-cryptographic opcodes but used to manipulate sensitive state ----- + /// Set bootwait parameters + Bootwait = 4096, + /// Used to map unknown opcodes InvalidCall = 65535, } diff --git a/services/keystore/src/lib.rs b/services/keystore/src/lib.rs index ce5124010..b6d21b325 100644 --- a/services/keystore/src/lib.rs +++ b/services/keystore/src/lib.rs @@ -169,6 +169,29 @@ impl Keystore { #[inline(always)] pub(crate) fn get_dec_backend(&self) -> KeystoreDec<'_> { KeystoreDec(self) } + + /// Returns the previous bootwait state + pub fn bootwait(&self, enable: Option) -> Result { + match xous::send_message( + self.conn, + xous::Message::new_blocking_scalar( + Opcode::Bootwait.to_usize().unwrap(), + if enable.is_some() { 1 } else { 0 }, + if enable.unwrap_or(false) { 1 } else { 0 }, + 0, + 0, + ), + )? { + xous::Result::Scalar5(_, last, _, _, _) => { + if last != 0 { + Ok(true) + } else { + Ok(false) + } + } + _ => unimplemented!(), + } + } } use core::sync::atomic::{AtomicU32, Ordering}; diff --git a/services/keystore/src/platform/baosec/server.rs b/services/keystore/src/platform/baosec/server.rs index 3cd6992da..e5469e8c6 100644 --- a/services/keystore/src/platform/baosec/server.rs +++ b/services/keystore/src/platform/baosec/server.rs @@ -44,6 +44,22 @@ pub fn keystore(sid: SID) -> ! { // this will use the backup_mgr to store ephemeral secrets todo!() } + Opcode::Bootwait => { + if let Some(scalar) = msg.body.scalar_message_mut() { + let is_some = scalar.arg1 != 0; + let enable = scalar.arg2 != 0; + match store.set_bootwait(if is_some { Some(enable) } else { None }) { + Ok(last) => { + if last { + scalar.arg1 = 1; + } else { + scalar.arg1 = 0; + } + } + _ => panic!("Couldn't set bootwait"), + } + } + } Opcode::InvalidCall => { log::error!("Invalid call in keystore: {:?}", opcode); } diff --git a/services/keystore/src/platform/baosec/store.rs b/services/keystore/src/platform/baosec/store.rs index 344d146c6..a5c94f53e 100644 --- a/services/keystore/src/platform/baosec/store.rs +++ b/services/keystore/src/platform/baosec/store.rs @@ -1,7 +1,8 @@ use aes::Aes256; use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit, generic_array::GenericArray}; use bao1x_api::{ - BOOT0_PUBKEY_FAIL, BoardTypeCoding, CP_ID, DEVELOPER_MODE, OEM_MODE, SLOT_ELEMENT_LEN_BYTES, UUID, + BOOT0_PUBKEY_FAIL, BoardTypeCoding, BootWaitCoding, CP_ID, DEVELOPER_MODE, OEM_MODE, + SLOT_ELEMENT_LEN_BYTES, UUID, }; use bao1x_hal::board::{BOOKEND_END, BOOKEND_START}; use bao1x_hal::{ @@ -356,4 +357,19 @@ impl KeyStore { }; Ok(()) } + + pub fn set_bootwait(&self, enable: Option) -> Result { + let previous = self.owc.get_decoded::().expect("couldn't fetch flag"); + if let Some(enable) = enable { + while self.owc.get_decoded::().expect("couldn't fetch flag") + != if enable { bao1x_api::BootWaitCoding::Enable } else { bao1x_api::BootWaitCoding::Disable } + { + self.owc.inc_coded::().unwrap(); + } + } + match previous { + BootWaitCoding::Enable => Ok(true), + BootWaitCoding::Disable => Ok(false), + } + } } From 2a7cffb86e69ea87170509cfc02da0dcf9376896 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 17:35:41 +0800 Subject: [PATCH 3/6] 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 --- services/bao-console/Cargo.toml | 1 + services/bao-console/src/cmds/test.rs | 437 +++++++++++++------------- 2 files changed, 228 insertions(+), 210 deletions(-) diff --git a/services/bao-console/Cargo.toml b/services/bao-console/Cargo.toml index 4b5f04f69..0e6d6b9f4 100644 --- a/services/bao-console/Cargo.toml +++ b/services/bao-console/Cargo.toml @@ -25,6 +25,7 @@ pddb = { path = "../pddb", optional = true } xous-swapper = { path = "../xous-swapper", optional = true } bytemuck = "1.24.0" susres = { package = "xous-api-susres", version = "0.9.68" } +keystore = { path = "../keystore" } # pddb testing rand = { version = "0.8.5", features = ["getrandom"], optional = true } diff --git a/services/bao-console/src/cmds/test.rs b/services/bao-console/src/cmds/test.rs index eac965e80..c9fabca38 100644 --- a/services/bao-console/src/cmds/test.rs +++ b/services/bao-console/src/cmds/test.rs @@ -15,242 +15,259 @@ impl<'a> ShellCmdApi<'a> for Test { let mut ret = String::new(); #[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")] let helpstring = "Usage: 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 = parts.map(|s| s.to_string()).collect(); - if let Some(sub_cmd) = tokens.next() { - match sub_cmd { - "timer" => { - let start = _env.ticktimer.elapsed_ms(); - log::info!("Starting test"); - let mut seconds = 0; - loop { - let elapsed = _env.ticktimer.elapsed_ms() - start; - if elapsed > seconds * 1000 { - log::info!("{} s", seconds); - seconds += 1; - } + match cmd.as_str() { + "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" => { + let start = _env.ticktimer.elapsed_ms(); + log::info!("Starting test"); + let mut seconds = 0; + loop { + let elapsed = _env.ticktimer.elapsed_ms() - start; + if elapsed > seconds * 1000 { + log::info!("{} s", seconds); + seconds += 1; } } - "time" => { - use chrono::{Local, Utc}; - let systime = std::time::SystemTime::now(); - let epoch = systime.duration_since(std::time::SystemTime::UNIX_EPOCH).unwrap(); - log::info!("Seconds since epoch: {}", epoch.as_secs()); - log::info!("Systime: {:?}", systime); - let now = Utc::now(); - log::info!("UTC now {}", now.format("%Y-%m-%d %H:%M:%S UTC")); - let local_now = Local::now(); - log::info!("Local time: {}", local_now.format("%Y-%m-%d %H:%M:%S %Z")); + } + "time" => { + use chrono::{Local, Utc}; + let systime = std::time::SystemTime::now(); + let epoch = systime.duration_since(std::time::SystemTime::UNIX_EPOCH).unwrap(); + log::info!("Seconds since epoch: {}", epoch.as_secs()); + log::info!("Systime: {:?}", systime); + let now = Utc::now(); + log::info!("UTC now {}", now.format("%Y-%m-%d %H:%M:%S UTC")); + let local_now = Local::now(); + log::info!("Local time: {}", local_now.format("%Y-%m-%d %H:%M:%S %Z")); - log::info!("Waiting 3 seconds"); - std::thread::sleep(std::time::Duration::from_secs(3)); + log::info!("Waiting 3 seconds"); + std::thread::sleep(std::time::Duration::from_secs(3)); - let systime = std::time::SystemTime::now(); - let epoch = systime.duration_since(std::time::SystemTime::UNIX_EPOCH).unwrap(); - log::info!("Seconds since epoch: {}", epoch.as_secs()); - log::info!("Systime: {:?}", systime); - let now = Utc::now(); - log::info!("UTC now {}", now.format("%Y-%m-%d %H:%M:%S UTC")); - let local_now = Local::now(); - log::info!("Local time: {}", local_now.format("%Y-%m-%d %H:%M:%S %Z")); - } - #[cfg(feature = "bmp180")] - "temp" => { - use bao1x_hal::bmp180::Bmp180; - use bao1x_hal::i2c::I2c; - let mut i2c = I2c::new(); + let systime = std::time::SystemTime::now(); + let epoch = systime.duration_since(std::time::SystemTime::UNIX_EPOCH).unwrap(); + log::info!("Seconds since epoch: {}", epoch.as_secs()); + log::info!("Systime: {:?}", systime); + let now = Utc::now(); + log::info!("UTC now {}", now.format("%Y-%m-%d %H:%M:%S UTC")); + let local_now = Local::now(); + log::info!("Local time: {}", local_now.format("%Y-%m-%d %H:%M:%S %Z")); + } + #[cfg(feature = "bmp180")] + "temp" => { + use bao1x_hal::bmp180::Bmp180; + use bao1x_hal::i2c::I2c; + let mut i2c = I2c::new(); - match Bmp180::new(&mut i2c) { - Ok(sensor) => match sensor.read_temperature(&mut i2c) { - Ok(temp) => { - write!(ret, "BMP180 Temperature: {:.1}°C", temp).unwrap(); - } - Err(e) => { - write!(ret, "Failed to read temperature: {:?}", e).unwrap(); - } - }, + match Bmp180::new(&mut i2c) { + Ok(sensor) => match sensor.read_temperature(&mut i2c) { + Ok(temp) => { + write!(ret, "BMP180 Temperature: {:.1}°C", temp).unwrap(); + } Err(e) => { - write!(ret, "Failed to initialize BMP180 sensor: {:?}", e).unwrap(); + write!(ret, "Failed to read temperature: {:?}", e).unwrap(); + } + }, + Err(e) => { + write!(ret, "Failed to initialize BMP180 sensor: {:?}", e).unwrap(); + } + } + } + #[cfg(not(feature = "hosted-baosec"))] + "shipmode" => { + use bao1x_hal::i2c::I2c; + let mut i2c = I2c::new(); + + let mut axp2101 = bao1x_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't get AXP2101"); + log::info!("sending shipmode to axp2101 pmic...in four seconds"); + let tt = ticktimer::Ticktimer::new().unwrap(); + tt.sleep_ms(4000).ok(); + // shut down BLDO1 - this should disconnect the battery + axp2101.set_ldo(&mut i2c, None, bao1x_hal::axp2101::WhichLdo::Bldo1).ok(); + // shut down PMIC + axp2101.powerdown(&mut i2c).ok(); + log::info!("sent shutdown to axp2101"); + } + #[cfg(not(feature = "hosted-baosec"))] + "deepsleep" => { + let gfx = ux_api::service::gfx::Gfx::new(&_env.xns).unwrap(); + log::info!("turn off display"); + gfx.set_power(false).unwrap(); + log::info!("display off"); + use num_traits::*; + // monkey patch over the standard xous IP + let conn = _env + .xns + .request_connection_blocking(susres::api::SERVER_NAME_SUSRES) + .expect("Can't connect to SUSRES"); + match xous::send_message( + conn, + xous::Message::new_blocking_scalar( + susres::api::Opcode::SuspendRequest.to_usize().unwrap(), + 1, // this is a monkeypatch + 0, + 0, + 0, + ), + ) { + Ok(xous::Result::Scalar1(result)) => { + if result == 1 { + log::info!("Should be in deep sleep!"); + } else { + log::error!("Couldn't initiate deep sleep") } } + _ => panic!("Couldn't send deep sleep message to susres"), } - #[cfg(not(feature = "hosted-baosec"))] - "shipmode" => { - use bao1x_hal::i2c::I2c; - let mut i2c = I2c::new(); + } + "seed" => { + let (_, value) = std::env::vars().find(|(key, _value)| key == "SEED").unwrap(); + log::info!("Seed: {:?}", value); + } + #[cfg(not(feature = "hosted-baosec"))] + "wfi" => { + let gfx = ux_api::service::gfx::Gfx::new(&_env.xns).unwrap(); + log::info!("turn off display"); + gfx.set_power(false).unwrap(); + log::info!("display off"); + let susres = susres::Susres::new_without_hook(&_env.xns).unwrap(); + log::info!("initiating wfi from test shell..."); + susres.initiate_suspend().unwrap(); + log::info!("waiting after WFI return (system will be in WFI)"); + _env.ticktimer.sleep_ms(100).ok(); + log::info!("turn on display"); + gfx.set_power(true).unwrap(); + } + "proc" => { + // hard coded - debug feature - if the platform ABI changes its name or opcode map this + // can break, but also this routine is not meant for public + // consumption and coding it here avoids breaking dependencies to the Xous API crate. + let page_buf = xous::PageBuf::new(); + xous::rsyscall(xous::SysCall::PlatformSpecific(2, page_buf.as_ptr(), 0, 0, 0, 0, 0)).unwrap(); - let mut axp2101 = - bao1x_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't get AXP2101"); - log::info!("sending shipmode to axp2101 pmic...in four seconds"); - let tt = ticktimer::Ticktimer::new().unwrap(); - tt.sleep_ms(4000).ok(); - // shut down BLDO1 - this should disconnect the battery - axp2101.set_ldo(&mut i2c, None, bao1x_hal::axp2101::WhichLdo::Bldo1).ok(); - // shut down PMIC - axp2101.powerdown(&mut i2c).ok(); - log::info!("sent shutdown to axp2101"); + log::info!("Process listing:"); + for line in page_buf.as_str().lines() { + log::info!("{}", line); } - #[cfg(not(feature = "hosted-baosec"))] - "deepsleep" => { - let gfx = ux_api::service::gfx::Gfx::new(&_env.xns).unwrap(); - log::info!("turn off display"); - gfx.set_power(false).unwrap(); - log::info!("display off"); - use num_traits::*; - // monkey patch over the standard xous IP - let conn = _env - .xns - .request_connection_blocking(susres::api::SERVER_NAME_SUSRES) - .expect("Can't connect to SUSRES"); - match xous::send_message( - conn, - xous::Message::new_blocking_scalar( - susres::api::Opcode::SuspendRequest.to_usize().unwrap(), - 1, // this is a monkeypatch - 0, - 0, - 0, - ), - ) { - Ok(xous::Result::Scalar1(result)) => { - if result == 1 { - log::info!("Should be in deep sleep!"); - } else { - log::error!("Couldn't initiate deep sleep") - } + } + "freemem" => { + // hard coded - debug feature - if the platform ABI changes its name or opcode map this + // can break, but also this routine is not meant for public + // consumption and coding it here avoids breaking dependencies to the Xous API crate. + let page_buf = xous::PageBuf::new(); + xous::rsyscall(xous::SysCall::PlatformSpecific(1, page_buf.as_ptr(), 0, 0, 0, 0, 0)).unwrap(); + + log::info!("RAM usage:"); + for line in page_buf.as_str().lines() { + log::info!("{}", line); + } + } + "interrupts" => { + // hard coded - debug feature - if the platform ABI changes its name or opcode map this + // can break, but also this routine is not meant for public + // consumption and coding it here avoids breaking dependencies to the Xous API crate. + let page_buf = xous::PageBuf::new(); + xous::rsyscall(xous::SysCall::PlatformSpecific(3, page_buf.as_ptr(), 0, 0, 0, 0, 0)).unwrap(); + + log::info!("Interrupt handlers:"); + for line in page_buf.as_str().lines() { + log::info!("{}", line); + } + } + #[cfg(feature = "board-baosec")] + "qrshow" => { + // note that 40 bytes gives 320 bits which fits nicely into a version 3 code, + // which allows 4 pixels per module rendering. + // if we have to move to 3 pixels per module, the next code up that optimally + // uses the full screen is version 6. This would give 102 bytes of transfer + // in a single scan. + // + // The equation for capacity is: + // `binary_bytes = floor((alphanumeric_capacity / 3) × 2)` + // + // where `alphameric_capacity` is the capacity of the QR code version + // per spec lookup table. + let modals = modals::Modals::new(&_env.xns).unwrap(); + let mut test_data = [0u8; 40]; + for (i, d) in test_data.iter_mut().enumerate() { + *d = i as u8; + } + let encoded = base45::encode(&test_data); + modals.show_notification("", Some(&encoded)).ok(); + } + #[cfg(feature = "board-baosec")] + "qrget" => { + let gfx = ux_api::service::gfx::Gfx::new(&_env.xns).unwrap(); + match gfx.acquire_qr() { + Ok(qr_data) => { + if let Some(meta) = qr_data.meta { + log::info!("QR code metadata: {}", meta); } - _ => panic!("Couldn't send deep sleep message to susres"), - } - } - "seed" => { - let (_, value) = std::env::vars().find(|(key, _value)| key == "SEED").unwrap(); - log::info!("Seed: {:?}", value); - } - #[cfg(not(feature = "hosted-baosec"))] - "wfi" => { - let gfx = ux_api::service::gfx::Gfx::new(&_env.xns).unwrap(); - log::info!("turn off display"); - gfx.set_power(false).unwrap(); - log::info!("display off"); - let susres = susres::Susres::new_without_hook(&_env.xns).unwrap(); - log::info!("initiating wfi from test shell..."); - susres.initiate_suspend().unwrap(); - log::info!("waiting after WFI return (system will be in WFI)"); - _env.ticktimer.sleep_ms(100).ok(); - log::info!("turn on display"); - gfx.set_power(true).unwrap(); - } - "proc" => { - // hard coded - debug feature - if the platform ABI changes its name or opcode map this - // can break, but also this routine is not meant for public - // consumption and coding it here avoids breaking dependencies to the Xous API crate. - let page_buf = xous::PageBuf::new(); - xous::rsyscall(xous::SysCall::PlatformSpecific(2, page_buf.as_ptr(), 0, 0, 0, 0, 0)) - .unwrap(); - - log::info!("Process listing:"); - for line in page_buf.as_str().lines() { - log::info!("{}", line); - } - } - "freemem" => { - // hard coded - debug feature - if the platform ABI changes its name or opcode map this - // can break, but also this routine is not meant for public - // consumption and coding it here avoids breaking dependencies to the Xous API crate. - let page_buf = xous::PageBuf::new(); - xous::rsyscall(xous::SysCall::PlatformSpecific(1, page_buf.as_ptr(), 0, 0, 0, 0, 0)) - .unwrap(); - - log::info!("RAM usage:"); - for line in page_buf.as_str().lines() { - log::info!("{}", line); - } - } - "interrupts" => { - // hard coded - debug feature - if the platform ABI changes its name or opcode map this - // can break, but also this routine is not meant for public - // consumption and coding it here avoids breaking dependencies to the Xous API crate. - let page_buf = xous::PageBuf::new(); - xous::rsyscall(xous::SysCall::PlatformSpecific(3, page_buf.as_ptr(), 0, 0, 0, 0, 0)) - .unwrap(); - - log::info!("Interrupt handlers:"); - for line in page_buf.as_str().lines() { - log::info!("{}", line); - } - } - #[cfg(feature = "board-baosec")] - "qrshow" => { - // note that 40 bytes gives 320 bits which fits nicely into a version 3 code, - // which allows 4 pixels per module rendering. - // if we have to move to 3 pixels per module, the next code up that optimally - // uses the full screen is version 6. This would give 102 bytes of transfer - // in a single scan. - // - // The equation for capacity is: - // `binary_bytes = floor((alphanumeric_capacity / 3) × 2)` - // - // where `alphameric_capacity` is the capacity of the QR code version - // per spec lookup table. - let modals = modals::Modals::new(&_env.xns).unwrap(); - let mut test_data = [0u8; 40]; - for (i, d) in test_data.iter_mut().enumerate() { - *d = i as u8; - } - let encoded = base45::encode(&test_data); - modals.show_notification("", Some(&encoded)).ok(); - } - #[cfg(feature = "board-baosec")] - "qrget" => { - let gfx = ux_api::service::gfx::Gfx::new(&_env.xns).unwrap(); - match gfx.acquire_qr() { - Ok(qr_data) => { - if let Some(meta) = qr_data.meta { - log::info!("QR code metadata: {}", meta); - } - if let Some(coded) = qr_data.content { - match base45::decode(&coded) { - Ok(data) => { - log::info!("Recovered: {:x?}", data); - } - Err(e) => { - log::info!("Base45 decode err: {:?}", e); - } + if let Some(coded) = qr_data.content { + match base45::decode(&coded) { + Ok(data) => { + log::info!("Recovered: {:x?}", data); + } + Err(e) => { + log::info!("Base45 decode err: {:?}", e); } } } - Err(e) => { - log::info!("QR error: {:?}", e); - } } - } - /* // leave this around in case we have more swap bugs to debug - // needs to have `swaptest1`` & `swaptest2` added to the image for this to work. - "swap" => { - log::info!("starting swap test"); - let swaptest1 = _env.xns.request_connection("swaptest1").unwrap(); - let swaptest2 = _env.xns.request_connection("swaptest2").unwrap(); - for i in 1..4 { - log::info!("iter {}", i); - xous::send_message(swaptest1, xous::Message::new_scalar(0, i, 0, 0, 0)).unwrap(); - xous::send_message(swaptest2, xous::Message::new_scalar(0, i + 1, 0, 0, 0)).unwrap(); + Err(e) => { + log::info!("QR error: {:?}", e); } - log::info!("swaptest done"); - } - */ - _ => { - write!(ret, "{}", helpstring).unwrap(); } } - } else { - write!(ret, "{}", helpstring).unwrap(); + /* // leave this around in case we have more swap bugs to debug + // needs to have `swaptest1`` & `swaptest2` added to the image for this to work. + "swap" => { + log::info!("starting swap test"); + let swaptest1 = _env.xns.request_connection("swaptest1").unwrap(); + let swaptest2 = _env.xns.request_connection("swaptest2").unwrap(); + for i in 1..4 { + log::info!("iter {}", i); + xous::send_message(swaptest1, xous::Message::new_scalar(0, i, 0, 0, 0)).unwrap(); + xous::send_message(swaptest2, xous::Message::new_scalar(0, i + 1, 0, 0, 0)).unwrap(); + } + log::info!("swaptest done"); + } + */ + _ => { + write!(ret, "{}", helpstring).unwrap(); + } } + Ok(Some(ret)) } } From b2c464be0fe06a5e1b7116c8c7db96617b3dfafa Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 17:36:15 +0800 Subject: [PATCH 4/6] add keystore as dependency to console --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index b2f9df37e..8055db5f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,6 +363,7 @@ dependencies = [ "base45", "bytemuck", "chrono", + "keystore", "log", "modals", "num-derive 0.4.2", From 5a73d17a0a5223aba4224dc54fbbd03a00b2fbfb Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 17:40:17 +0800 Subject: [PATCH 5/6] handle the no-arg case correctly --- services/bao-console/src/cmds/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/services/bao-console/src/cmds/test.rs b/services/bao-console/src/cmds/test.rs index c9fabca38..e39137623 100644 --- a/services/bao-console/src/cmds/test.rs +++ b/services/bao-console/src/cmds/test.rs @@ -30,6 +30,7 @@ impl<'a> ShellCmdApi<'a> for Test { let keystore = keystore::Keystore::new(&_env.xns); if args.len() != 1 { write!(ret, "bootwait [check | enable | disable]").ok(); + return Ok(Some(ret)); } if args[0] == "check" { write!(ret, "bootwait is {:?}", keystore.bootwait(None).unwrap()).ok(); From 4c3d2f677cdf41bfaf0db49402fe29bf917ca70f Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 17:52:00 +0800 Subject: [PATCH 6/6] fix hosted mode --- services/keystore/src/platform/hosted.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/keystore/src/platform/hosted.rs b/services/keystore/src/platform/hosted.rs index 536e19829..e5b3ff2ff 100644 --- a/services/keystore/src/platform/hosted.rs +++ b/services/keystore/src/platform/hosted.rs @@ -136,7 +136,7 @@ pub fn keystore(sid: SID) -> ! { Opcode::EphemeralOp => { todo!() } - Opcode::InvalidCall => { + _ => { log::error!("Invalid call in keystore: {:?}", opcode); } }