[test] Add rom_e2e_bootstrap_phase1_page_program
Fixes #14460
Signed-off-by: Alphan Ulusoy <alphan@google.com>
diff --git a/sw/device/silicon_creator/rom/data/rom_testplan.hjson b/sw/device/silicon_creator/rom/data/rom_testplan.hjson
index b45503d..e4ba577 100644
--- a/sw/device/silicon_creator/rom/data/rom_testplan.hjson
+++ b/sw/device/silicon_creator/rom/data/rom_testplan.hjson
@@ -310,12 +310,14 @@
- Apply bootstrap pin strapping.
- Reset the chip.
- - Write `0x4552544f` (ASCII "OTRE") at byte offset `0x334`.
- - Write `0x1` at byte offset `0x374`.
+ - Write `0x4552544f_00000000` (ASCII "\0\0\0\0OTRE") at byte offset `0x80330`.
+ - Note: Writes must start at a flash-word-aligned address and we
+ must write to the second slot since ROM returns the last error.
- Reset the chip.
- - Verify that the chip outputs the expected `BFV`: `0142500d` over UART.
- - If the write succeeds, which shouldn't happen, ROM outputs `024d410d`
- (`kErrorManifestBadCodeRegion`).
+ - Verify that the chip outputs the expected `BFV`: `0142500d` over
+ UART (`kErrorBootPolicyBadIdentifier').
+ - If the write succeeds, which shouldn't happen, ROM outputs `0242500d`
+ (`kErrorBootPolicyBadLength`).
- ROM will continously reset the chip and output the same `BFV` and `LCV`.
'''
tags: ["rom", "verilator", "dv", "fpga", "silicon"]
diff --git a/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs b/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs
index c11d9c5..6067ba7 100644
--- a/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs
+++ b/sw/host/tests/rom/e2e_bootstrap_entry/src/main.rs
@@ -311,6 +311,36 @@
Ok(())
}
+fn test_bootstrap_phase1_page_program(opts: &Opts, transport: &TransportWrapper) -> Result<()> {
+ let _bs = BootstrapTest::start(transport, opts.init.bootstrap.options.reset_delay)?;
+
+ let spi = transport.spi("0")?;
+ let uart = transport.uart("0")?;
+ let mut console = UartConsole {
+ timeout: Some(Duration::new(1, 0)),
+ // `kErrorBootPolicyBadIdentifier` (0142500d) is defined in `error.h`.
+ exit_success: Some(Regex::new("BFV:0142500d\r\n")?),
+ // `kErrorBootPolicyBadLength` (0242500d) is defined in `error.h`.
+ exit_failure: Some(Regex::new("BFV:0242500d\r\n")?),
+ ..Default::default()
+ };
+ SpiFlash::from_spi(&*spi)?
+ // Write "OTRE" to the identifier field of the manifest in the second slot.
+ // Note: We must start at a flash-word-aligned address.
+ .program(&*spi, 0x80330, &0x4552544f_00000000u64.to_le_bytes())?;
+ // Remove strapping so that chip fails to boot instead of going into bootstrap.
+ transport.remove_pin_strapping("ROM_BOOTSTRAP")?;
+ transport.reset_target(opts.init.bootstrap.options.reset_delay, true)?;
+
+ // We should see the expected BFV.
+ let result = console.interact(&*uart, None, Some(&mut std::io::stdout()))?;
+ if result != ExitStatus::ExitSuccess {
+ bail!("FAIL: {:?}", result);
+ }
+
+ Ok(())
+}
+
fn main() -> Result<()> {
let opts = Opts::from_args();
opts.init.init_logging();
@@ -330,6 +360,7 @@
execute_test!(test_bootstrap_shutdown, &opts, &transport, cmd, bfv);
}
execute_test!(test_bootstrap_phase1_reset, &opts, &transport);
+ execute_test!(test_bootstrap_phase1_page_program, &opts, &transport);
Ok(())
}