Merge branch 'bugfix/esp_idf_ulp_wakeupcauses_record_v5.5' into 'release/v5.5'

fix(ulp): record wakeup causes before lp core request sleep v5.5

See merge request espressif/esp-idf!49121
This commit is contained in:
Jiang Jiang Jian
2026-06-03 10:51:04 +08:00
26 changed files with 252 additions and 22 deletions
+22 -2
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -18,6 +18,8 @@
#include "ulp_lp_core_memory_shared.h"
#include "ulp_lp_core_lp_timer_shared.h"
#include "hal/lp_core_ll.h"
#include "soc/pmu_reg.h"
#include "hal/pmu_ll.h"
#if CONFIG_IDF_TARGET_ESP32P4
#include "esp32p4/rom/rtc.h"
@@ -33,6 +35,11 @@
extern uint32_t _rtc_ulp_memory_start;
#endif //ESP_ROM_HAS_LP_ROM
#if SOC_LP_CORE_HW_AUTO_CLRWAKEUPCAUSE
#include "hal/lp_aon_hal.h"
#include "rom/rtc.h"
#endif
const static char* TAG = "ulp-lp-core";
#define WAKEUP_SOURCE_MAX_NUMBER 6
@@ -173,6 +180,19 @@ esp_err_t ulp_lp_core_load_binary(const uint8_t* program_binary, size_t program_
return ESP_OK;
}
void ulp_lp_core_sleep_start(void)
{
#if SOC_LP_CORE_HW_AUTO_CLRWAKEUPCAUSE
/* LP store register to save wakeup cause for HP core to query.
* Using a hardware register avoids symbol linking issues between
* the independently compiled HP and LP core binaries.
* Save PMU wakeup cause to LP store register for HP core to query */
lp_aon_hal_store_wakeup_cause(pmu_ll_hp_get_wakeup_cause(&PMU));
#endif
lp_core_ll_request_sleep();
}
void ulp_lp_core_stop(void)
{
if (esp_cpu_dbgr_is_attached()) {
@@ -186,7 +206,7 @@ void ulp_lp_core_stop(void)
}
/* Disable wake-up source and put lp core to sleep */
lp_core_ll_set_wakeup_source(0);
lp_core_ll_request_sleep();
ulp_lp_core_sleep_start();
}
void ulp_lp_core_sw_intr_trigger(void)
+20 -3
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -25,6 +25,10 @@
#include "esp_cpu.h"
#include "ulp_lp_core_cpu_freq_shared.h"
#if SOC_LP_CORE_HW_AUTO_CLRWAKEUPCAUSE
#include "hal/lp_aon_hal.h"
#include "rom/rtc.h"
#endif
static uint32_t lp_wakeup_cause = 0;
@@ -142,9 +146,22 @@ void ulp_lp_core_lp_uart_reset_wakeup_en(void)
}
#endif
void ulp_lp_core_sleep_start_lp_core(void)
{
#if SOC_LP_CORE_HW_AUTO_CLRWAKEUPCAUSE
/* LP store register to save wakeup cause for HP core to query.
* Using a hardware register avoids symbol linking issues between
* the independently compiled HP and LP core binaries.
* Save PMU wakeup cause to LP store register for HP core to query */
lp_aon_hal_store_wakeup_cause(pmu_ll_hp_get_wakeup_cause(&PMU));
#endif
lp_core_ll_request_sleep();
}
void ulp_lp_core_halt(void)
{
lp_core_ll_request_sleep();
ulp_lp_core_sleep_start_lp_core();
while (1);
}
@@ -153,7 +170,7 @@ void ulp_lp_core_stop_lp_core(void)
{
/* Disable wake-up source and put lp core to sleep */
lp_core_ll_set_wakeup_source(0);
lp_core_ll_request_sleep();
ulp_lp_core_sleep_start_lp_core();
}
void __attribute__((noreturn)) abort(void)