[opentitan-tool] listen better for Test ROM identification
Signed-off-by: Drew Macrae <drewmacrae@google.com>
diff --git a/sw/host/opentitanlib/src/transport/cw310/mod.rs b/sw/host/opentitanlib/src/transport/cw310/mod.rs
index befa4fa..2004acd 100644
--- a/sw/host/opentitanlib/src/transport/cw310/mod.rs
+++ b/sw/host/opentitanlib/src/transport/cw310/mod.rs
@@ -211,7 +211,6 @@
return Ok(None);
}
}
-
// Program the FPGA bitstream.
log::info!("Programming the FPGA bitstream.");
let usb = self.device.borrow();
diff --git a/sw/host/opentitanlib/src/uart/console.rs b/sw/host/opentitanlib/src/uart/console.rs
index b738363..d28caca 100644
--- a/sw/host/opentitanlib/src/uart/console.rs
+++ b/sw/host/opentitanlib/src/uart/console.rs
@@ -24,7 +24,7 @@
pub newline: bool,
}
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
pub enum ExitStatus {
None,
CtrlC,
diff --git a/sw/host/opentitanlib/src/util/rom_detect.rs b/sw/host/opentitanlib/src/util/rom_detect.rs
index a65e315..9d8c0fb 100644
--- a/sw/host/opentitanlib/src/util/rom_detect.rs
+++ b/sw/host/opentitanlib/src/util/rom_detect.rs
@@ -8,6 +8,7 @@
use std::convert::TryInto;
use std::str::FromStr;
use std::time::Duration;
+use std::time::Instant;
use structopt::clap::arg_enum;
use thiserror::Error;
@@ -43,7 +44,7 @@
usr_access: Self::scan_usr_access(bitstream)?,
console: UartConsole {
timeout: timeout,
- exit_success: Some(Regex::new(r"(\w+ROM):([^\r\n]+)").unwrap()),
+ exit_success: Some(Regex::new(r"(\w+ROM):([^\r\n]+)[\r\n]").unwrap()),
..Default::default()
},
})
@@ -61,7 +62,10 @@
}
pub fn detect(&mut self, uart: &dyn Uart) -> Result<bool> {
- self.console.interact(uart, None, None)?;
+ let t0 = Instant::now();
+ let rc = self.console.interact(uart, None, None)?;
+ let t1 = Instant::now();
+ log::debug!("detect exit={:?}, duration={:?}", rc, t1 - t0);
if let Some(cap) = self.console.captures(ExitStatus::ExitSuccess) {
log::info!("Current bitstream: {:?}", cap.get(0).unwrap().as_str());
let romkind = cap.get(1).unwrap().as_str();
diff --git a/sw/host/opentitantool/src/command/load_bitstream.rs b/sw/host/opentitantool/src/command/load_bitstream.rs
index 573d398..0717c7a 100644
--- a/sw/host/opentitantool/src/command/load_bitstream.rs
+++ b/sw/host/opentitantool/src/command/load_bitstream.rs
@@ -30,7 +30,7 @@
pub rom_kind: Option<RomKind>,
#[structopt(long, parse(try_from_str=humantime::parse_duration), default_value="50ms", help = "Duration of the reset pulse.")]
pub rom_reset_pulse: Duration,
- #[structopt(long, parse(try_from_str=humantime::parse_duration), default_value="1s", help = "Duration of ROM detection timeout")]
+ #[structopt(long, parse(try_from_str=humantime::parse_duration), default_value="2s", help = "Duration of ROM detection timeout")]
pub rom_timeout: Duration,
}