fixup dabao demo apps

- add boot delay on hello world - otherwise you might miss it
because it prints before the console is enumerated

- add preemption to the dabao environment

- improve error handling
This commit is contained in:
bunnie 2025-10-26 19:27:54 +08:00
parent 0ef31b1288
commit df9ae96263
4 changed files with 26 additions and 5 deletions

View file

@ -19,6 +19,7 @@ bao1x-api = { path = "../../libs/bao1x-api" }
bao1x-hal-service = { path = "../../services/bao1x-hal-service", optional = true }
bao1x-emu = { path = "../../services/bao1x-emu", optional = true }
usb-bao1x = { path = "../../services/usb-bao1x" }
bytemuck = "1.24.0"
aes = { path = "../../services/aes", default-features = false, optional = true }
@ -31,6 +32,7 @@ bao1x = ["utralib/bao1x", "usb-bao1x/bao1x", "aes/bao1x"]
board-dabao = [
"bao1x-hal-service",
"bao1x-hal/board-dabao",
# "bao1x-hal/debug-print-duart",
"usb-bao1x/board-dabao",
]
ctap-bringup = []

View file

@ -4,6 +4,7 @@ mod ctap;
mod repl;
mod shell;
use cmds::*;
#[cfg(feature = "usb")]
use usb_bao1x::UsbHid;
fn main() {
@ -12,6 +13,10 @@ fn main() {
log::info!("my PID is {}", xous::process::id());
let tt = ticktimer::Ticktimer::new().unwrap();
let hal = bao1x_hal_service::Hal::new();
// allow preemption in the dabao console environment
hal.set_preemption(true);
#[cfg(feature = "usb")]
{
let usb = UsbHid::new();

View file

@ -83,13 +83,21 @@ impl Repl {
// take the input and pass it on to the various command parsers, and attach result
if let Some(local) = &mut self.input {
println!("[console] {}", local);
if let Some(res) = self.env.dispatch(Some(local), None).expect("command dispatch failed") {
println!("{}\r", res);
match self.env.dispatch(Some(local), None) {
Ok(Some(res)) => println!("{}\r", res),
Ok(None) => println!("\r"),
Err(e) => {
println!("Command error: {:?}", e);
}
}
} else if let Some(msg) = &self.msg {
log::trace!("processing callback msg: {:?}", msg);
if let Some(res) = self.env.dispatch(None, Some(msg)).expect("callback failed") {
println!("{}", res);
match self.env.dispatch(None, Some(msg)) {
Ok(Some(res)) => println!("{}\r", res),
Ok(None) => println!("\r"),
Err(e) => {
println!("Command error: {:?}", e);
}
}
}

View file

@ -4,7 +4,13 @@ fn main() -> ! {
log::set_max_level(log::LevelFilter::Info);
log::info!("Hello world PID is {}", xous::process::id());
println!("Hello world");
// This delay of 5 seconds allows users watching over USB serial
// console a few seconds to connect the console and see the output.
// Otherwise, it will "print" to a console that's not listening.
std::thread::sleep(std::time::Duration::from_secs(5));
// This is the hello world!
println!("Hello world!");
// This ensures a graceful exit from the process.
xous::terminate_process(0)