|
|
@@ -665,12 +665,29 @@ esp_err_t esp_light_sleep_start(void)
|
|
|
s_config.ccount_ticks_record = esp_cpu_get_cycle_count();
|
|
|
static portMUX_TYPE light_sleep_lock = portMUX_INITIALIZER_UNLOCKED;
|
|
|
portENTER_CRITICAL(&light_sleep_lock);
|
|
|
+ /*
|
|
|
+ Note: We are about to stall the other CPU via the esp_ipc_isr_stall_other_cpu(). However, there is a chance of
|
|
|
+ deadlock if after stalling the other CPU, we attempt to take spinlocks already held by the other CPU that is.
|
|
|
+
|
|
|
+ Thus any functions that we call after stalling the other CPU will need to have the locks taken first to avoid
|
|
|
+ deadlock.
|
|
|
+
|
|
|
+ Todo: IDF-5257
|
|
|
+ */
|
|
|
+
|
|
|
/* We will be calling esp_timer_private_set inside DPORT access critical
|
|
|
* section. Make sure the code on the other CPU is not holding esp_timer
|
|
|
* lock, otherwise there will be deadlock.
|
|
|
*/
|
|
|
esp_timer_private_lock();
|
|
|
|
|
|
+ /* We will be calling esp_rtc_get_time_us() below. Make sure the code on the other CPU is not holding the
|
|
|
+ * esp_rtc_get_time_us() lock, otherwise there will be deadlock. esp_rtc_get_time_us() is called via:
|
|
|
+ *
|
|
|
+ * - esp_clk_slowclk_cal_set() -> esp_rtc_get_time_us()
|
|
|
+ */
|
|
|
+ esp_clk_private_lock();
|
|
|
+
|
|
|
s_config.rtc_ticks_at_sleep_start = rtc_time_get();
|
|
|
uint32_t ccount_at_sleep_start = esp_cpu_get_cycle_count();
|
|
|
uint64_t high_res_time_at_start = esp_timer_get_time();
|
|
|
@@ -793,6 +810,7 @@ esp_err_t esp_light_sleep_start(void)
|
|
|
}
|
|
|
esp_set_time_from_rtc();
|
|
|
|
|
|
+ esp_clk_private_unlock();
|
|
|
esp_timer_private_unlock();
|
|
|
esp_ipc_isr_release_other_cpu();
|
|
|
if (!wdt_was_enabled) {
|