mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
fix(spi_flash): Fix flash encryption write verify,
Closes https://github.com/espressif/esp-idf/issues/15380
This commit is contained in:
@ -176,6 +176,8 @@ menu "SPI Flash driver"
|
|||||||
back and verified. This can catch hardware problems with SPI flash, or flash which
|
back and verified. This can catch hardware problems with SPI flash, or flash which
|
||||||
was not erased before verification.
|
was not erased before verification.
|
||||||
|
|
||||||
|
This will slightly influence the write performance.
|
||||||
|
|
||||||
config SPI_FLASH_LOG_FAILED_WRITE
|
config SPI_FLASH_LOG_FAILED_WRITE
|
||||||
bool "Log errors if verification fails"
|
bool "Log errors if verification fails"
|
||||||
depends on SPI_FLASH_VERIFY_WRITE
|
depends on SPI_FLASH_VERIFY_WRITE
|
||||||
|
@ -1378,11 +1378,31 @@ esp_err_t IRAM_ATTR esp_flash_write_encrypted(esp_flash_t *chip, uint32_t addres
|
|||||||
COUNTER_ADD_BYTES(write, encrypt_byte);
|
COUNTER_ADD_BYTES(write, encrypt_byte);
|
||||||
|
|
||||||
#if CONFIG_SPI_FLASH_VERIFY_WRITE
|
#if CONFIG_SPI_FLASH_VERIFY_WRITE
|
||||||
|
|
||||||
|
if (lock_once == true) {
|
||||||
|
err = s_encryption_write_unlock(chip);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
bus_acquired = false;
|
||||||
|
//Error happens, we end flash operation. Re-enable cache and flush it
|
||||||
|
goto restore_cache;
|
||||||
|
}
|
||||||
|
bus_acquired = false;
|
||||||
|
}
|
||||||
err = s_verify_write(chip, row_addr, encrypt_byte, (uint32_t *)encrypt_buf, is_encrypted);
|
err = s_verify_write(chip, row_addr, encrypt_byte, (uint32_t *)encrypt_buf, is_encrypted);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
//Error happens, we end flash operation. Re-enable cache and flush it
|
//Error happens, we end flash operation. Re-enable cache and flush it
|
||||||
goto restore_cache;
|
goto restore_cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lock_once == true) {
|
||||||
|
err = s_encryption_write_lock(chip);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
bus_acquired = false;
|
||||||
|
//Error happens, we end flash operation. Re-enable cache and flush it
|
||||||
|
goto restore_cache;
|
||||||
|
}
|
||||||
|
bus_acquired = true;
|
||||||
|
}
|
||||||
#endif //CONFIG_SPI_FLASH_VERIFY_WRITE
|
#endif //CONFIG_SPI_FLASH_VERIFY_WRITE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ from pytest_embedded import Dut
|
|||||||
'config',
|
'config',
|
||||||
[
|
[
|
||||||
'release',
|
'release',
|
||||||
|
'verify',
|
||||||
],
|
],
|
||||||
indirect=True,
|
indirect=True,
|
||||||
)
|
)
|
||||||
@ -38,6 +39,7 @@ def test_flash_encryption_rom_impl(dut: Dut) -> None:
|
|||||||
[
|
[
|
||||||
'release_f4r8',
|
'release_f4r8',
|
||||||
'rom_impl',
|
'rom_impl',
|
||||||
|
'verify',
|
||||||
],
|
],
|
||||||
indirect=True,
|
indirect=True,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user