Skip to content

Commit e3c01a1

Browse files
committed
[FPGA]: Wait for cold boot complete in model harness
This reduces race conditions for the mailbox lock.
1 parent 4312e42 commit e3c01a1

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

hw-model/src/model_fpga_subsystem.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ pub struct ModelFpgaSubsystem {
476476
}
477477

478478
impl ModelFpgaSubsystem {
479+
fn mci_boot_milestones(&mut self) -> McuBootMilestones {
480+
McuBootMilestones::from((self.mci_flow_status() >> 16) as u16)
481+
}
482+
479483
fn set_bootfsm_break(&mut self, val: bool) {
480484
if val {
481485
self.wrapper
@@ -1758,10 +1762,6 @@ impl ModelFpgaSubsystem {
17581762
(self.mci_flow_status() & 0x0000_ffff) as u16
17591763
}
17601764

1761-
pub fn mci_boot_milestones(&mut self) -> McuBootMilestones {
1762-
McuBootMilestones::from((self.mci_flow_status() >> 16) as u16)
1763-
}
1764-
17651765
fn caliptra_axi_bus(&mut self) -> Option<FpgaRealtimeBus<'_>> {
17661766
self.mmio.caliptra_axi_bus()
17671767
}
@@ -2339,7 +2339,13 @@ impl HwModel for ModelFpgaSubsystem {
23392339
// MCU ROM will wait after reaching the mailbox for this bit before booting RT
23402340
gpio.set(current | 1 << 31);
23412341

2342-
// ironically, we don't need to support this
2342+
// Wait for MCU to finish cold boot (including ROM integrity check)
2343+
// to avoid mailbox contention with the host.
2344+
self.step_until(|m| {
2345+
m.mci_boot_milestones()
2346+
.contains(McuBootMilestones::COLD_BOOT_FLOW_COMPLETE)
2347+
});
2348+
23432349
Ok(())
23442350
}
23452351

0 commit comments

Comments
 (0)