mspi: turn down freq to fix crash when sleep

This commit is contained in:
wanlei
2023-02-23 12:54:37 +08:00
parent 266a58f85b
commit d0c70aa7ac
2 changed files with 12 additions and 1 deletions

View File

@@ -746,7 +746,7 @@ esp_err_t IRAM_ATTR bootloader_flash_reset_chip(void)
return ESP_OK;
}
bool bootloader_flash_is_octal_mode_enabled(void)
bool IRAM_ATTR bootloader_flash_is_octal_mode_enabled(void)
{
#if SOC_SPI_MEM_SUPPORT_OPI_MODE
return efuse_ll_get_flash_type();

View File

@@ -72,6 +72,7 @@
#include "esp_private/gpio.h"
#elif CONFIG_IDF_TARGET_ESP32S3
#include "esp32s3/rom/rtc.h"
#include "esp_private/mspi_timing_tuning.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32H4
@@ -461,6 +462,11 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo
pd_flags &= ~RTC_SLEEP_PD_INT_8M;
}
// Turn down mspi clock speed
#if SOC_SPI_MEM_SUPPORT_TIME_TUNING
mspi_timing_change_speed_mode_cache_safe(true);
#endif
// Set mspi clock to a low-power one.
#if SOC_MEMSPI_CLOCK_IS_INDEPENDENT
spi_flash_set_clock_src(MSPI_CLK_SRC_ROM_DEFAULT);
@@ -639,6 +645,11 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo
spi_flash_set_clock_src(MSPI_CLK_SRC_DEFAULT);
#endif
// Speed up mspi clock freq
#if SOC_SPI_MEM_SUPPORT_TIME_TUNING
mspi_timing_change_speed_mode_cache_safe(false);
#endif
if (!deep_sleep) {
s_config.ccount_ticks_record = esp_cpu_get_cycle_count();
misc_modules_wake_prepare();