Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

humility ibc black-box should skip empty events #434

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 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 @@ -17,7 +17,7 @@ name = "humility"
#
# Be sure to check in and push all of the files that change. Happy versioning!
#
version = "0.10.34"
version = "0.10.35"
authors = ["Bryan Cantrill <bryan@oxide.computer>"]
edition = "2018"
license = "MPL-2.0"
Expand Down
53 changes: 44 additions & 9 deletions cmd/ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,40 @@ impl<'a> IbcHandler<'a> {
Err(e) => bail!("Failed to read event {i}: {e}"),
}
}
let mut base_timestamp: u32 = 0;
for i in 0..=newest_fault_event_index {
let e = events[i as usize];
println!("{}", "FAULT EVENT".red());
println!(" EVENT_INDEX: {i}");
self.print_event(e, verbose, vout_mode);
self.print_event(e, verbose, vout_mode, &mut base_timestamp);
}
for i in 24..=newest_lifecycle_event_index {
let e = events[i as usize];
println!("{}", "LIFECYCLE EVENT".green());
println!(" EVENT_INDEX: {i}");
self.print_event(e, verbose, vout_mode);
self.print_event(e, verbose, vout_mode, &mut base_timestamp);
}

Ok(())
}

fn print_event(&self, e: IbcEvent, verbose: bool, vout_mode: u8) {
println!(
" TIMESTAMP {:#010x} = {}",
e.timestamp.get(),
Self::format_time(e.timestamp.get())
);
println!(" EVENT_ID {:#06x}", e.event_id.get());
fn print_event(
&self,
e: IbcEvent,
verbose: bool,
vout_mode: u8,
base_timestamp: &mut u32,
) {
// In that case that a log contains no entries, the newest event index
// reported will be the lowest slot for the log type, which will be
// empty. Reading an empty event will return 0xFF in all bytes.
if e.timestamp.get() == u32::MAX
&& e.event_id.get() == u16::MAX
&& e.status_word.get() == u16::MAX
{
println!(" EMPTY");
return;
}

// Decoding is extracted from revision A and B of the datasheet, which
// contain non-overlapping sets of decoding information. They don't
Expand All @@ -250,6 +261,30 @@ impl<'a> IbcHandler<'a> {
// 28710-FGB 100 378 Rev A (Application Note 326), May 2023

let status_word = e.status_word.get();

// When a BOOT_EVENT or TIME_ERASE_EVENT is seen, record the timestamp
// so that the times for following events can be displayed relative to
// this.
if e.status_word.get() == 1 && (e.status_mfr == 0 || e.status_mfr == 6)
{
*base_timestamp = e.timestamp.get();
}

if *base_timestamp != 0 && *base_timestamp <= e.timestamp.get() {
println!(
" TIMESTAMP {:#010x} = +{}",
e.timestamp.get(),
Self::format_time(e.timestamp.get() - *base_timestamp)
);
} else {
println!(
" TIMESTAMP {:#010x} = {}",
e.timestamp.get(),
Self::format_time(e.timestamp.get())
);
}
println!(" EVENT_ID {:#06x}", e.event_id.get());

println!(" STATUS_WORD {:#06x}", status_word);
for (bit, name) in [
(0, "System event"),
Expand Down
4 changes: 2 additions & 2 deletions tests/cmd/chip.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For more information try --help

```
$ humility --chip this-can-be-anything -V
humility 0.10.34
humility 0.10.35

```

Expand All @@ -28,7 +28,7 @@ For more information try --help

```
$ humility -c apx432 -V
humility 0.10.34
humility 0.10.35

```

4 changes: 2 additions & 2 deletions tests/cmd/version.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Long version flag:

```
$ humility --version
humility 0.10.34
humility 0.10.35

```

Short version flag:

```
$ humility -V
humility 0.10.34
humility 0.10.35

```