From 42bb45db22eb9159e34cb3841ab8fd2703eb7e8f Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 10 Jun 2026 11:09:16 +0800 Subject: [PATCH] fix(ulp): fixes potential race-condition for lp-timer wakeup with lp-core Reconfigure wakeup time before enabling the wakeup source to avoid a wakeup from potentially stale values. Closes https://github.com/espressif/esp-idf/issues/17009 --- components/ulp/lp_core/lp_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/ulp/lp_core/lp_core.c b/components/ulp/lp_core/lp_core.c index f9a0dd71721..4525007e812 100644 --- a/components/ulp/lp_core/lp_core.c +++ b/components/ulp/lp_core/lp_core.c @@ -161,16 +161,9 @@ esp_err_t ulp_lp_core_run(ulp_lp_core_cfg_t* cfg) otherwise configured HW breakpoints and dcsr.ebreak* bits will be missed */ lp_core_ll_rst_at_sleep_enable(!(CONFIG_ULP_NORESET_UNDER_DEBUG && esp_cpu_dbgr_is_attached())); - /* Set wake-up sources */ - lp_core_ll_set_wakeup_source(lp_core_get_wakeup_source_hw_flags(cfg->wakeup_source)); - /* Enable JTAG debugging */ lp_core_ll_debug_module_enable(true); - if (cfg->wakeup_source & ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU) { - lp_core_ll_hp_wake_lp(); - } - #if SOC_ULP_LP_UART_SUPPORTED if (cfg->wakeup_source & ULP_LP_CORE_WAKEUP_SOURCE_LP_UART) { lp_core_ll_enable_lp_uart_wakeup(true); @@ -192,6 +185,13 @@ esp_err_t ulp_lp_core_run(ulp_lp_core_cfg_t* cfg) } #endif + /* Set wake-up sources */ + lp_core_ll_set_wakeup_source(lp_core_get_wakeup_source_hw_flags(cfg->wakeup_source)); + + if (cfg->wakeup_source & ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU) { + lp_core_ll_hp_wake_lp(); + } + return ESP_OK; }