From 68b9df7ceb4cde29324b87a998974fa578bb07e8 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Mon, 9 Mar 2026 16:12:11 +0800 Subject: [PATCH] fix(esp_hw_support): fix sleep exception if CONFIG_SPI_FLASH_ROM_IMPL enabled --- components/esp_hw_support/sleep_modes.c | 5 +++-- components/esp_pm/test_apps/esp_pm/sdkconfig.ci.slp_iram_opt | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index bebfa8956f3..20b1c2025c8 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -495,12 +495,13 @@ static void s_do_deep_sleep_phy_callback(void) #endif static int s_cache_suspend_cnt = 0; +static uint32_t s_cache_state = 0; // Must be called from critical sections. static void IRAM_ATTR suspend_cache(void) { s_cache_suspend_cnt++; if (s_cache_suspend_cnt == 1) { - spi_flash_disable_cache(esp_cpu_get_core_id(), NULL); + spi_flash_disable_cache(esp_cpu_get_core_id(), &s_cache_state); } } @@ -509,7 +510,7 @@ static void IRAM_ATTR resume_cache(void) { s_cache_suspend_cnt--; assert(s_cache_suspend_cnt >= 0 && DRAM_STR("cache resume doesn't match suspend ops")); if (s_cache_suspend_cnt == 0) { - spi_flash_restore_cache(esp_cpu_get_core_id(), 0); + spi_flash_restore_cache(esp_cpu_get_core_id(), s_cache_state); } } diff --git a/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.slp_iram_opt b/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.slp_iram_opt index ebffd40c4b4..d41587bdeca 100644 --- a/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.slp_iram_opt +++ b/components/esp_pm/test_apps/esp_pm/sdkconfig.ci.slp_iram_opt @@ -2,3 +2,4 @@ CONFIG_PM_SLP_IRAM_OPT=y CONFIG_PM_RTOS_IDLE_OPT=y CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y +CONFIG_SPI_FLASH_ROM_IMPL=y