mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'fix/fix_esp32_core1_access_rtc_fast_in_sleep_code_v5.4' into 'release/v5.4'
fix(esp_hw_support): fix esp32 APP_CPU accessing RTC_FAST memory in sleep code (v5.4) See merge request espressif/esp-idf!40557
This commit is contained in:
@@ -291,8 +291,9 @@ static bool s_light_sleep_wakeup = false;
|
||||
static portMUX_TYPE spinlock_rtc_deep_sleep = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
static const char *TAG = "sleep";
|
||||
static RTC_FAST_ATTR int32_t s_sleep_sub_mode_ref_cnt[ESP_SLEEP_MODE_MAX] = { 0 };
|
||||
//in this mode, 2uA is saved, but RTC memory can't use at high temperature, and RTCIO can't be used as INPUT.
|
||||
|
||||
/* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */
|
||||
RTC_SLOW_ATTR static int32_t s_sleep_sub_mode_ref_cnt[ESP_SLEEP_MODE_MAX] = { 0 };
|
||||
|
||||
void esp_sleep_overhead_out_time_refresh(void)
|
||||
{
|
||||
@@ -385,12 +386,12 @@ esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void)
|
||||
}
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
/* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */
|
||||
void
|
||||
/* APP core of esp32 can't access to RTC FAST MEMORY, link to RTC SLOW MEMORY instead*/
|
||||
RTC_SLOW_ATTR
|
||||
#else
|
||||
void RTC_IRAM_ATTR
|
||||
RTC_IRAM_ATTR
|
||||
#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
|
||||
wake_stub_fn_handler = new_stub;
|
||||
@@ -399,7 +400,14 @@ esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub)
|
||||
#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 */
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@@ -2565,11 +2573,11 @@ static uint32_t get_sleep_flags(uint32_t sleep_flags, bool deepsleep)
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
/* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */
|
||||
void
|
||||
RTC_SLOW_ATTR
|
||||
#else
|
||||
void RTC_IRAM_ATTR
|
||||
RTC_IRAM_ATTR
|
||||
#endif
|
||||
esp_deep_sleep_disable_rom_logging(void)
|
||||
void esp_deep_sleep_disable_rom_logging(void)
|
||||
{
|
||||
rtc_suppress_rom_log();
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "esp_sleep.h"
|
||||
#include "unity.h"
|
||||
#include "unity_test_utils.h"
|
||||
@@ -38,6 +39,30 @@ TEST_CASE("Can use 8MD256 as RTC clock source in deepsleep", "[pm]")
|
||||
test_deepsleep(false);
|
||||
}
|
||||
|
||||
static void check_reset_reason_deep_sleep(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(ESP_RST_DEEPSLEEP, esp_reset_reason());
|
||||
}
|
||||
|
||||
static void enter_deepsleep_by_core1(void *args)
|
||||
{
|
||||
do {
|
||||
test_deepsleep(false);
|
||||
} while (1);
|
||||
}
|
||||
|
||||
static void request_core1_do_deepsleep(void)
|
||||
{
|
||||
fflush(stdout);
|
||||
fsync(fileno(stdout));
|
||||
xTaskCreatePinnedToCore(enter_deepsleep_by_core1, "deep_sleep_task", 4096, NULL, 6, NULL, 1);
|
||||
while(1);
|
||||
}
|
||||
|
||||
TEST_CASE_MULTIPLE_STAGES("Can use 8MD256 as RTC clock source in deepsleep (enter sleep by core1)", "[pm]",
|
||||
request_core1_do_deepsleep,
|
||||
check_reset_reason_deep_sleep);
|
||||
|
||||
static void test_lightsleep(bool force_rtc_periph)
|
||||
{
|
||||
esp_sleep_enable_timer_wakeup(2000000);
|
||||
|
@@ -18,11 +18,7 @@
|
||||
#include "nvs.h"
|
||||
#include "deep_sleep_example.h"
|
||||
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED
|
||||
static RTC_DATA_ATTR struct timeval sleep_enter_time;
|
||||
#else
|
||||
static struct timeval sleep_enter_time;
|
||||
#endif
|
||||
RTC_SLOW_ATTR static struct timeval sleep_enter_time;
|
||||
|
||||
static void deep_sleep_task(void *args)
|
||||
{
|
||||
|
Reference in New Issue
Block a user