fix(storage/esp_partition): add option to control erase check during write for linux target

This commit is contained in:
Tomáš Rohlínek
2024-02-27 12:38:10 +01:00
parent 6e20be1d95
commit f753434640
2 changed files with 11 additions and 0 deletions

View File

@@ -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];