mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-01 06:27:29 +00:00
spi_flash: fix stale read issue for memory mapped partition
On flash program operation (either erase or write), if corresponding address has cache mapping present then cache is explicitly flushed (for both pro and app cpu) Closes https://github.com/espressif/esp-idf/issues/2146
This commit is contained in:
@@ -253,6 +253,11 @@ esp_err_t IRAM_ATTR spi_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
}
|
||||
}
|
||||
COUNTER_STOP(erase);
|
||||
|
||||
spi_flash_guard_start();
|
||||
spi_flash_check_and_flush_cache(start_addr, size);
|
||||
spi_flash_guard_end();
|
||||
|
||||
return spi_flash_translate_rc(rc);
|
||||
}
|
||||
|
||||
@@ -419,9 +424,9 @@ esp_err_t IRAM_ATTR spi_flash_write(size_t dst, const void *srcv, size_t size)
|
||||
out:
|
||||
COUNTER_STOP(write);
|
||||
|
||||
spi_flash_guard_op_lock();
|
||||
spi_flash_mark_modified_region(dst, size);
|
||||
spi_flash_guard_op_unlock();
|
||||
spi_flash_guard_start();
|
||||
spi_flash_check_and_flush_cache(dst, size);
|
||||
spi_flash_guard_end();
|
||||
|
||||
return spi_flash_translate_rc(rc);
|
||||
}
|
||||
@@ -485,9 +490,9 @@ esp_err_t IRAM_ATTR spi_flash_write_encrypted(size_t dest_addr, const void *src,
|
||||
COUNTER_ADD_BYTES(write, size);
|
||||
COUNTER_STOP(write);
|
||||
|
||||
spi_flash_guard_op_lock();
|
||||
spi_flash_mark_modified_region(dest_addr, size);
|
||||
spi_flash_guard_op_unlock();
|
||||
spi_flash_guard_start();
|
||||
spi_flash_check_and_flush_cache(dest_addr, size);
|
||||
spi_flash_guard_end();
|
||||
|
||||
return spi_flash_translate_rc(rc);
|
||||
}
|
||||
|
Reference in New Issue
Block a user