Skip to content

Commit 5f348c0

Browse files
committed
include current state of transient override in RotBootInfo
1 parent cfb23ab commit 5f348c0

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

drv/lpc55-update-server/src/main.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,7 @@ impl ServerImpl<'_> {
637637
None
638638
};
639639

640-
// We only support persistent override at this point
641-
// We need to read the magic ram value to fill this in.
642-
let transient_boot_preference = None;
640+
let transient_boot_preference = get_hubris_transient_override();
643641

644642
Ok((
645643
persistent_boot_preference,
@@ -1361,17 +1359,23 @@ fn set_transient_override(preference: [u8; 32]) {
13611359
}
13621360
}
13631361

1364-
pub fn set_hubris_transient_override(bank: Option<SlotId>) {
1365-
// Preference constants are taken from bootleby:src/lib.rs
1366-
const PREFER_SLOT_A: [u8; 32] = hex!(
1367-
"edb23f2e9b399c3d57695262f29615910ed10c8d9b261bfc2076b8c16c84f66d"
1368-
);
1369-
const PREFER_SLOT_B: [u8; 32] = hex!(
1370-
"70ed2914e6fdeeebbb02763b96da9faa0160b7fc887425f4d45547071d0ce4ba"
1371-
);
1372-
// Bootleby writes all zeros after reading. We write all ones to reset.
1373-
const PREFER_NOTHING: [u8; 32] = [0xffu8; 32];
1362+
fn get_transient_override() -> [u8; 32] {
1363+
// Safety: Data is consumed by Bootleby on next boot.
1364+
// There are no concurrent writers possible.
1365+
// Bootleby consumes and resets TRANSIENT_OVERRIDE.
1366+
// The client may be verifying state set during update flows.
1367+
unsafe { TRANSIENT_OVERRIDE.assume_init() }
1368+
}
1369+
1370+
// Preference constants are taken from bootleby:src/lib.rs
1371+
const PREFER_SLOT_A: [u8; 32] =
1372+
hex!("edb23f2e9b399c3d57695262f29615910ed10c8d9b261bfc2076b8c16c84f66d");
1373+
const PREFER_SLOT_B: [u8; 32] =
1374+
hex!("70ed2914e6fdeeebbb02763b96da9faa0160b7fc887425f4d45547071d0ce4ba");
1375+
// Bootleby writes all zeros after reading. We write all ones to reset.
1376+
const PREFER_NOTHING: [u8; 32] = [0xffu8; 32];
13741377

1378+
pub fn set_hubris_transient_override(bank: Option<SlotId>) {
13751379
match bank {
13761380
// Do we need a value that says we were here and cleared?
13771381
None => set_transient_override(PREFER_NOTHING),
@@ -1380,6 +1384,14 @@ pub fn set_hubris_transient_override(bank: Option<SlotId>) {
13801384
}
13811385
}
13821386

1387+
pub fn get_hubris_transient_override() -> Option<SlotId> {
1388+
match get_transient_override() {
1389+
PREFER_SLOT_A => Some(SlotId::A),
1390+
PREFER_SLOT_B => Some(SlotId::B),
1391+
_ => None,
1392+
}
1393+
}
1394+
13831395
fn round_up_to_flash_page(offset: u32) -> Option<u32> {
13841396
offset.checked_next_multiple_of(BYTES_PER_FLASH_PAGE as u32)
13851397
}

0 commit comments

Comments
 (0)