mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
fix(mspi): fixed possible boot failure in some builds when psram is enabled
A typical scenario is: when XIP on PSRAM enabled, compiler optimization level is Os. Under certain binary layout, boot hangs and backtrace points to `esp_sleep_config_gpio_isolate`. The root cause is that, during PSRAM initialization, it calls esp_gpio_reserve, which happens to place before the reported function. However, after call, there is no barrier before the clock adjustment in `mspi_timing_enter_low_speed_mode`. The clock gets changed when the cache is still fetching data, resulting in the corrupted data in the end of the cache line. This commits add spi_flash_disable_cache as a barrier to make sure the cache transactions is finished before the clock switch.
This commit is contained in:
@@ -36,6 +36,21 @@ uint32_t mspi_timing_get_psram_low_speed_freq_mhz(void);
|
||||
*/
|
||||
void mspi_timing_enter_high_speed_mode(bool control_spi1);
|
||||
|
||||
/**
|
||||
* @brief Switch MSPI to low speed while suspending external memory cache to avoid in-flight cache line fills across the
|
||||
* clock change.
|
||||
*
|
||||
* @note Early init only. Not safe for general runtime use: does not coordinate with other cores or freeze cache.
|
||||
*/
|
||||
void mspi_timing_enter_low_speed_early(void);
|
||||
|
||||
/**
|
||||
* @brief Switch MSPI to high speed while suspending external memory cache.
|
||||
*
|
||||
* @note Same usage constraints as @ref mspi_timing_enter_low_speed_early.
|
||||
*/
|
||||
void mspi_timing_enter_high_speed_early(void);
|
||||
|
||||
/**
|
||||
* @brief Switch MSPI into low speed mode / high speed mode.
|
||||
* @note This API is cache safe, it will freeze both D$ and I$ and restore them after MSPI is switched
|
||||
|
||||
Reference in New Issue
Block a user