From c2640458f5f002d668727e086b53804de95a440a Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 28 Jan 2026 15:21:39 +0800 Subject: [PATCH] fix hosted mode and warnings --- apps-baosec/vault2/src/main.rs | 3 +++ services/bao-console/Cargo.toml | 3 ++- services/bao-console/src/cmds/test.rs | 6 +++--- services/bao-video/src/main.rs | 2 +- services/bao1x-emu/src/display.rs | 9 +++++++++ services/bao1x-hal-service/src/servers/susres.rs | 3 +-- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps-baosec/vault2/src/main.rs b/apps-baosec/vault2/src/main.rs index 0476ee969..6df8541e1 100644 --- a/apps-baosec/vault2/src/main.rs +++ b/apps-baosec/vault2/src/main.rs @@ -540,6 +540,9 @@ fn main() -> ! { let previous = allow_totp_rendering.load(Ordering::SeqCst); allow_totp_rendering.store(false, Ordering::SeqCst); let mut test_data = [0u8; 40]; + #[cfg(feature = "hosted-baosec")] + let mut trng = bao1x_emu::trng::Trng::new(&xns).unwrap(); + #[cfg(not(feature = "hosted-baosec"))] let mut trng = bao1x_hal_service::trng::Trng::new(&xns).unwrap(); trng.fill_bytes_via_next(&mut test_data); let encoded = base45::encode(&test_data); diff --git a/services/bao-console/Cargo.toml b/services/bao-console/Cargo.toml index 6f8d91737..d603cb5a1 100644 --- a/services/bao-console/Cargo.toml +++ b/services/bao-console/Cargo.toml @@ -27,7 +27,7 @@ bytemuck = "1.24.0" susres = { path = "../../api/xous-api-susres", package = "xous-api-susres" } keystore = { path = "../keystore" } -bio-lib = { path = "../../libs/bio-lib" } +bio-lib = { path = "../../libs/bio-lib", optional = true } arbitrary-int = "1.2" # pddb testing @@ -59,6 +59,7 @@ board-baosec = [ "pddb/board-baosec", "xous-swapper", "ux-api/board-baosec", + "bio-lib", ] oem-baosec-lite = ["bao1x-hal/sensor-lis2dh12"] hosted-baosec = [ diff --git a/services/bao-console/src/cmds/test.rs b/services/bao-console/src/cmds/test.rs index f63e62697..06f9bb20b 100644 --- a/services/bao-console/src/cmds/test.rs +++ b/services/bao-console/src/cmds/test.rs @@ -1,5 +1,3 @@ -use std::time::Duration; - use String; use crate::{CommonEnv, ShellCmdApi}; @@ -252,6 +250,7 @@ impl<'a> ShellCmdApi<'a> for Test { } } } + #[cfg(not(feature = "hosted-baosec"))] "cam" => { use bao1x_api::I2cApi; let mut i2c = bao1x_hal::i2c::I2c::new(); @@ -270,8 +269,9 @@ impl<'a> ShellCmdApi<'a> for Test { write!(ret, "Wrote {:x} into {:x}", data, adr).ok(); } } + #[cfg(all(not(feature = "hosted-baosec"), feature = "oem-baosec-lite"))] "accel" => { - use std::time::Instant; + use std::time::{Duration, Instant}; use bao1x_hal::i2c::I2c; use bao1x_hal::lis2dh12::{Lis2dh12, Orientation}; diff --git a/services/bao-video/src/main.rs b/services/bao-video/src/main.rs index 7d5c252cd..e5c864251 100644 --- a/services/bao-video/src/main.rs +++ b/services/bao-video/src/main.rs @@ -266,7 +266,7 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! { udma_global.udma_clock_config(PeriphId::Cam, true); // ---- camera initialization - #[cfg(not(feature = "oem-baosec-lite"))] + #[cfg(all(not(feature = "oem-baosec-lite"), not(feature = "hosted-baosec")))] let cam_clk = (IoxPort::PA, 0); #[cfg(feature = "oem-baosec-lite")] let cam_clk = (IoxPort::PA, 3); diff --git a/services/bao1x-emu/src/display.rs b/services/bao1x-emu/src/display.rs index 9893f9b4d..b0bc7e92a 100644 --- a/services/bao1x-emu/src/display.rs +++ b/services/bao1x-emu/src/display.rs @@ -172,6 +172,15 @@ impl FrameBuffer for Oled128x128 { } } + unsafe fn put_pixel_unchecked(&mut self, p: Point, on: ColorNative) { + let bitnum = (p.x + p.y * COLUMN) as usize; + if on.0 != 0 { + self.buffer[bitnum / 32] |= 1 << (bitnum % 32); + } else { + self.buffer[bitnum / 32] &= !(1 << (bitnum % 32)); + } + } + fn dimensions(&self) -> Point { Point::new(COLUMN, ROW) } fn get_pixel(&self, p: Point) -> Option { diff --git a/services/bao1x-hal-service/src/servers/susres.rs b/services/bao1x-hal-service/src/servers/susres.rs index 89147e7d1..778a22aeb 100644 --- a/services/bao1x-hal-service/src/servers/susres.rs +++ b/services/bao1x-hal-service/src/servers/susres.rs @@ -1,6 +1,5 @@ use core::sync::atomic::{AtomicU32, Ordering}; -use bao1x_hal_service::api::ClockOp; use num_traits::*; use utralib::*; use xous::{CID, Message, msg_blocking_scalar_unpack, msg_scalar_unpack, send_message, sender::Sender}; @@ -222,7 +221,7 @@ fn susres_service() { log::trace!("still waiting on callbacks, returning to main loop"); } }), - Some(Opcode::SuspendRequest) => msg_blocking_scalar_unpack!(msg, deepsleep, 0, 0, 0, { + Some(Opcode::SuspendRequest) => msg_blocking_scalar_unpack!(msg, _, _, _, _, { log::info!("registered suspend listeners:"); for sub in suspend_subscribers.iter() { log::info!("{:?}", sub);