Skip to content

Commit

Permalink
[rust] update semver-compatible dependencies
Browse files Browse the repository at this point in the history
* indexmap has an API deprecation, so the usage is replaced.
* serialport now sets DTR on open by default, disable this behaviour
  to stay compatible.

Signed-off-by: Gary Guo <[email protected]>
  • Loading branch information
nbdd0121 committed Jan 16, 2025
1 parent 11ac7bd commit 140185f
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 382 deletions.
4 changes: 2 additions & 2 deletions sw/host/opentitanlib/src/transport/common/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl SerialPortUart {

/// Open the given serial device, such as `/dev/ttyUSB0`.
pub fn open(port_name: &str, baud: u32) -> Result<Self> {
let port = TTYPort::open(&serialport::new(port_name, baud))
let port = TTYPort::open(&serialport::new(port_name, baud).preserve_dtr_on_open())
.map_err(|e| UartError::OpenError(e.to_string()))?;
flock_serial(&port, port_name)?;
Ok(SerialPortUart {
Expand All @@ -49,7 +49,7 @@ impl SerialPortUart {

/// Open a pseudo port (e.g. a verilator pts device).
pub fn open_pseudo(port_name: &str, baud: u32) -> Result<Self> {
let port = TTYPort::open(&serialport::new(port_name, baud))
let port = TTYPort::open(&serialport::new(port_name, baud).preserve_dtr_on_open())
.map_err(|e| UartError::OpenError(e.to_string()))?;
flock_serial(&port, port_name)?;
Ok(SerialPortUart {
Expand Down
9 changes: 6 additions & 3 deletions sw/host/opentitanlib/src/transport/hyperdebug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,12 @@ impl Inner {
.console_tty
.to_str()
.ok_or(TransportError::UnicodePathError)?;
let port =
TTYPort::open(&serialport::new(port_name, 115_200).timeout(Self::COMMAND_TIMEOUT))
.context("Failed to open HyperDebug console")?;
let port = TTYPort::open(
&serialport::new(port_name, 115_200)
.preserve_dtr_on_open()
.timeout(Self::COMMAND_TIMEOUT),
)
.context("Failed to open HyperDebug console")?;
flock_serial(&port, port_name)?;
let conn = Rc::new(Conn {
console_port: RefCell::new(port),
Expand Down
2 changes: 1 addition & 1 deletion sw/host/ot_certs/src/template/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Subst for Template {
let mut variables = self.variables.clone();
let mut new_data = SubstData::new();
for (var_name, val) in data.values.iter() {
let Some(var_type) = variables.remove(var_name) else {
let Some(var_type) = variables.shift_remove(var_name) else {
// Variable does not appear in the template: ignore it.
continue;
};
Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/.cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[advisories]
ignore = [
"RUSTSEC-2020-0168", # `mach`, dependency of `serialport`, only affects MacOS
"RUSTSEC-2023-0071", # `rsa`, decryption is vulnerable to timing attack. We only sign/verify.
]
Loading

0 comments on commit 140185f

Please sign in to comment.