diff --git a/components/esp_partition/Kconfig b/components/esp_partition/Kconfig index 6a0159bc2a..9fa838f5bc 100644 --- a/components/esp_partition/Kconfig +++ b/components/esp_partition/Kconfig @@ -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 diff --git a/components/esp_partition/partition_linux.c b/components/esp_partition/partition_linux.c index 0a1379ef21..3cf497d367 100644 --- a/components/esp_partition/partition_linux.c +++ b/components/esp_partition/partition_linux.c @@ -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];