From 043180fcfd363280566892ecfa0e2c392ac3c42c Mon Sep 17 00:00:00 2001 From: muhaidong Date: Mon, 7 Sep 2026 22:00:30 +0800 Subject: [PATCH] fix(esp_timer): preserve timer_process_alarm symbol for ldgen --- components/esp_timer/CMakeLists.txt | 4 ++-- components/esp_timer/linker.lf | 6 ++++++ components/esp_timer/src/esp_timer.c | 3 ++- components/esp_wifi/linker.lf | 7 ------- 4 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 components/esp_timer/linker.lf diff --git a/components/esp_timer/CMakeLists.txt b/components/esp_timer/CMakeLists.txt index 8ff75b2c1b6..a308aaf5803 100644 --- a/components/esp_timer/CMakeLists.txt +++ b/components/esp_timer/CMakeLists.txt @@ -14,7 +14,6 @@ else() elseif(CONFIG_ESP_TIMER_IMPL_SYSTIMER) list(APPEND srcs "src/esp_timer_impl_systimer.c") endif() - if(CONFIG_SOC_SYSTIMER_SUPPORT_ETM) list(APPEND srcs "src/esp_timer_etm.c") endif() @@ -22,7 +21,8 @@ else() idf_component_register(SRCS "${srcs}" INCLUDE_DIRS include PRIV_REQUIRES esp_hal_timg esp_hal_systimer - PRIV_INCLUDE_DIRS private_include) + PRIV_INCLUDE_DIRS private_include + LDFRAGMENTS linker.lf) # Forces the linker to include esp_timer_init.c target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_timer_init_include_func") diff --git a/components/esp_timer/linker.lf b/components/esp_timer/linker.lf new file mode 100644 index 00000000000..4aade496869 --- /dev/null +++ b/components/esp_timer/linker.lf @@ -0,0 +1,6 @@ +[mapping:esp_timer_wifi_pm] +archive: libesp_timer.a +entries: + if ESP_WIFI_SLP_IRAM_OPT = y && IDF_TARGET_ESP32 = y: + esp_timer:timer_task (noflash) + esp_timer:timer_process_alarm (noflash) diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index 244e86e2066..a37485bb361 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -484,7 +484,8 @@ static ESP_TIMER_IRAM_ATTR void timer_list_unlock(esp_timer_dispatch_t timer_typ #ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD ESP_TIMER_IRAM_ATTR #endif -static void timer_process_alarm(esp_timer_dispatch_t dispatch_method) +// Keep this as a standalone symbol because ldgen maps it by name. +static void __attribute__((noinline, noclone)) timer_process_alarm(esp_timer_dispatch_t dispatch_method) { timer_list_lock(dispatch_method); esp_timer_handle_t it; diff --git a/components/esp_wifi/linker.lf b/components/esp_wifi/linker.lf index 1f1f69f1ed3..830cdef2de8 100644 --- a/components/esp_wifi/linker.lf +++ b/components/esp_wifi/linker.lf @@ -163,10 +163,3 @@ entries: if PM_ENABLE = y: wifi_init:wifi_pm_sleep_lock_acquire (noflash) wifi_init:wifi_pm_sleep_lock_release (noflash) - -[mapping:esp_timer_wifi_pm] -archive: libesp_timer.a -entries: - if ESP_WIFI_SLP_IRAM_OPT = y && IDF_TARGET_ESP32 = y: - esp_timer:timer_task (noflash) - esp_timer:timer_process_alarm (noflash)