You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The theoretical maximum value of time_in_us can be calculated by formula:
(time_in_us / cali) << 12 = 2^31 - 1
cali = system_rtc_clock_cali_proc(), the cali is the RTC clock period (in
us); bit11 ~ bit0 are decimal. For more details about the cali, please see the
API: system_rtc_clock_cali_proc
From the previous follows this implementation for calculating the max theoretical sleep time::
However, calling this: system_deep_sleep(deepSleepMax());
seems to have odd behavior. Sometimes there is an error message in the serial output saying sleep time too long, sometimes the ESP sleeps, and sometimes the ESP doesn't wake up.
After configuration, the chip will not enter Deep-sleep mode immediately, but will wait for a while till the Wi-Fi core is closed safely.
I suspect that:
there is a race condition, because it is possible that the max theoretical value for sleep changes between the time the user calls system_deep_sleep() and the actual sleep begins
If system_deep_sleep() is called with a value larger than the max theoretical value, the ESP could never wake up again
If there is a check on the SDK code side that checks against some max value, that it suffers from the same race condition above, which means, which means that it is still possible for a value that is too big to reach the sleep code, and make the ESP never wake up.
The text was updated successfully, but these errors were encountered:
I should also note that I see 2 distinct use cases, neither of which is really addressed by the current SDK api:
sleep for a specific time, which should always be "safe"
sleep for the max time possible, whatever that time is, even if that max time changes over time
Point 1 hints at some way to calculate a max sleep time that will always be safe and can never fail.
Point 2 requires that either the current suspected race condition be fixed, or a new api be implemented that sleeps for the max possible time independently of the value of cali, e.g.: system_deep_sleep_max_time(); //sleep for max possible time (receives no arguments)
Function system_deep_sleep() is of type bool. I would suggest the api should return 'false' when max sleeptime is exceeded. Currently it does not.
FayeY
changed the title
system_deep_sleep with max time sometimes doesn't wake up, possible race condition
[TW#25879] system_deep_sleep with max time sometimes doesn't wake up, possible race condition
Aug 29, 2018
Reference discussion in Arduino core issue tracker here.
CC @marcvtew
CC @5chufti
Hi,
Per NONOS SDK api reference doc section 3.3.9:
From the previous follows this implementation for calculating the max theoretical sleep time::
However, calling this:
system_deep_sleep(deepSleepMax());
seems to have odd behavior. Sometimes there is an error message in the serial output saying sleep time too long, sometimes the ESP sleeps, and sometimes the ESP doesn't wake up.
The NONOS SDK api reference doc says in section 3.3.9, in Note, 3rd bullet:
I suspect that:
The text was updated successfully, but these errors were encountered: