Page 1 of 1

re-enter deep sleep in esp_wake_deep_sleep()

Posted: Mon Sep 03, 2018 4:33 pm
by rummyr
Apologies if this has already been asked.
Is it possible to re-enter deep sleep from within esp_wake_deep_sleep()?

Obviously I've tried, but if I call

Code: Select all

esp_sleep_enable_timer_wakeup(###)
without even trying to call

Code: Select all

esp_deep_sleep_start()
I get an

Code: Select all

rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
Am I just being stupid and this isn't accessible from within an RTC_IRAM_ATTR function?
or is it more complex?
or is it a bug?

Re: re-enter deep sleep in esp_wake_deep_sleep()

Posted: Tue Sep 04, 2018 12:20 am
by WiFive
The wake stub code can only call functions implemented in ROM or loaded into RTC Fast Memory
https://docs.espressif.com/projects/esp ... -stub.html

Re: re-enter deep sleep in esp_wake_deep_sleep()

Posted: Thu Sep 06, 2018 6:20 am
by rummyr
Still trying to get a handle on this .. hope people don't mind me adding findings here

ROM functions can be found in
https://github.com/espressif/esp-idf/tr ... nclude/rom

sleep related functions can be found in
https://github.com/espressif/esp-idf/bl ... ep_modes.c

So I guess it's going to be a case of copying the necessary code from sleep_modes.c, or maybe delving into ULP!

*deleted a long section based on me thinking IRAM was the same as RTC_IRAM*

Re: re-enter deep sleep in esp_wake_deep_sleep()

Posted: Sat Sep 08, 2018 1:40 pm
by boarchuz
There's sample code that does exactly this:

https://gist.github.com/igrr/54f7fbe051 ... d7fbecfeab

Re: re-enter deep sleep in esp_wake_deep_sleep()

Posted: Tue Oct 23, 2018 12:27 pm
by rummyr
That code was brill ... its a PITA to try to find exactly what you can and can't call though, you have to poke through the source looking for the IRAM tag.

For what it's worth in case anyone cares.

I'm finding that it takes around 1mSec from when I see the current begins to ramp up before my wake_stub code raises an IO line high.