Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

torntrousers
Posts: 11
Joined: Thu Oct 08, 2015 2:31 pm

Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby torntrousers » Sat May 27, 2017 4:56 pm

I'm trying the extended deepSleep times available with the latest ESP8266 SDK 2.1.0. Some sleep time values work fine but some don't seem to work and the ESP wakes up almost immediately. Bit strange.

For example, calling system_deep_sleep with these works as expected:
uint64_t sleepTime = 10000000; // WORKS: 10 seconds
uint64_t sleepTime = 7200000000; // WORKS: 2 hours
uint64_t sleepTime = 9000000000; // WORKS: 2.5 hours
uint64_t sleepTime = 86400000000; // WORKS: 24 hours

But calling system_deep_sleep with values like these doesn't work and the ESP8266 wakes up almost immediately:
uint64_t sleepTime = 21600000000; // FAILS: 6 hours
uint64_t sleepTime = 74049000000; // FAILS: bit over 20 hours

In all cases system_deep_sleep is returning true, and the ESP8266 wakes up with rst cause:2, boot mode:(3,6).

What could be wrong, is this a bug?

pratik

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby pratik » Sun May 28, 2017 9:41 pm

Reset cause 2 means that you are getting the reboot due to reset pin activation.
Ensure that this has nothing to do with loose connections, if you are working on a prototype. Meanwhile I will let you know if I can reproduce this exact problem.

torntrousers
Posts: 11
Joined: Thu Oct 08, 2015 2:31 pm

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby torntrousers » Tue May 30, 2017 4:35 pm

Were you able to recreate this? Should be pretty easy - just try a deepSleep for 6 hours and it should wake up right away instead of sleeping.

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby Her Mary » Wed May 31, 2017 1:57 pm

May it be the maximum limitation of sleep time?
It is mentioned in the non OS API guide.

torntrousers
Posts: 11
Joined: Thu Oct 08, 2015 2:31 pm

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby torntrousers » Wed May 31, 2017 4:08 pm

I'm having trouble with the maths. In the API guide in system_deep_sleep in 3.3.9 it says:

The theoretical maximum value of time_in_us can be calculated by formula:
(time_in_us / cali) << 12 = 2^32 - 1
• cali = system_rtc_clock_cali_proc(), the cali is the RTC clock period (in us)

In system_rtc_clock_cali_proc in 3.3.22 it says:

RTC clock period (in us); bit11 ~ bit0 are decimal.
Example os_printf("clk cal : %d \r\n",system_rtc_clock_cali_proc()>>12);

When I try that printf on an ESP8266 it outputs "clk cal : 6"

So (time_in_us / cali) << 12 = 2^32 - 1
So time_in-us = ( (2^32 - 1) >> 12 ) * 6
= 6291450

Which is just 6 seconds! Clearly wrong as it sleeps for longer than that fine. Can anyone do the maths better?

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby Her Mary » Thu Jun 01, 2017 11:26 am

I think the "<< 12" means "bit11 ~ bit0 are decimal"... So the "cali" should not be "6", but 6xxxx...
It is "cali = system_rtc_clock_cali_proc()", not "cali = system_rtc_clock_cali_proc()>>12".
Last edited by Her Mary on Thu Jun 01, 2017 2:13 pm, edited 1 time in total.

torntrousers
Posts: 11
Joined: Thu Oct 08, 2015 2:31 pm

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby torntrousers » Thu Jun 01, 2017 12:51 pm

If thats the case then the longer sleep times should be fine, right? So why aren't they working for me? Could someone else here just try a deep sleep for 21600000000 (six hours) and see if it works for them or not?

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby Her Mary » Thu Jun 15, 2017 5:51 pm

The latest doc changed to (time_in_us / cali) << 12 = 2^31 - 1
Mine is 3.5 hours.

Bremer
Posts: 1
Joined: Sun Jun 18, 2017 6:51 pm

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby Bremer » Sun Jun 18, 2017 8:45 pm

I found another problem with system_deep_sleep(0)

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Inconsistent sleeping with SDK 2.1.0 uint64_t sleep times

Postby ESP_Faye » Mon Jun 19, 2017 10:04 am

Hi Bremer,

The deep sleep 0 issue has been solved, please have a try with the latest SDK. https://github.com/espressif/ESP8266_NONOS_SDK

Thanks for your interest in ESP8266!

Who is online

Users browsing this forum: No registered users and 64 guests