mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
fix(mmap): fixed some API read wrong data via mmap when flash being erased/written while XIP on PSRAM
Before: The cache won't be disabled when XIP on psram. But during flash erasing/programming, read data will be courrupt. When XIP in psram is enabled, the image is not mapped to the cache so usually there will be no flash access. The only way to read from flash is via the driver or use mmap. The driver has protection during erasing, while th mmap region not. Now: Mmap APIs provide a flag to make mmap->unmap region mutually exclusive to flash erase/programming when XIP from psram. SPI Flash write APIs will benefit from this. When the flag is used, no concurrent access to mapped region will happen while writing; otherwise the cache will be disable to avoid data corruption. Most ESP-IDF APIs calls mmap with this flag. As for users calling mmap-like APIs directly, they can choose whether to enable this by a flag. Closes https://github.com/espressif/esp-idf/issues/14897
This commit is contained in:
committed by
Michael (XIAO Xufeng)
parent
39a219331c
commit
3e8389cc31
@@ -31,6 +31,10 @@ typedef struct esp_flash_os_functions_t {
|
||||
/** Limit CPU frequency during flash operations (ESP32-C5 only, 240MHz).
|
||||
*/
|
||||
#define ESP_FLASH_START_FLAG_LIMIT_CPU_FREQ BIT(0)
|
||||
/** Indicates that this operation forbids flash from being read (e.g., write/erase).
|
||||
* The OS layer implementation needs to take appropriate measures to avoid concurrent read operations.
|
||||
*/
|
||||
#define ESP_FLASH_START_FLAG_NO_READ BIT(1)
|
||||
/**
|
||||
* Called before commencing any flash operation. Does not need to be
|
||||
* recursive (ie is called at most once for each call to 'end').
|
||||
|
||||
Reference in New Issue
Block a user