[sw/silicon_creator] Clear status bits after ignored cmds in bootstrap phase 1
Fixes #14871
Signed-off-by: Alphan Ulusoy <alphan@google.com>
diff --git a/sw/device/silicon_creator/rom/bootstrap.c b/sw/device/silicon_creator/rom/bootstrap.c
index fdb3aa5..0ec2c6e 100644
--- a/sw/device/silicon_creator/rom/bootstrap.c
+++ b/sw/device/silicon_creator/rom/bootstrap.c
@@ -231,14 +231,16 @@
error = bootstrap_chip_erase();
HARDENED_RETURN_IF_ERROR(error);
*state = kBootstrapStateEraseVerify;
+ // Note: We clear WIP and WEN bits in `bootstrap_handle_erase_verify()`
+ // after checking that both data banks have been erased.
break;
default:
- // Ignore any other command, e.g. PAGE_PROGRAM, RESET.
+ // Ignore any other command, e.g. PAGE_PROGRAM, RESET, and clear WIP and
+ // WEN bits right away.
+ spi_device_flash_status_clear();
error = kErrorOk;
}
- // Note: We clear WIP and WEN bits in `bootstrap_handle_erase_verify()` after
- // checking that both data banks have been erased.
return error;
}
diff --git a/sw/device/silicon_creator/rom/bootstrap_unittest.cc b/sw/device/silicon_creator/rom/bootstrap_unittest.cc
index 3de843a..1f3f987 100644
--- a/sw/device/silicon_creator/rom/bootstrap_unittest.cc
+++ b/sw/device/silicon_creator/rom/bootstrap_unittest.cc
@@ -471,20 +471,21 @@
}
TEST_F(BootstrapTest, IgnoredCommands) {
- // Erase
+ // Phase 1: Erase
ExpectBootstrapRequestCheck(true);
EXPECT_CALL(spi_device_, Init());
ExpectSpiCmd(ChipEraseCmd()); // Ignored, missing WREN.
ExpectSpiFlashStatusGet(false);
ExpectSpiCmd(ResetCmd()); // Ignored, not supported.
ExpectSpiFlashStatusGet(true);
+ EXPECT_CALL(spi_device_, FlashStatusClear());
ExpectSpiCmd(ChipEraseCmd());
ExpectSpiFlashStatusGet(true);
ExpectFlashCtrlChipErase(kErrorOk, kErrorOk);
- // Verify
+ // Phase 1: Verify
ExpectFlashCtrlEraseVerify(kErrorOk, kErrorOk);
EXPECT_CALL(spi_device_, FlashStatusClear());
- // Erase/Program
+ // Phase 2: Erase/Program
ExpectSpiCmd(SectorEraseCmd(0));
ExpectSpiFlashStatusGet(false);
ExpectSpiCmd(ChipEraseCmd());