Merge branch 'fix/fix_esp32_core1_access_rtc_fast_in_sleep_code_v5.1' into 'release/v5.1'

fix(esp_hw_support): fix esp32 APP_CPU accessing RTCFAST memory in sleep code (v5.1)

See merge request espressif/esp-idf!40560
This commit is contained in:
Jiang Jiang Jian
2025-07-16 10:33:56 +08:00
2 changed files with 18 additions and 14 deletions

View File

@@ -256,7 +256,8 @@ static bool s_light_sleep_wakeup = false;
static portMUX_TYPE spinlock_rtc_deep_sleep = portMUX_INITIALIZER_UNLOCKED; static portMUX_TYPE spinlock_rtc_deep_sleep = portMUX_INITIALIZER_UNLOCKED;
static const char *TAG = "sleep"; static const char *TAG = "sleep";
static RTC_FAST_ATTR bool s_adc_tsen_enabled = false; /* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_FAST_ATTR */
static RTC_SLOW_ATTR bool s_adc_tsen_enabled = false;
//in this mode, 2uA is saved, but RTC memory can't use at high temperature, and RTCIO can't be used as INPUT. //in this mode, 2uA is saved, but RTC memory can't use at high temperature, and RTCIO can't be used as INPUT.
static bool s_ultra_low_enabled = false; static bool s_ultra_low_enabled = false;
@@ -357,12 +358,12 @@ esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void)
} }
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
/* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */ /* APP core of esp32 can't access to RTC FAST MEMORY, link to RTC SLOW MEMORY instead*/
void RTC_SLOW_ATTR
#else #else
void RTC_IRAM_ATTR RTC_IRAM_ATTR
#endif #endif
esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub) void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub)
{ {
#if SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY #if SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY
wake_stub_fn_handler = new_stub; wake_stub_fn_handler = new_stub;
@@ -371,7 +372,14 @@ esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub)
#endif #endif
} }
void RTC_IRAM_ATTR esp_default_wake_deep_sleep(void)
#if CONFIG_IDF_TARGET_ESP32
/* APP core of esp32 can't access to RTC FAST MEMORY, link to RTC SLOW MEMORY instead*/
RTC_SLOW_ATTR
#else
RTC_IRAM_ATTR
#endif
void esp_default_wake_deep_sleep(void)
{ {
/* Clear MMU for CPU 0 */ /* Clear MMU for CPU 0 */
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
@@ -2208,11 +2216,11 @@ static uint32_t get_power_down_flags(void)
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
/* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */ /* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */
void RTC_SLOW_ATTR
#else #else
void RTC_IRAM_ATTR RTC_IRAM_ATTR
#endif #endif
esp_deep_sleep_disable_rom_logging(void) void esp_deep_sleep_disable_rom_logging(void)
{ {
rtc_suppress_rom_log(); rtc_suppress_rom_log();
} }

View File

@@ -18,11 +18,7 @@
#include "nvs.h" #include "nvs.h"
#include "deep_sleep_example.h" #include "deep_sleep_example.h"
#if SOC_RTC_FAST_MEM_SUPPORTED RTC_SLOW_ATTR static struct timeval sleep_enter_time;
static RTC_DATA_ATTR struct timeval sleep_enter_time;
#else
static struct timeval sleep_enter_time;
#endif
static void deep_sleep_task(void *args) static void deep_sleep_task(void *args)
{ {