mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 11:44:31 +02:00
fix(esp_hw_support): fix sleep iram safe code inlined to flash
This commit is contained in:
@@ -19,15 +19,21 @@ extern "C" {
|
|||||||
//and all variables in shared RAM. These macros can be used to redirect
|
//and all variables in shared RAM. These macros can be used to redirect
|
||||||
//particular functions/variables to other memory regions.
|
//particular functions/variables to other memory regions.
|
||||||
|
|
||||||
// Forces code into IRAM instead of flash
|
// Places code into IRAM instead of flash
|
||||||
#define IRAM_ATTR _SECTION_ATTR_IMPL(".iram1", __COUNTER__)
|
#define IRAM_ATTR _SECTION_ATTR_IMPL(".iram1", __COUNTER__)
|
||||||
|
|
||||||
|
// Forces code into IRAM instead of flash
|
||||||
|
#define FORCE_IRAM_ATTR _SECTION_FORCE_ATTR_IMPL(".iram1", __COUNTER__)
|
||||||
|
|
||||||
// Forces data into DRAM instead of flash
|
// Forces data into DRAM instead of flash
|
||||||
#define DRAM_ATTR _SECTION_ATTR_IMPL(".dram1", __COUNTER__)
|
#define DRAM_ATTR _SECTION_ATTR_IMPL(".dram1", __COUNTER__)
|
||||||
|
|
||||||
// Forces code into TCM instead of flash
|
// Places code into TCM instead of flash
|
||||||
#define TCM_IRAM_ATTR _SECTION_ATTR_IMPL(".tcm.text", __COUNTER__)
|
#define TCM_IRAM_ATTR _SECTION_ATTR_IMPL(".tcm.text", __COUNTER__)
|
||||||
|
|
||||||
|
// Forces code into TCM instead of flash
|
||||||
|
#define FORCE_TCM_IRAM_ATTR _SECTION_FORCE_ATTR_IMPL(".tcm.text", __COUNTER__)
|
||||||
|
|
||||||
// Forces data into TCM instead of L2MEM
|
// Forces data into TCM instead of L2MEM
|
||||||
#define TCM_DRAM_ATTR _SECTION_ATTR_IMPL(".tcm.data", __COUNTER__)
|
#define TCM_DRAM_ATTR _SECTION_ATTR_IMPL(".tcm.data", __COUNTER__)
|
||||||
|
|
||||||
@@ -189,11 +195,13 @@ FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a = a << b; return a; }
|
|||||||
// data with a custom section type set
|
// data with a custom section type set
|
||||||
#ifndef CONFIG_IDF_TARGET_LINUX
|
#ifndef CONFIG_IDF_TARGET_LINUX
|
||||||
#define _SECTION_ATTR_IMPL(SECTION, COUNTER) __attribute__((section(SECTION "." _COUNTER_STRINGIFY(COUNTER))))
|
#define _SECTION_ATTR_IMPL(SECTION, COUNTER) __attribute__((section(SECTION "." _COUNTER_STRINGIFY(COUNTER))))
|
||||||
|
#define _SECTION_FORCE_ATTR_IMPL(SECTION, COUNTER) __attribute__((noinline, section(SECTION "." _COUNTER_STRINGIFY(COUNTER))))
|
||||||
#define _COUNTER_STRINGIFY(COUNTER) #COUNTER
|
#define _COUNTER_STRINGIFY(COUNTER) #COUNTER
|
||||||
#else
|
#else
|
||||||
// Custom section attributes are generally not used in the port files for Linux target, but may be found
|
// Custom section attributes are generally not used in the port files for Linux target, but may be found
|
||||||
// in the common header files. Don't declare custom sections in that case.
|
// in the common header files. Don't declare custom sections in that case.
|
||||||
#define _SECTION_ATTR_IMPL(SECTION, COUNTER)
|
#define _SECTION_ATTR_IMPL(SECTION, COUNTER)
|
||||||
|
#define _SECTION_FORCE_ATTR_IMPL(SECTION, COUNTER)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use IDF_DEPRECATED attribute to mark anything deprecated from use in
|
/* Use IDF_DEPRECATED attribute to mark anything deprecated from use in
|
||||||
|
@@ -228,7 +228,7 @@
|
|||||||
(source == value))
|
(source == value))
|
||||||
|
|
||||||
#if CONFIG_PM_SLP_IRAM_OPT
|
#if CONFIG_PM_SLP_IRAM_OPT
|
||||||
# define SLEEP_FN_ATTR IRAM_ATTR
|
# define SLEEP_FN_ATTR FORCE_IRAM_ATTR
|
||||||
#else
|
#else
|
||||||
# define SLEEP_FN_ATTR
|
# define SLEEP_FN_ATTR
|
||||||
#endif
|
#endif
|
||||||
@@ -532,7 +532,7 @@ static void s_do_deep_sleep_phy_callback(void)
|
|||||||
static int s_cache_suspend_cnt = 0;
|
static int s_cache_suspend_cnt = 0;
|
||||||
|
|
||||||
// Must be called from critical sections.
|
// Must be called from critical sections.
|
||||||
static void IRAM_ATTR suspend_cache(void) {
|
static void FORCE_IRAM_ATTR suspend_cache(void) {
|
||||||
s_cache_suspend_cnt++;
|
s_cache_suspend_cnt++;
|
||||||
if (s_cache_suspend_cnt == 1) {
|
if (s_cache_suspend_cnt == 1) {
|
||||||
#if CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION && CONFIG_IDF_TARGET_ESP32P4
|
#if CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION && CONFIG_IDF_TARGET_ESP32P4
|
||||||
@@ -546,7 +546,7 @@ static void IRAM_ATTR suspend_cache(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Must be called from critical sections.
|
// Must be called from critical sections.
|
||||||
static void IRAM_ATTR resume_cache(void) {
|
static void FORCE_IRAM_ATTR resume_cache(void) {
|
||||||
s_cache_suspend_cnt--;
|
s_cache_suspend_cnt--;
|
||||||
assert(s_cache_suspend_cnt >= 0 && DRAM_STR("cache resume doesn't match suspend ops"));
|
assert(s_cache_suspend_cnt >= 0 && DRAM_STR("cache resume doesn't match suspend ops"));
|
||||||
if (s_cache_suspend_cnt == 0) {
|
if (s_cache_suspend_cnt == 0) {
|
||||||
@@ -832,12 +832,12 @@ static SLEEP_FN_ATTR void sleep_low_power_clock_calibration(bool is_dslp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline static uint32_t call_rtc_sleep_start(uint32_t reject_triggers, uint32_t lslp_mem_inf_fpu, bool dslp);
|
static uint32_t call_rtc_sleep_start(uint32_t reject_triggers, uint32_t lslp_mem_inf_fpu, bool dslp);
|
||||||
|
|
||||||
#if SOC_PMU_SUPPORTED
|
#if SOC_PMU_SUPPORTED
|
||||||
static esp_err_t IRAM_ATTR esp_sleep_start_safe(uint32_t sleep_flags, uint32_t reject_triggers, bool deep_sleep, pmu_sleep_config_t *config)
|
static esp_err_t FORCE_IRAM_ATTR esp_sleep_start_safe(uint32_t sleep_flags, uint32_t reject_triggers, bool deep_sleep, pmu_sleep_config_t *config)
|
||||||
#else
|
#else
|
||||||
static esp_err_t IRAM_ATTR esp_sleep_start_safe(uint32_t sleep_flags, uint32_t reject_triggers, bool deep_sleep, rtc_sleep_config_t *config)
|
static esp_err_t FORCE_IRAM_ATTR esp_sleep_start_safe(uint32_t sleep_flags, uint32_t reject_triggers, bool deep_sleep, rtc_sleep_config_t *config)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
esp_err_t result = ESP_OK;
|
esp_err_t result = ESP_OK;
|
||||||
@@ -1185,7 +1185,7 @@ static esp_err_t SLEEP_FN_ATTR esp_sleep_start(uint32_t sleep_flags, uint32_t cl
|
|||||||
return result ? ESP_ERR_SLEEP_REJECT : ESP_OK;
|
return result ? ESP_ERR_SLEEP_REJECT : ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static uint32_t IRAM_ATTR call_rtc_sleep_start(uint32_t reject_triggers, uint32_t lslp_mem_inf_fpu, bool dslp)
|
static uint32_t FORCE_IRAM_ATTR call_rtc_sleep_start(uint32_t reject_triggers, uint32_t lslp_mem_inf_fpu, bool dslp)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||||
return rtc_sleep_start(s_config.wakeup_triggers, reject_triggers);
|
return rtc_sleep_start(s_config.wakeup_triggers, reject_triggers);
|
||||||
@@ -1196,7 +1196,7 @@ inline static uint32_t IRAM_ATTR call_rtc_sleep_start(uint32_t reject_triggers,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection)
|
static esp_err_t FORCE_IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection)
|
||||||
{
|
{
|
||||||
#if SOC_VBAT_SUPPORTED
|
#if SOC_VBAT_SUPPORTED
|
||||||
if (s_sleep_sub_mode_ref_cnt[ESP_SLEEP_VBAT_POWER_DEEPSLEEP_MODE]) {
|
if (s_sleep_sub_mode_ref_cnt[ESP_SLEEP_VBAT_POWER_DEEPSLEEP_MODE]) {
|
||||||
@@ -1298,7 +1298,7 @@ static esp_err_t IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR esp_deep_sleep_start(void)
|
void FORCE_IRAM_ATTR esp_deep_sleep_start(void)
|
||||||
{
|
{
|
||||||
bool allow_sleep_rejection = true;
|
bool allow_sleep_rejection = true;
|
||||||
deep_sleep_start(!allow_sleep_rejection);
|
deep_sleep_start(!allow_sleep_rejection);
|
||||||
@@ -1306,7 +1306,7 @@ void IRAM_ATTR esp_deep_sleep_start(void)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t IRAM_ATTR esp_deep_sleep_try_to_start(void)
|
esp_err_t FORCE_IRAM_ATTR esp_deep_sleep_try_to_start(void)
|
||||||
{
|
{
|
||||||
bool allow_sleep_rejection = true;
|
bool allow_sleep_rejection = true;
|
||||||
return deep_sleep_start(allow_sleep_rejection);
|
return deep_sleep_start(allow_sleep_rejection);
|
||||||
|
Reference in New Issue
Block a user