Page 1 of 1

Wake up after deep sleep

Posted: Wed Feb 19, 2020 7:44 am
by aleksboshnakov
Hi, I am new to esp32.
In the last two days I have tried to run different types of code and I have focused on how deep-sleep works that I can't understand. Is it normal that when the device wakes up it goes into the bootloader? Is it possible to avoid the bootloader and on wake up to resume the code from where it went in deep-sleep? I ask this because I notice that it takes about 300ms for the bootloader each time it wakes up and this is not good for the kind of purpose for which I am using esp32.

I await your news regarding the precise functioning of deep-sleep and wake up. Also because I could not find any information about this behavior.

Aleks.

Re: Wake up after deep sleep

Posted: Wed Feb 19, 2020 11:11 am
by WiFive
Only light sleep can resume

Re: Wake up after deep sleep

Posted: Wed Feb 19, 2020 1:18 pm
by aleksboshnakov
After I tried light sleep I realized that it resumes the code from the point where the device goes to sleep.

Thx.

Re: Wake up after deep sleep

Posted: Wed Feb 19, 2020 1:18 pm
by boarchuz
If you're using IDF v4 you can try CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP for significantly faster wakeup.

Re: Wake up after deep sleep

Posted: Thu Feb 20, 2020 7:49 am
by aleksboshnakov
I can't understand then what the deep-sleep mode is for if every time the device wakes up it has to bootloader.

Re: Wake up after deep sleep

Posted: Fri Feb 21, 2020 2:01 am
by WiFive
aleksboshnakov wrote:
Thu Feb 20, 2020 7:49 am
I can't understand then what the deep-sleep mode is for if every time the device wakes up it has to bootloader.
To use the least current, you have to shut everything down. If you can sleep for long periods then you will happily trade the wakeup time for the power savings.

Re: Wake up after deep sleep

Posted: Thu Feb 11, 2021 8:01 am
by ESP_alisitsyn
Hello @aleksboshnakov,

I just found your message but later. Want to add something to this discussion. When the chip starts the boot loader take place but you can start your code that can check some conditions and then continue to sleep or wake up after timeout or pin state change and load software normally on specific condition. This would significantly decrease power consumption and allows to use your logic after power up. This user code is called wake stub, please refer:
https://docs.espressif.com/projects/esp ... -stub.html

Let me know if you need more information.

Re: Wake up after deep sleep

Posted: Wed Mar 10, 2021 8:22 am
by aleksboshnakov
ESP_alisitsyn wrote:
Thu Feb 11, 2021 8:01 am
Hello @aleksboshnakov,

I just found your message but later. Want to add something to this discussion. When the chip starts the boot loader take place but you can start your code that can check some conditions and then continue to sleep or wake up after timeout or pin state change and load software normally on specific condition. This would significantly decrease power consumption and allows to use your logic after power up. This user code is called wake stub, please refer:
https://docs.espressif.com/projects/esp ... -stub.html

Let me know if you need more information.
Hello,

It's an interesting feature, but it's not for me. My problem is that as soon as possible I should wake up from deep sleep. By changing some configuration within "sdkconfig" I managed to decrease it to about 150ms but that's still a lot for what I should be doing.

Re: Wake up after deep sleep

Posted: Wed Mar 10, 2021 9:13 am
by boarchuz
aleksboshnakov wrote: I managed to decrease it to about 150ms but that's still a lot for what I should be doing.
Did you try the option I mentioned above? Is GPIO low on power on (or esp_rom_disable_logging)? Bootloader logging as minimal as acceptable?

I think a typical application with all optimisations should be able to do sleep->app_main in about 20-25ms; the lowest I've seen is 15ms.

Re: Wake up after deep sleep

Posted: Wed Mar 10, 2021 9:50 am
by aleksboshnakov
boarchuz wrote:
Wed Mar 10, 2021 9:13 am
aleksboshnakov wrote: I managed to decrease it to about 150ms but that's still a lot for what I should be doing.
Did you try the option I mentioned above? Is GPIO low on power on (or esp_rom_disable_logging)? Bootloader logging as minimal as acceptable?

I think a typical application with all optimisations should be able to do sleep->app_main in about 20-25ms; the lowest I've seen is 15ms.
Which GPIO are you referring to?
For now I have disabled image verification using

Code: Select all

bootloader_load_image_no_verify()
, commented

Code: Select all

memset(start, FREE_FILL_PATTERN, size)
and set QIO flash mode and 80MHz speed. Also, BOOTLOADER_LOG_LEVEL is set to "ERRORS".