mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +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:
committed by
Michael (XIAO Xufeng)
parent
00c8f05ebf
commit
ecab1fec19
@@ -341,8 +341,8 @@ esp_err_t esp_psram_impl_enable(void)
|
||||
s_set_psram_cs_timing();
|
||||
s_configure_psram_ecc();
|
||||
|
||||
//enter MSPI slow mode to init PSRAM device registers
|
||||
mspi_timing_enter_low_speed_mode(true);
|
||||
//enter MSPI slow mode to init PSRAM device registers (early init: see mspi_timing_enter_low_speed_early)
|
||||
mspi_timing_enter_low_speed_early();
|
||||
|
||||
//set to variable dummy mode
|
||||
SET_PERI_REG_MASK(SPI_MEM_DDR_REG(1), SPI_MEM_SPI_FMEM_VAR_DUMMY);
|
||||
@@ -377,7 +377,7 @@ esp_err_t esp_psram_impl_enable(void)
|
||||
//Do PSRAM timing tuning, we use SPI1 to do the tuning, and set the SPI0 PSRAM timing related registers accordingly
|
||||
mspi_timing_psram_tuning();
|
||||
//Back to the high speed mode. Flash/PSRAM clocks are set to the clock that user selected. SPI0/1 registers are all set correctly
|
||||
mspi_timing_enter_high_speed_mode(true);
|
||||
mspi_timing_enter_high_speed_early();
|
||||
|
||||
/**
|
||||
* Tuning may change SPI1 regs, whereas legacy spi_flash APIs rely on these regs.
|
||||
|
||||
@@ -327,8 +327,8 @@ esp_err_t esp_psram_impl_enable(void) //psram init
|
||||
psram_gpio_config();
|
||||
psram_set_cs_timing();
|
||||
|
||||
//enter MSPI slow mode to init PSRAM device registers
|
||||
mspi_timing_enter_low_speed_mode(true);
|
||||
//enter MSPI slow mode to init PSRAM device registers (early init: see mspi_timing_enter_low_speed_early)
|
||||
mspi_timing_enter_low_speed_early();
|
||||
|
||||
//We use SPI1 to init PSRAM
|
||||
psram_disable_qio_mode(SPI1_NUM);
|
||||
@@ -369,7 +369,7 @@ esp_err_t esp_psram_impl_enable(void) //psram init
|
||||
//Configure SPI0 PSRAM related SPI Phases
|
||||
config_psram_spi_phases();
|
||||
//Back to the high speed mode. Flash/PSRAM clocks are set to the clock that user selected. SPI0/1 registers are all set correctly
|
||||
mspi_timing_enter_high_speed_mode(true);
|
||||
mspi_timing_enter_high_speed_early();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user