[opentitanlib] Set a default for reset_delay and clean up call sites
Signed-off-by: Alphan Ulusoy <alphan@google.com>
diff --git a/sw/host/opentitanlib/src/bootstrap/mod.rs b/sw/host/opentitanlib/src/bootstrap/mod.rs
index ae014cd..a62d390 100644
--- a/sw/host/opentitanlib/src/bootstrap/mod.rs
+++ b/sw/host/opentitanlib/src/bootstrap/mod.rs
@@ -96,8 +96,8 @@
help = "Whether to reset target and clear UART RX buffer after bootstrap. For CW310 only."
)]
pub clear_uart: Option<bool>,
- #[structopt(long, parse(try_from_str=parse_duration), help = "Duration of the reset delay")]
- pub reset_delay: Option<Duration>,
+ #[structopt(long, parse(try_from_str=parse_duration), default_value = "100ms", help = "Duration of the reset delay")]
+ pub reset_delay: Duration,
#[structopt(long, parse(try_from_str=parse_duration), help = "Duration of the inter-frame delay")]
pub inter_frame_delay: Option<Duration>,
#[structopt(long, parse(try_from_str=parse_duration), help = "Duration of the flash-erase delay")]
@@ -115,8 +115,6 @@
}
impl<'a> Bootstrap<'a> {
- const RESET_DELAY: Duration = Duration::from_millis(200);
-
/// Perform the update, sending the firmware `payload` to a SPI or UART target depending on
/// given `options`, which specifies protocol and port to use.
pub fn update(
@@ -164,7 +162,7 @@
uart_params: &options.uart_params,
spi_params: &options.spi_params,
reset_pin: transport.gpio_pin("RESET")?,
- reset_delay: options.reset_delay.unwrap_or(Self::RESET_DELAY),
+ reset_delay: options.reset_delay,
}
.do_update(updater, transport, payload, &progress)
}
diff --git a/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs b/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs
index 98d5a30..567347d 100644
--- a/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs
+++ b/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs
@@ -111,13 +111,7 @@
};
transport.apply_pin_strapping("ROM_BOOTSTRAP")?;
- let reset_delay = opts
- .init
- .bootstrap
- .options
- .reset_delay
- .unwrap_or(Duration::from_millis(50));
- transport.reset_target(reset_delay, true)?;
+ transport.reset_target(opts.init.bootstrap.options.reset_delay, true)?;
// Now watch the console for the exit conditions.
let result = console.interact(&*uart, None, Some(&mut std::io::stdout()))?;
@@ -147,13 +141,7 @@
};
transport.remove_pin_strapping("ROM_BOOTSTRAP")?;
- let reset_delay = opts
- .init
- .bootstrap
- .options
- .reset_delay
- .unwrap_or(Duration::from_millis(50));
- transport.reset_target(reset_delay, true)?;
+ transport.reset_target(opts.init.bootstrap.options.reset_delay, true)?;
// Now watch the console for the exit conditions.
let result = console.interact(&*uart, None, Some(&mut std::io::stdout()))?;