From 45990692d1a3a0b90d7157fd7dc04059dabf05b2 Mon Sep 17 00:00:00 2001 From: Lou Tianhao Date: Wed, 28 Aug 2024 14:15:37 +0800 Subject: [PATCH 1/2] change(pm): change dependence of pm_slp_iram_opt --- components/esp_pm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index d7f0ee7d3b..4581363803 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -49,7 +49,7 @@ menu "Power Management" config PM_SLP_IRAM_OPT bool "Put lightsleep related codes in internal RAM" - depends on FREERTOS_USE_TICKLESS_IDLE + depends on SOC_LIGHT_SLEEP_SUPPORTED help If enabled, about 2.1KB of lightsleep related source code would be in IRAM and chip would sleep longer for 310us at 160MHz CPU frequency most each time. From 4c3f6efbd7e54fe88bddb6866c05c1cbcbef94ef Mon Sep 17 00:00:00 2001 From: Lou Tianhao Date: Wed, 4 Sep 2024 11:26:53 +0800 Subject: [PATCH 2/2] fix(pm): cancel cache_safe_assertion when using ext0 & ext1 --- components/esp_hw_support/sleep_modes.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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