Skip to content

Commit

Permalink
Use firmware.valid to Check Firmware Validity Before Upgrade (#57)
Browse files Browse the repository at this point in the history
This takes into account FW versions that don't have this attribute.
Gives feedback to the user if the image was found to be invalid.
  • Loading branch information
esarver authored Jan 28, 2025
1 parent e5a0f14 commit a30188a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
### Changed

- Reduce amount of default logging
- Use new `firmware.valid` attribute to gate firmware update

### Added

Expand Down
31 changes: 15 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ serde_json = "1.0.114"
thiserror = "2.0.3"
tracing = { version = "0.1.40", features = ["async-await"] }
tracing-subscriber = { version = "0.3.18", features = ["json"] }
tsp-toolkit-kic-lib = { git = "https://github.com/tektronix/tsp-toolkit-kic-lib.git", tag = "v0.19.4" }
tsp-toolkit-kic-lib = { git = "https://github.com/tektronix/tsp-toolkit-kic-lib.git", tag = "v0.19.5-0" }

[workspace.lints.rust]
warnings = "deny"
Expand Down
34 changes: 22 additions & 12 deletions instrument-repl/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::{
};
use tracing::{debug, error, info, instrument, trace, warn};

use tsp_toolkit_kic_lib::instrument::Instrument;
use tsp_toolkit_kic_lib::{instrument::Instrument, InstrumentError};

use crate::{
command::Request,
Expand Down Expand Up @@ -299,7 +299,7 @@ impl Repl {
if slot.is_some_and(|s| s > 0) {
// Upgrading Module
Self::println_flush(
&"Sending firmware file to mainframe. Please wait for module upgrade to complete (2-5 minutes)..."
&"Sending firmware file to mainframe. Please wait for module upgrade to complete (up to 10 minutes)..."
.bright_yellow(),
)?;
} else {
Expand All @@ -308,16 +308,26 @@ impl Repl {
.bright_yellow(),
)?;
}
self.inst.flash_firmware(contents.as_ref(), slot)?;
if slot.is_some_and(|s| s > 0) {
// Upgrading Module
Self::println_flush(&"Module upgrade complete.".bright_yellow())?;
} else {
Self::println_flush(
&"Firmware file download complete.".bright_yellow(),
)?;
// Upgrading Mainframe
Self::println_flush(&"Close the terminal (.exit) and reconnect after the instrument has restarted.".bright_yellow())?;
match self.inst.flash_firmware(contents.as_ref(), slot) {
Ok(()) => {
if slot.is_some_and(|s| s > 0) {
// Upgrading Module
Self::println_flush(
&"Module upgrade complete.".bright_yellow(),
)?;
} else {
Self::println_flush(
&"Firmware file download complete.".bright_yellow(),
)?;
// Upgrading Mainframe
Self::println_flush(&"Close the terminal (.exit) and reconnect after the instrument has restarted.".bright_yellow())?;
}
}
Err(InstrumentError::FwUpgradeFailure(msg)) => {
error!("{msg}");
Self::println_flush(&msg.red())?;
}
Err(e) => return Err(e.into()),
}
// Flashing FW disables prompts before flashing but might
// lose runtime state, so we can't save the previous
Expand Down

0 comments on commit a30188a

Please sign in to comment.