diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index e30bc2038b..2e2b812b9b 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -1322,8 +1322,21 @@ esp_err_t esp_light_sleep_start(void) #if CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION && CONFIG_PM_SLP_IRAM_OPT /* Cache Suspend 0: if CONFIG_PM_SLP_IRAM_OPT is enabled, suspend cache here so that the access to flash - during the sleep process can be explicitly exposed. */ - suspend_cache(); + * during the sleep process can be explicitly exposed. + * + * If we use EXTx wakeup, we must put related codes in IRAM, but The `rtc_io_desc` table + * consumes a significant amount of memory. For example, on the ESP32, its size is 1008 + * bytes. Therefore, when EXTx wakeup is enabled, we do not perform cache access checks here */ + uint32_t ignore_check_wakeup_triggers = 0; +#if SOC_PM_SUPPORT_EXT0_WAKEUP + ignore_check_wakeup_triggers |= RTC_EXT0_TRIG_EN; +#endif +#if SOC_PM_SUPPORT_EXT1_WAKEUP + ignore_check_wakeup_triggers |= RTC_EXT1_TRIG_EN; +#endif + if (!(s_config.wakeup_triggers & ignore_check_wakeup_triggers)) { + suspend_cache(); + } #endif // Decide which power domains can be powered down @@ -1463,7 +1476,9 @@ esp_err_t esp_light_sleep_start(void) #if CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION && CONFIG_PM_SLP_IRAM_OPT /* Cache Resume 0: sleep process done, resume cache for continue running */ - resume_cache(); + if (!(s_config.wakeup_triggers & ignore_check_wakeup_triggers)) { + resume_cache(); + } #endif #if !CONFIG_FREERTOS_UNICORE