mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-03 22:08:28 +00:00 
			
		
		
		
	fix _rtc_slow_length being incorrectly optimized by compiler
This commit is contained in:
		@@ -1280,10 +1280,14 @@ static uint32_t get_power_down_flags(void)
 | 
				
			|||||||
#if SOC_RTC_SLOW_MEM_SUPPORTED && SOC_ULP_SUPPORTED
 | 
					#if SOC_RTC_SLOW_MEM_SUPPORTED && SOC_ULP_SUPPORTED
 | 
				
			||||||
    // Labels are defined in the linker script
 | 
					    // Labels are defined in the linker script
 | 
				
			||||||
    extern int _rtc_slow_length;
 | 
					    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) &&
 | 
					    if ((s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] == ESP_PD_OPTION_AUTO) &&
 | 
				
			||||||
            ((size_t) &_rtc_slow_length > 0 ||
 | 
					            (rtc_slow_mem_used > 0 || (s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
 | 
				
			||||||
             (s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
 | 
					 | 
				
			||||||
        s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] = ESP_PD_OPTION_ON;
 | 
					        s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] = ESP_PD_OPTION_ON;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user