[spi_passthru] Test write_status opcodes
Signed-off-by: Chris Frantz <cfrantz@google.com>
diff --git a/sw/host/opentitanlib/src/spiflash/flash.rs b/sw/host/opentitanlib/src/spiflash/flash.rs
index e8bad7e..615be32 100644
--- a/sw/host/opentitanlib/src/spiflash/flash.rs
+++ b/sw/host/opentitanlib/src/spiflash/flash.rs
@@ -64,6 +64,10 @@
// Winbond parts use 0x35 and 0x15 for extended status reads.
pub const READ_STATUS2: u8 = 0x35;
pub const READ_STATUS3: u8 = 0x15;
+ pub const WRITE_STATUS: u8 = 0x01;
+ // Winbond parts use 0x31 and 0x11 for extended status writes.
+ pub const WRITE_STATUS2: u8 = 0x31;
+ pub const WRITE_STATUS3: u8 = 0x11;
pub const READ_ID: u8 = 0x9f;
pub const ENTER_4B: u8 = 0xb7;
pub const EXIT_4B: u8 = 0xe9;
diff --git a/sw/host/tests/chip/spi_passthru/src/main.rs b/sw/host/tests/chip/spi_passthru/src/main.rs
index cb552dd..6ecece8 100644
--- a/sw/host/tests/chip/spi_passthru/src/main.rs
+++ b/sw/host/tests/chip/spi_passthru/src/main.rs
@@ -196,6 +196,21 @@
Ok(())
}
+fn test_write_status(opts: &Opts, transport: &TransportWrapper, opcode: u8) -> Result<()> {
+ let uart = transport.uart("console")?;
+ let spi = transport.spi(&opts.spi)?;
+ let info = UploadInfo::execute(&*uart, || {
+ spi.run_transaction(&mut [Transfer::Write(&[opcode])])?;
+ Ok(())
+ })?;
+
+ assert_eq!(info.opcode, opcode);
+ assert_eq!(info.has_address, false);
+ assert_eq!(info.data_len, 0);
+ assert_eq!(info.flash_status & FLASH_STATUS_STD_BITS, FLASH_STATUS_WIP);
+ Ok(())
+}
+
fn main() -> Result<()> {
let opts = Opts::from_args();
opts.init.init_logging();
@@ -212,5 +227,18 @@
execute_test!(test_read_status_extended, &opts, &transport);
execute_test!(test_read_sfdp, &opts, &transport);
execute_test!(test_chip_erase, &opts, &transport);
+ execute_test!(test_write_status, &opts, &transport, SpiFlash::WRITE_STATUS);
+ execute_test!(
+ test_write_status,
+ &opts,
+ &transport,
+ SpiFlash::WRITE_STATUS2
+ );
+ execute_test!(
+ test_write_status,
+ &opts,
+ &transport,
+ SpiFlash::WRITE_STATUS3
+ );
Ok(())
}