From b43f0ddc7007fa352cfb332c80398faeb18a8c0a Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Wed, 27 Aug 2025 09:50:21 +0800 Subject: [PATCH] feat(sleep): Modify the build system --- .../esp_hw_support/lowpower/CMakeLists.txt | 5 ++++ components/esp_pm/Kconfig | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/components/esp_hw_support/lowpower/CMakeLists.txt b/components/esp_hw_support/lowpower/CMakeLists.txt index bb470ef3b8..914a1e7272 100644 --- a/components/esp_hw_support/lowpower/CMakeLists.txt +++ b/components/esp_hw_support/lowpower/CMakeLists.txt @@ -9,6 +9,11 @@ set(srcs) if(CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP OR (CONFIG_SOC_CPU_IN_TOP_DOMAIN AND CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP)) list(APPEND srcs "port/${target}/sleep_cpu.c") + if(CONFIG_PM_CPU_RETENTION_DYNAMIC) + list(APPEND srcs "port/${target}/sleep_cpu_dynamic.c") + elseif(CONFIG_PM_CPU_RETENTION_STATIC) + list(APPEND srcs "port/${target}/sleep_cpu_static.c") + endif() if(CONFIG_SOC_PM_CPU_RETENTION_BY_SW) list(APPEND srcs "port/${target}/sleep_cpu_asm.S") set_property(TARGET ${COMPONENT_LIB} diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index 0c7591b799..736389e94c 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -130,6 +130,31 @@ menu "Power Management" On esp32s3 soc, enabling this option will consume 8.58 KB of internal RAM and will reduce sleep current consumption by about 650 uA. + choice + bool "Retentive memory alloaction strategy for light sleep" + depends on SOC_PM_CPU_RETENTION_BY_SW && \ + (PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP || (PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_CPU_IN_TOP_DOMAIN)) + default PM_CPU_RETENTION_DYNAMIC + help + In light sleep mode, certain CPU states and data need to be preserved in memory while cpu domain + is powered down. This configuration determines how the required memory resources are allocated. + The PM_CPU_RETENTION_DYNAMIC option allows more flexible runtime memory management by + supporting access to larger memory. However, it carries the risk of insufficient memory + when the chip enters the light-sleep mode, even resulting in retention failure. + In contrast, the PM_CPU_RETENTION_STATIC option ensures reliable sleep CPU retention during the + system initialization, but reduces the memory available during runtime. + + config PM_CPU_RETENTION_DYNAMIC + bool "Dynamically allocate memory" + help + Allocate memory for retention data only when preparing to enter light sleep. + + config PM_CPU_RETENTION_STATIC + bool "Statically allocate memory" + help + Pre-allocate all required retention memory during system initialization. + endchoice + config PM_RESTORE_CACHE_TAGMEM_AFTER_LIGHT_SLEEP bool "Restore I/D-cache tag memory after power down CPU light sleep" depends on IDF_TARGET_ESP32S3 && PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP