Skip to content

Commit 5f3492d

Browse files
authored
Add special-case handling for measurement token handoff (#552)
Without this change, the SP's "multiple seconds of resets" in oxidecomputer/hubris#2138 cause Humility to time out. We could increase Humility's timeout, but having an explicit SKIP token seems like a cleaner solution; with the SWD dongle attached, the SP is definitely not getting measured!
1 parent 4ea30b7 commit 5f3492d

8 files changed

Lines changed: 33 additions & 9 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ hif = { git = "https://github.com/oxidecomputer/hif" }
8787
humpty = { git = "https://github.com/oxidecomputer/humpty", version = "0.1.3" }
8888
idol = {git = "https://github.com/oxidecomputer/idolatry.git"}
8989
idt8a3xxxx = { git = "https://github.com/oxidecomputer/idt8a3xxxx" }
90+
measurement-token = { git = "https://github.com/oxidecomputer/lpc55_support", default-features = false }
9091
pmbus = { git = "https://github.com/oxidecomputer/pmbus" }
91-
spd = { git = "https://github.com/oxidecomputer/spd" }
9292
serialport = { git = "https://github.com/jgallagher/serialport-rs", branch = "illumos-support" }
93+
spd = { git = "https://github.com/oxidecomputer/spd" }
9394
tlvc = { git = "https://github.com/oxidecomputer/tlvc" }
9495
tlvc-text = {git = "https://github.com/oxidecomputer/tlvc"}
9596
vsc7448-info = { git = "https://github.com/oxidecomputer/vsc7448.git" }

cmd/flash/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ humility-probes-core = { workspace = true }
1313
cmd-auxflash = { workspace = true }
1414
clap = { workspace = true }
1515
anyhow = { workspace = true }
16+
measurement-token = { workspace = true }
1617
parse_int = { workspace = true }
1718
num-traits = { workspace = true }
1819
tempfile = { workspace = true }

cmd/flash/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,23 @@ fn flashcmd(context: &mut ExecutionContext) -> Result<()> {
403403
std::thread::sleep(std::time::Duration::from_millis(delay));
404404
}
405405

406-
core.reset()?;
406+
// If this image uses handoff to send a measurement token between the RoT
407+
// and SP, this won't work with a debugger physically attached. To prevent
408+
// the SP from resetting itself, we write a different token which skips this
409+
// reboot loop. The memory address and token values are pulled from the
410+
// `measurement-token` crate in `lpc55_support`, which is also used in the
411+
// SP firmware.
412+
if hubris.manifest.features.iter().any(|s| s == "measurement-handoff") {
413+
core.reset_and_halt(std::time::Duration::from_millis(25))?;
414+
humility::msg!("skipping measurement token handoff");
415+
core.write_word_32(
416+
measurement_token::SP_ADDR as u32,
417+
measurement_token::SKIP,
418+
)?;
419+
core.run()?;
420+
} else {
421+
core.reset()?;
422+
}
407423

408424
// At this point, we can attempt to program the auxiliary flash. This has
409425
// to happen *after* the image is flashed and the core is reset, because it

humility-bin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
[package]
1919
name = "humility-bin"
20-
version = "0.12.6"
20+
version = "0.12.7"
2121
edition = "2021"
2222
license = "MPL-2.0"
2323
rust-version = "1.68"

humility-bin/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.12.6
16+
humility 0.12.7
1717

1818
```
1919

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

2929
```
3030
$ humility -c apx432 -V
31-
humility 0.12.6
31+
humility 0.12.7
3232

3333
```
3434

humility-bin/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.12.6
5+
humility 0.12.7
66

77
```
88

99
Short version flag:
1010

1111
```
1212
$ humility -V
13-
humility 0.12.6
13+
humility 0.12.7
1414

1515
```

humility-core/src/hubris.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const OXIDE_NT_HUBRIS_ARCHIVE: u32 = OXIDE_NT_BASE + 1;
4040
const OXIDE_NT_HUBRIS_REGISTERS: u32 = OXIDE_NT_BASE + 2;
4141
const OXIDE_NT_HUBRIS_TASK: u32 = OXIDE_NT_BASE + 3;
4242

43-
const MAX_HUBRIS_VERSION: u32 = 9;
43+
const MAX_HUBRIS_VERSION: u32 = 10;
4444

4545
#[derive(Default, Debug, Serialize)]
4646
pub struct HubrisManifest {

0 commit comments

Comments
 (0)