mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
fix _rtc_slow_length being incorrectly optimized by compiler
This commit is contained in:
parent
667f3dfbad
commit
05b7db9cd8
@ -662,10 +662,14 @@ static uint32_t get_power_down_flags(void)
|
||||
|
||||
// Labels are defined in the linker script, see esp32.ld.
|
||||
extern int _rtc_slow_length;
|
||||
/**
|
||||
* Compiler considers "(size_t) &_rtc_slow_length > 0" to always be true.
|
||||
* So use a volatile variable to prevent compiler from doing this optimization.
|
||||
*/
|
||||
volatile size_t rtc_slow_mem_used = (size_t)&_rtc_slow_length;
|
||||
|
||||
if ((s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] == ESP_PD_OPTION_AUTO) &&
|
||||
((size_t) &_rtc_slow_length > 0 ||
|
||||
(s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
|
||||
(rtc_slow_mem_used > 0 || (s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] = ESP_PD_OPTION_ON;
|
||||
}
|
||||
|
||||
|
@ -695,10 +695,14 @@ static uint32_t get_power_down_flags(void)
|
||||
|
||||
// Labels are defined in the linker script, see esp32s2.ld.
|
||||
extern int _rtc_slow_length;
|
||||
/**
|
||||
* Compiler considers "(size_t) &_rtc_slow_length > 0" to always be true.
|
||||
* So use a volatile variable to prevent compiler from doing this optimization.
|
||||
*/
|
||||
volatile size_t rtc_slow_mem_used = (size_t)&_rtc_slow_length;
|
||||
|
||||
if ((s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] == ESP_PD_OPTION_AUTO) &&
|
||||
((size_t) &_rtc_slow_length > 0 ||
|
||||
(s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
|
||||
(rtc_slow_mem_used > 0 || (s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] = ESP_PD_OPTION_ON;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user