From 77a1e2931d1827a4978f360a7e65cb23020fddb1 Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Mon, 24 Mar 2025 16:35:19 +0800 Subject: [PATCH] change: fix build clang test apps job error --- components/esp_hw_support/esp_clk.c | 8 +++++++- .../esp_hw_support/sar_periph_ctrl_common.c | 8 +++++++- components/esp_pm/linker.lf | 14 -------------- components/esp_system/task_wdt/task_wdt.c | 18 ++++++++++++------ .../task_wdt/task_wdt_impl_esp_timer.c | 12 +++++++++--- .../task_wdt/task_wdt_impl_timergroup.c | 8 +++++++- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/components/esp_hw_support/esp_clk.c b/components/esp_hw_support/esp_clk.c index 2ebd827631..ec85b60f00 100644 --- a/components/esp_hw_support/esp_clk.c +++ b/components/esp_hw_support/esp_clk.c @@ -26,6 +26,12 @@ #define MHZ (1000000) +#if CONFIG_PM_SLP_IRAM_OPT +# define ESP_CLK_FN_ATTR IRAM_ATTR +#else +# define ESP_CLK_FN_ATTR +#endif + // g_ticks_us defined in ROMs for PRO and APP CPU extern uint32_t g_ticks_per_us_pro; @@ -48,7 +54,7 @@ _Static_assert(offsetof(retain_mem_t, checksum) == sizeof(retain_mem_t) - sizeof #if !NON_OS_BUILD static __attribute__((section(".rtc_timer_data_in_rtc_mem"))) retain_mem_t s_rtc_timer_retain_mem; -static uint32_t calc_checksum(void) +static ESP_CLK_FN_ATTR uint32_t calc_checksum(void) { uint32_t checksum = 0; uint32_t *data = (uint32_t*) &s_rtc_timer_retain_mem; diff --git a/components/esp_hw_support/sar_periph_ctrl_common.c b/components/esp_hw_support/sar_periph_ctrl_common.c index 4e64ee0cc1..f8099358ca 100644 --- a/components/esp_hw_support/sar_periph_ctrl_common.c +++ b/components/esp_hw_support/sar_periph_ctrl_common.c @@ -33,6 +33,12 @@ static const char *TAG_TSENS = "temperature_sensor"; #define TSENS_RCC_ATOMIC() #endif +#if CONFIG_PM_SLP_IRAM_OPT +# define SAR_PERIPH_CTRL_COMMON_FN_ATTR IRAM_ATTR +#else +# define SAR_PERIPH_CTRL_COMMON_FN_ATTR +#endif + static int s_record_min = INT_NOT_USED; static int s_record_max = INT_NOT_USED; static int s_temperature_sensor_power_cnt; @@ -79,7 +85,7 @@ void temperature_sensor_power_release(void) portEXIT_CRITICAL(&rtc_spinlock); } -static int temperature_sensor_get_raw_value(void) +static SAR_PERIPH_CTRL_COMMON_FN_ATTR int temperature_sensor_get_raw_value(void) { int raw_value = temperature_sensor_ll_get_raw_value(); return (TEMPERATURE_SENSOR_LL_ADC_FACTOR * raw_value - TEMPERATURE_SENSOR_LL_DAC_FACTOR * temperature_sensor_attributes[s_tsens_idx].offset - TEMPERATURE_SENSOR_LL_OFFSET_FACTOR); diff --git a/components/esp_pm/linker.lf b/components/esp_pm/linker.lf index b68487946e..95a192d0c6 100644 --- a/components/esp_pm/linker.lf +++ b/components/esp_pm/linker.lf @@ -39,8 +39,6 @@ entries: esp_clk:esp_rtc_get_time_us (noflash) esp_clk:esp_clk_private_lock (noflash) esp_clk:esp_clk_private_unlock (noflash) - if SOC_RTC_MEM_SUPPORTED = y: - esp_clk:calc_checksum (noflash) if SOC_SYSTIMER_SUPPORTED = y: systimer (noflash) if IDF_TARGET_ESP32H21 != y && IDF_TARGET_ESP32H4 != y: @@ -48,7 +46,6 @@ entries: if SOC_TEMP_SENSOR_SUPPORTED = y: sar_periph_ctrl_common:temperature_sensor_power_acquire (noflash) sar_periph_ctrl_common:temperature_sensor_power_release (noflash) - sar_periph_ctrl_common:temperature_sensor_get_raw_value (noflash) sar_periph_ctrl_common:temp_sensor_get_raw_value (noflash) regi2c_ctrl:regi2c_saradc_enable (noflash) regi2c_ctrl:regi2c_saradc_disable (noflash) @@ -61,17 +58,6 @@ archive: libesp_system.a entries: if PM_RTOS_IDLE_OPT = y: freertos_hooks:esp_vApplicationIdleHook (noflash) - if PM_SLP_IRAM_OPT = y: - task_wdt:idle_hook_cb (noflash) - task_wdt:task_wdt_timer_feed (noflash) - task_wdt:find_entry_and_check_all_reset (noflash) - task_wdt:find_entry_from_task_handle_and_check_all_reset (noflash) - task_wdt:esp_task_wdt_reset (noflash) - task_wdt:esp_task_wdt_reset_user (noflash) - if ESP_TASK_WDT_USE_ESP_TIMER = y: - task_wdt_impl_esp_timer:esp_task_wdt_impl_timer_feed (noflash) - else: - task_wdt_impl_timergroup:esp_task_wdt_impl_timer_feed (noflash) [mapping:esp_timer_pm] archive: libesp_timer.a diff --git a/components/esp_system/task_wdt/task_wdt.c b/components/esp_system/task_wdt/task_wdt.c index 4b374c467d..60e256f121 100644 --- a/components/esp_system/task_wdt/task_wdt.c +++ b/components/esp_system/task_wdt/task_wdt.c @@ -36,6 +36,12 @@ #define BACKTRACE_MSG "backtrace" #endif +#if CONFIG_PM_RTOS_IDLE_OPT +# define TASK_WDT_FN_ATTR IRAM_ATTR +#else +# define TASK_WDT_FN_ATTR +#endif + /* We will use this function in order to simulate an `abort()` occurring in * a different context than the one it's called from. */ extern void xt_unhandled_exception(void *frame); @@ -96,7 +102,7 @@ static char core_user_names[CONFIG_FREERTOS_NUMBER_OF_CORES][CORE_USER_NAME_LEN] * @brief Reset the timer and reset flags of each entry * When entering this function, the spinlock has already been taken, no need to take it back. */ -static void task_wdt_timer_feed(void) +static TASK_WDT_FN_ATTR void task_wdt_timer_feed(void) { esp_task_wdt_impl_timer_feed(p_twdt_obj->impl_ctx); @@ -114,7 +120,7 @@ static void task_wdt_timer_feed(void) * @param[out] all_reset Whether all entries have been reset * @return Whether the user entry exists */ -static bool find_entry_and_check_all_reset(twdt_entry_t *user_entry, bool *all_reset) +static TASK_WDT_FN_ATTR bool find_entry_and_check_all_reset(twdt_entry_t *user_entry, bool *all_reset) { bool found_user_entry = false; bool found_non_reset = false; @@ -139,7 +145,7 @@ static bool find_entry_and_check_all_reset(twdt_entry_t *user_entry, bool *all_r * @param[out] all_reset Whether all entries have been reset * @return Task entry, or NULL if not found */ -static twdt_entry_t *find_entry_from_task_handle_and_check_all_reset(TaskHandle_t handle, bool *all_reset) +static TASK_WDT_FN_ATTR twdt_entry_t *find_entry_from_task_handle_and_check_all_reset(TaskHandle_t handle, bool *all_reset) { twdt_entry_t *target = NULL; bool found_non_reset = false; @@ -448,7 +454,7 @@ static void task_wdt_timeout_handling(int cores_fail, bool panic) * * @return Whether the idle tasks should continue idling */ -static bool idle_hook_cb(void) +static TASK_WDT_FN_ATTR bool idle_hook_cb(void) { #if CONFIG_FREERTOS_SMP esp_task_wdt_reset_user(core_user_handles[xPortGetCoreID()]); @@ -687,7 +693,7 @@ esp_err_t esp_task_wdt_add_user(const char *user_name, esp_task_wdt_user_handle_ return ret; } -esp_err_t esp_task_wdt_reset(void) +esp_err_t TASK_WDT_FN_ATTR esp_task_wdt_reset(void) { ESP_RETURN_ON_FALSE(p_twdt_obj != NULL, ESP_ERR_INVALID_STATE, TAG, "TWDT was never initialized"); esp_err_t ret; @@ -711,7 +717,7 @@ err: return ret; } -esp_err_t esp_task_wdt_reset_user(esp_task_wdt_user_handle_t user_handle) +esp_err_t TASK_WDT_FN_ATTR esp_task_wdt_reset_user(esp_task_wdt_user_handle_t user_handle) { ESP_RETURN_ON_FALSE(user_handle != NULL, ESP_ERR_INVALID_ARG, TAG, "Invalid arguments"); ESP_RETURN_ON_FALSE(p_twdt_obj != NULL, ESP_ERR_INVALID_STATE, TAG, "TWDT was never initialized"); diff --git a/components/esp_system/task_wdt/task_wdt_impl_esp_timer.c b/components/esp_system/task_wdt/task_wdt_impl_esp_timer.c index d5219dcfab..d6441f7d43 100644 --- a/components/esp_system/task_wdt/task_wdt_impl_esp_timer.c +++ b/components/esp_system/task_wdt/task_wdt_impl_esp_timer.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,6 +17,12 @@ #include "esp_timer.h" #include "esp_private/esp_task_wdt_impl.h" +#if CONFIG_PM_SLP_IRAM_OPT +# define TASK_WDT_FN_ATTR IRAM_ATTR +#else +# define TASK_WDT_FN_ATTR +#endif + /** * Context for the software implementation of the Task WatchDog Timer. * This will be passed as a parameter to public functions below. */ @@ -50,7 +56,7 @@ esp_err_t esp_task_wdt_impl_timer_allocate(const esp_task_wdt_config_t *config, esp_err_t ret = esp_timer_create(&timer_args, &ctx->sw_timer); ESP_GOTO_ON_FALSE((ret == ESP_OK), ret, reterr, TAG, "could not start periodic timer"); - /* Configure it as a periodic timer, so that we check the Tasks everytime it is triggered. + /* Configure it as a periodic timer, so that we check the Tasks every time it is triggered. * No need to start the timer here, it will be started later with `esp_task_wdt_impl_timer_restart` */ ctx->period_ms = config->timeout_ms; @@ -89,7 +95,7 @@ void esp_task_wdt_impl_timer_free(twdt_ctx_t obj) } } -esp_err_t esp_task_wdt_impl_timer_feed(twdt_ctx_t obj) +esp_err_t TASK_WDT_FN_ATTR esp_task_wdt_impl_timer_feed(twdt_ctx_t obj) { esp_err_t ret = ESP_OK; const twdt_ctx_soft_t* ctx = (twdt_ctx_soft_t*) obj; diff --git a/components/esp_system/task_wdt/task_wdt_impl_timergroup.c b/components/esp_system/task_wdt/task_wdt_impl_timergroup.c index c602f20186..ec408377f6 100644 --- a/components/esp_system/task_wdt/task_wdt_impl_timergroup.c +++ b/components/esp_system/task_wdt/task_wdt_impl_timergroup.c @@ -32,6 +32,12 @@ #define TWDT_TIMER_GROUP 0 #define TWDT_INTR_SOURCE SYS_TG0_WDT_INTR_SOURCE +#if CONFIG_PM_SLP_IRAM_OPT +# define TASK_WDT_FN_ATTR IRAM_ATTR +#else +# define TASK_WDT_FN_ATTR +#endif + /** * Context for the software implementation of the Task WatchDog Timer. * This will be passed as a parameter to public functions below. */ @@ -177,7 +183,7 @@ void esp_task_wdt_impl_timer_free(twdt_ctx_t obj) } } -esp_err_t esp_task_wdt_impl_timer_feed(twdt_ctx_t obj) +esp_err_t TASK_WDT_FN_ATTR esp_task_wdt_impl_timer_feed(twdt_ctx_t obj) { esp_err_t ret = ESP_OK; twdt_ctx_hard_t* ctx = (twdt_ctx_hard_t*) obj;