From e908a3238168a439a252b1a7dfe98e9568acc953 Mon Sep 17 00:00:00 2001 From: ninh Date: Fri, 25 Dec 2020 20:04:32 +0800 Subject: [PATCH] put pm_slp_iram_opt and pm_rtos_iram_opt related attributes in esp_pm/linker.lf --- components/esp_common/linker.lf | 6 --- components/esp_hw_support/linker.lf | 2 - components/esp_pm/Kconfig | 15 +++---- components/esp_pm/linker.lf | 47 +++++++++++++++++++++ components/esp_system/linker.lf | 6 --- components/esp_timer/CMakeLists.txt | 3 +- components/esp_timer/component.mk | 2 - components/esp_timer/linker.lf | 10 ----- components/newlib/newlib.lf | 7 --- examples/wifi/power_save/sdkconfig.defaults | 3 ++ 10 files changed, 58 insertions(+), 43 deletions(-) delete mode 100644 components/esp_timer/linker.lf diff --git a/components/esp_common/linker.lf b/components/esp_common/linker.lf index bfc8cdad1a..b6913ecff1 100644 --- a/components/esp_common/linker.lf +++ b/components/esp_common/linker.lf @@ -2,9 +2,3 @@ archive: libesp_common.a entries: esp_err (noflash) - if PM_RTOS_IDLE_OPT = y: - freertos_hooks:esp_vApplicationIdleHook (noflash) - task_wdt:idle_hook_cb (noflash) - task_wdt:esp_task_wdt_reset (noflash) - task_wdt:find_task_in_twdt_list (noflash) - task_wdt:reset_hw_timer (noflash) diff --git a/components/esp_hw_support/linker.lf b/components/esp_hw_support/linker.lf index 96e27d5032..9abbe07e38 100644 --- a/components/esp_hw_support/linker.lf +++ b/components/esp_hw_support/linker.lf @@ -11,5 +11,3 @@ entries: rtc_sleep (noflash_text) rtc_time (noflash_text) rtc_wdt (noflash_text) - if PM_SLP_IRAM_OPT = y: - rtc_init:rtc_vddsdio_get_config (noflash) diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index c581d9753f..e066022621 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -62,20 +62,19 @@ menu "Power Management" config PM_SLP_IRAM_OPT bool "Put lightsleep related codes in internal RAM" depends on FREERTOS_USE_TICKLESS_IDLE - default n help - If enabled, about 1.8KB of lightsleep related codes would be in IRAM and chip would sleep + If enabled, about 1.8KB of lightsleep related source code would be in IRAM and chip would sleep longer for 760us at most each time. - This feature is intended to be used when a lower power management mode is needed - regardless of the internal memory. + This feature is intended to be used when lower power consumption is needed + while there is enough place in IRAM to place source code. config PM_RTOS_IDLE_OPT bool "Put RTOS IDLE related codes in internal RAM" depends on FREERTOS_USE_TICKLESS_IDLE - default n help - If enabled, about 260B of RTOS_IDLE related codes would be in IRAM and chip would sleep + If enabled, about 260B of RTOS_IDLE related source code would be in IRAM and chip would sleep longer for 40us at most each time. - This feature is intended to be used when a lower power management mode is needed - regardless of the internal memory. + This feature is intended to be used when lower power consumption is needed + while there is enough place in IRAM to place source code. + endmenu # "Power Management" diff --git a/components/esp_pm/linker.lf b/components/esp_pm/linker.lf index e04ce24164..6de8b2b302 100644 --- a/components/esp_pm/linker.lf +++ b/components/esp_pm/linker.lf @@ -4,3 +4,50 @@ entries: if PM_RTOS_IDLE_OPT = y: pm_impl:esp_pm_impl_idle_hook (noflash) pm_impl:esp_pm_impl_waiti (noflash) + +[mapping:esp_common_pm] +archive: libesp_common.a +entries: + if PM_RTOS_IDLE_OPT = y: + freertos_hooks:esp_vApplicationIdleHook (noflash) + task_wdt:idle_hook_cb (noflash) + task_wdt:esp_task_wdt_reset (noflash) + task_wdt:find_task_in_twdt_list (noflash) + task_wdt:reset_hw_timer (noflash) + +[mapping:esp_hw_support_pm] +archive: libesp_hw_support.a +entries: + if PM_SLP_IRAM_OPT = y: + rtc_init:rtc_vddsdio_get_config (noflash) + +[mapping:esp_system_pm] +archive: libesp_system.a +entries: + if PM_SLP_IRAM_OPT = y: + sleep_modes:esp_light_sleep_start (noflash) + sleep_modes:esp_sleep_enable_timer_wakeup (noflash) + sleep_modes:timer_wakeup_prepare (noflash) + sleep_modes:get_power_down_flags (noflash) + +[mapping:esp_timer_pm] +archive: libesp_timer.a +entries: + if PM_SLP_IRAM_OPT = y: + esp_timer_impl_lac:esp_timer_impl_lock (noflash) + esp_timer_impl_lac:esp_timer_impl_unlock (noflash) + esp_timer_impl_lac:esp_timer_impl_advance (noflash) + esp_timer_impl_systimer:esp_timer_impl_lock (noflash) + esp_timer_impl_systimer:esp_timer_impl_unlock (noflash) + esp_timer_impl_systimer:esp_timer_impl_advance (noflash) + +[mapping:newlib_pm] +archive: libnewlib.a +entries: + if PM_SLP_IRAM_OPT = y: + esp_time_impl:esp_time_impl_set_boot_time (noflash) + esp_time_impl:esp_time_impl_get_boot_time (noflash) + esp_time_impl:esp_clk_slowclk_cal_get (noflash) + esp_time_impl:esp_rtc_get_time_us (noflash) + esp_time_impl:esp_clk_slowclk_cal_set (noflash) + esp_time_impl:esp_set_time_from_rtc (noflash) diff --git a/components/esp_system/linker.lf b/components/esp_system/linker.lf index c4b3ac055e..17ab599c35 100644 --- a/components/esp_system/linker.lf +++ b/components/esp_system/linker.lf @@ -23,12 +23,6 @@ entries: usb_console:esp_usb_console_cdc_acm_cb (noflash) usb_console:esp_usb_console_dfu_detach_cb (noflash) usb_console:esp_usb_console_before_restart (noflash) - if PM_SLP_IRAM_OPT = y: - sleep_modes:esp_light_sleep_start (noflash) - sleep_modes:esp_sleep_enable_timer_wakeup (noflash) - sleep_modes:timer_wakeup_prepare (noflash) - sleep_modes:get_power_down_flags (noflash) - [mapping:vfs_cdcacm] archive: libvfs.a diff --git a/components/esp_timer/CMakeLists.txt b/components/esp_timer/CMakeLists.txt index bd5a566aeb..0fbbee530b 100644 --- a/components/esp_timer/CMakeLists.txt +++ b/components/esp_timer/CMakeLists.txt @@ -15,5 +15,4 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS include PRIV_INCLUDE_DIRS private_include REQUIRES esp_common - PRIV_REQUIRES soc driver "${target}" - LDFRAGMENTS linker.lf) + PRIV_REQUIRES soc driver "${target}") diff --git a/components/esp_timer/component.mk b/components/esp_timer/component.mk index d179111cda..43b72dec6c 100644 --- a/components/esp_timer/component.mk +++ b/components/esp_timer/component.mk @@ -20,5 +20,3 @@ ifdef CONFIG_IDF_TARGET_ESP32 else $(error esp_timer is only supported by the Make build system for esp32 chip. For other chips, use the Cmake build system) endif - -COMPONENT_ADD_LDFRAGMENTS += linker.lf diff --git a/components/esp_timer/linker.lf b/components/esp_timer/linker.lf deleted file mode 100644 index 743b8d6f13..0000000000 --- a/components/esp_timer/linker.lf +++ /dev/null @@ -1,10 +0,0 @@ -[mapping:esp_timer] -archive: libesp_timer.a -entries: - if PM_SLP_IRAM_OPT = y: - esp_timer_impl_lac:esp_timer_impl_lock (noflash) - esp_timer_impl_lac:esp_timer_impl_unlock (noflash) - esp_timer_impl_lac:esp_timer_impl_advance (noflash) - esp_timer_impl_systimer:esp_timer_impl_lock (noflash) - esp_timer_impl_systimer:esp_timer_impl_unlock (noflash) - esp_timer_impl_systimer:esp_timer_impl_advance (noflash) diff --git a/components/newlib/newlib.lf b/components/newlib/newlib.lf index 46410048cd..63a93164a2 100644 --- a/components/newlib/newlib.lf +++ b/components/newlib/newlib.lf @@ -3,10 +3,3 @@ archive: libnewlib.a entries: heap (noflash) abort (noflash) - if PM_SLP_IRAM_OPT = y: - esp_time_impl:esp_time_impl_set_boot_time (noflash) - esp_time_impl:esp_time_impl_get_boot_time (noflash) - esp_time_impl:esp_clk_slowclk_cal_get (noflash) - esp_time_impl:esp_rtc_get_time_us (noflash) - esp_time_impl:esp_clk_slowclk_cal_set (noflash) - esp_time_impl:esp_set_time_from_rtc (noflash) diff --git a/examples/wifi/power_save/sdkconfig.defaults b/examples/wifi/power_save/sdkconfig.defaults index d39e7c8321..60d93f2738 100644 --- a/examples/wifi/power_save/sdkconfig.defaults +++ b/examples/wifi/power_save/sdkconfig.defaults @@ -6,3 +6,6 @@ CONFIG_PM_ENABLE=y CONFIG_FREERTOS_USE_TICKLESS_IDLE=y # Use RTC timer as reference CONFIG_PM_USE_RTC_TIMER_REF=y +# Put related source code in IRAM +CONFIG_PM_SLP_IRAM_OPT=y +CONFIG_PM_RTOS_IDLE_OPT=y