Skip to content

Commit 8a8922a

Browse files
authored
humility ibc black-box should skip empty events (#434)
1 parent 67d932e commit 8a8922a

File tree

5 files changed

+50
-15
lines changed

5 files changed

+50
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ name = "humility"
1717
#
1818
# Be sure to check in and push all of the files that change. Happy versioning!
1919
#
20-
version = "0.10.34"
20+
version = "0.10.35"
2121
authors = ["Bryan Cantrill <[email protected]>"]
2222
edition = "2018"
2323
license = "MPL-2.0"

cmd/ibc/src/lib.rs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,29 +211,40 @@ impl<'a> IbcHandler<'a> {
211211
Err(e) => bail!("Failed to read event {i}: {e}"),
212212
}
213213
}
214+
let mut base_timestamp: u32 = 0;
214215
for i in 0..=newest_fault_event_index {
215216
let e = events[i as usize];
216217
println!("{}", "FAULT EVENT".red());
217218
println!(" EVENT_INDEX: {i}");
218-
self.print_event(e, verbose, vout_mode);
219+
self.print_event(e, verbose, vout_mode, &mut base_timestamp);
219220
}
220221
for i in 24..=newest_lifecycle_event_index {
221222
let e = events[i as usize];
222223
println!("{}", "LIFECYCLE EVENT".green());
223224
println!(" EVENT_INDEX: {i}");
224-
self.print_event(e, verbose, vout_mode);
225+
self.print_event(e, verbose, vout_mode, &mut base_timestamp);
225226
}
226227

227228
Ok(())
228229
}
229230

230-
fn print_event(&self, e: IbcEvent, verbose: bool, vout_mode: u8) {
231-
println!(
232-
" TIMESTAMP {:#010x} = {}",
233-
e.timestamp.get(),
234-
Self::format_time(e.timestamp.get())
235-
);
236-
println!(" EVENT_ID {:#06x}", e.event_id.get());
231+
fn print_event(
232+
&self,
233+
e: IbcEvent,
234+
verbose: bool,
235+
vout_mode: u8,
236+
base_timestamp: &mut u32,
237+
) {
238+
// In that case that a log contains no entries, the newest event index
239+
// reported will be the lowest slot for the log type, which will be
240+
// empty. Reading an empty event will return 0xFF in all bytes.
241+
if e.timestamp.get() == u32::MAX
242+
&& e.event_id.get() == u16::MAX
243+
&& e.status_word.get() == u16::MAX
244+
{
245+
println!(" EMPTY");
246+
return;
247+
}
237248

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

252263
let status_word = e.status_word.get();
264+
265+
// When a BOOT_EVENT or TIME_ERASE_EVENT is seen, record the timestamp
266+
// so that the times for following events can be displayed relative to
267+
// this.
268+
if e.status_word.get() == 1 && (e.status_mfr == 0 || e.status_mfr == 6)
269+
{
270+
*base_timestamp = e.timestamp.get();
271+
}
272+
273+
if *base_timestamp != 0 && *base_timestamp <= e.timestamp.get() {
274+
println!(
275+
" TIMESTAMP {:#010x} = +{}",
276+
e.timestamp.get(),
277+
Self::format_time(e.timestamp.get() - *base_timestamp)
278+
);
279+
} else {
280+
println!(
281+
" TIMESTAMP {:#010x} = {}",
282+
e.timestamp.get(),
283+
Self::format_time(e.timestamp.get())
284+
);
285+
}
286+
println!(" EVENT_ID {:#06x}", e.event_id.get());
287+
253288
println!(" STATUS_WORD {:#06x}", status_word);
254289
for (bit, name) in [
255290
(0, "System event"),

tests/cmd/chip.trycmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For more information try --help
1313

1414
```
1515
$ humility --chip this-can-be-anything -V
16-
humility 0.10.34
16+
humility 0.10.35
1717

1818
```
1919

@@ -28,7 +28,7 @@ For more information try --help
2828

2929
```
3030
$ humility -c apx432 -V
31-
humility 0.10.34
31+
humility 0.10.35
3232

3333
```
3434

tests/cmd/version.trycmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ Long version flag:
22

33
```
44
$ humility --version
5-
humility 0.10.34
5+
humility 0.10.35
66

77
```
88

99
Short version flag:
1010

1111
```
1212
$ humility -V
13-
humility 0.10.34
13+
humility 0.10.35
1414

1515
```

0 commit comments

Comments
 (0)