add build flags to bao-console

two flags are added:

with-pddb - puts the PDDB commands into the console
battery-readout - turns on the periodic battery readout
This commit is contained in:
bunnie 2025-06-09 16:37:47 +08:00
parent 4bc762e9ae
commit ea3b032fbe
3 changed files with 10 additions and 3 deletions

View file

@ -50,7 +50,9 @@ hosted-baosec = [
"cramium-hal/hosted-baosec", "cramium-hal/hosted-baosec",
] ]
usb = [] usb = []
pddbtest = [] battery-readout = []
with-pddb = []
pddbtest = ["with-pddb"]
test-rekey = [] test-rekey = []
autobasis = ["rand_chacha", "rand"] autobasis = ["rand_chacha", "rand"]
modal-testing = ["ux-api", "modals/modal-testing"] modal-testing = ["ux-api", "modals/modal-testing"]

View file

@ -87,7 +87,9 @@ use trng_cmd::*;
mod usb; mod usb;
#[cfg(feature = "usb")] #[cfg(feature = "usb")]
use usb::*; use usb::*;
#[cfg(feature = "with-pddb")]
mod pddb; mod pddb;
#[cfg(feature = "with-pddb")]
use pddb::*; use pddb::*;
pub struct CmdEnv { pub struct CmdEnv {
@ -97,6 +99,7 @@ pub struct CmdEnv {
trng_cmd: TrngCmd, trng_cmd: TrngCmd,
#[cfg(feature = "usb")] #[cfg(feature = "usb")]
usb: Usb, usb: Usb,
#[cfg(feature = "with-pddb")]
pddb_cmd: PddbCmd, pddb_cmd: PddbCmd,
} }
impl CmdEnv { impl CmdEnv {
@ -120,6 +123,7 @@ impl CmdEnv {
}, },
#[cfg(feature = "usb")] #[cfg(feature = "usb")]
usb: Usb::new(), usb: Usb::new(),
#[cfg(feature = "with-pddb")]
pddb_cmd: PddbCmd::new(), pddb_cmd: PddbCmd::new(),
} }
} }
@ -142,6 +146,7 @@ impl CmdEnv {
&mut console_cmd, &mut console_cmd,
#[cfg(feature = "usb")] #[cfg(feature = "usb")]
&mut self.usb, &mut self.usb,
#[cfg(feature = "with-pddb")]
&mut self.pddb_cmd, &mut self.pddb_cmd,
]; ];

View file

@ -108,7 +108,7 @@ fn main() {
modals::tests::spawn_test(); modals::tests::spawn_test();
} }
#[cfg(not(feature = "hosted-baosec"))] #[cfg(feature = "battery-readout")]
{ {
use cramium_api::I2cApi; use cramium_api::I2cApi;
let mut i2c = cram_hal_service::I2c::new(); let mut i2c = cram_hal_service::I2c::new();
@ -126,7 +126,7 @@ fn main() {
} }
} }
} }
#[cfg(feature = "hosted-baosec")] #[cfg(any(feature = "hosted-baosec", not(feature = "battery-readout")))]
loop { loop {
tt.sleep_ms(2_000).ok(); tt.sleep_ms(2_000).ok();
} }