mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(storage/esp_partition): add option to control erase check during write for linux target
This commit is contained in:
parent
6e20be1d95
commit
f753434640
@ -7,4 +7,13 @@ menu "Partition API Configuration"
|
||||
help
|
||||
This option enables gathering host test statistics and SPI flash wear levelling simulation.
|
||||
|
||||
config ESP_PARTITION_ERASE_CHECK
|
||||
bool "Check if flash is erased before writing"
|
||||
depends on IDF_TARGET_LINUX
|
||||
default y
|
||||
help
|
||||
This option controls whether the partition implementation checks
|
||||
if the flash is erased before writing to it.
|
||||
This is necessary for SPIFFS, which expects to be able to write without erasing first.
|
||||
|
||||
endmenu
|
||||
|
@ -396,12 +396,14 @@ esp_err_t esp_partition_write(const esp_partition_t *partition, size_t dst_offse
|
||||
|
||||
for (size_t x = 0; x < new_size; x++) {
|
||||
|
||||
#ifdef CONFIG_ESP_PARTITION_ERASE_CHECK
|
||||
// Check if address to be written was erased first
|
||||
if((~((uint8_t *)dst_addr)[x] & ((uint8_t *)src)[x]) != 0) {
|
||||
ESP_LOGW(TAG, "invalid flash operation detected");
|
||||
ret = ESP_ERR_FLASH_OP_FAIL;
|
||||
break;
|
||||
}
|
||||
#endif // CONFIG_ESP_PARTITION_ERASE_CHECK
|
||||
|
||||
// AND with destination byte (to emulate real NOR FLASH behavior)
|
||||
((uint8_t *)dst_addr)[x] &= ((uint8_t *)src)[x];
|
||||
|
Loading…
Reference in New Issue
Block a user