From 945e38b21ced71ecbfc986ccd00280a9714737c5 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 a5e53cddb4..4eff07ae5a 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -552,6 +552,7 @@ 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 FORCE_IRAM_ATTR suspend_cache(void) { @@ -563,7 +564,7 @@ static void FORCE_IRAM_ATTR suspend_cache(void) { // fully check the access to external memory, writeback & invalidate is needed here. Cache_WriteBack_Invalidate_All(CACHE_MAP_MASK); #endif - spi_flash_disable_cache(esp_cpu_get_core_id(), NULL); + spi_flash_disable_cache(esp_cpu_get_core_id(), &s_cache_state); } } @@ -572,7 +573,7 @@ static void FORCE_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 ebffd40c4b..d41587bdec 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