
Deep sleep wake stubs are executed early during the wake-up process. They are loaded into RTC Fast Memory, and any data which they use must also be loaded into RTC memory. This memory holds its contents during deep sleep. The wake stub code can only call functions implemented in ROM or loaded into RTC Fast Memory, and can only access data loaded in RTC memory. All other RAM will be uninitialised and have random contents.
| Characteristics | Values |
|---|---|
| When are deep sleep wake stubs executed? | Very early during the wake-up process |
| Where is the deep sleep wake stub code loaded? | "RTC Fast Memory" |
| Where must the data used by the deep sleep wake stub code be loaded? | RTC memory |
Explore related products
What You'll Learn
- How to go back to sleep from deep sleep wake stub?
- How to blink an LED with the wake_stub every few seconds?
- Deep sleep wake stub code is loaded into RTC Fast Memory
- Wake stubs are executed early during the wake-up process
- The second way is a better option if you need to use strings or write other more complex code

How to go back to sleep from deep sleep wake stub
Deep sleep wake stubs are executed very early during the wake-up process. The code is loaded into "RTC Fast Memory" and any data which it uses must also be loaded into RTC memory.
To go back to sleep from a deep sleep wake stub, you can follow these steps:
- Clear the HOLD bit: CLEAR_PERI_REG_MASK(RTC_CNTL_PAD_HOLD_REG, BIT(9))
- Enable GPIO output: REG_WRITE(RTC_GPIO_ENABLE_W1TS_REG, BIT(RTC_GPIO_ENABLE_W1TS_S + 9))
- Set the GPIO output bit high: REG_WRITE(RTC_GPIO_OUT_W1TS_REG, BIT(RTC_GPIO_OUT_DATA_W1TS_S + 9))
- Feed the watchdog: REG_WRITE(TIMG_WDTFEED_REG(0), 1)
- Delay 1ms: ets_delay_us(1000)
- Set the GPIO output bit low: REG_WRITE(RTC_GPIO_OUT_W1TC_REG, BIT(RTC_GPIO_
It is important to note that the wake stub code can only call functions implemented in ROM or loaded into RTC Fast Memory. Additionally, the wake stub code can only access data loaded in RTC memory. All other RAM will be uninitialised and have random contents. The wake stub can use other RAM for temporary storage, but the contents will be overwritten when the system goes back to sleep or starts ESP-IDF.
Gently Waking Newborns: Tips for New Parents
You may want to see also
Explore related products

How to blink an LED with the wake_stub every few seconds
Deep sleep wake stubs are executed very early during the wake-up process. To blink an LED with the wake_stub every few seconds, you can follow these steps:
First, make sure that you have the necessary hardware and software. You will need an ESP32 microcontroller, an LED, and the ESP-IDF development environment.
Next, you will need to write code that uses the wake_stub functionality. Here is an example code snippet in C:
C
#include "esp_system.h"
#include "esp_deep_sleep.h"
#include "driver/gpio.h"
Void blink_led() {
// Set the GPIO pin for the LED
Gpio_pad_select_gpio(LED_GPIO);
// Set the GPIO pin as output
Gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT);
// Blink the LED
Gpio_set_level(LED_GPIO, 1);
VTaskDelay(1000 / portTICK_PERIOD_MS);
Gpio_set_level(LED_GPIO, 0);
VTaskDelay(1000 / portTICK_PERIOD_MS);
}
Void app_main() {
// Initialize the LED GPIO pin
Gpio_pad_select_gpio(LED_GPIO);
Gpio_set_direction(LED_GPIO, GPIO_MODE_OUTPUT);
// Go to deep sleep for a few seconds
Esp_deep_sleep_start();
// When the device wakes up, blink the LED
Blink_led();
}
In this code, we define a function `blink_led` that blinks the LED by toggling its GPIO pin high and low with a delay in between. We then call this function in the `app_main` function after the device wakes up from deep sleep.
To compile and run this code, you can follow these steps:
- Create a new ESP-IDF project and add the code to the `main/main.c` file.
- Configure the GPIO pin for the LED in the `menuconfig` menu.
- Build and flash the project to your ESP32 microcontroller.
- Observe the LED blinking every few seconds after the device wakes up from deep sleep.
By following these steps, you can blink an LED with the wake_stub every few seconds, utilizing the deep sleep wake functionality of the ESP32 microcontroller.
The Enigmatic Prince: Awakening the Enchanted Princess
You may want to see also
Explore related products
$44.99

Deep sleep wake stub code is loaded into RTC Fast Memory
Deep sleep wake stubs are executed very early during the wake-up process. For example, the equivalent example in rtc_wake_stub_counter.c: int wake_count; void RTC_IRAM_ATTR esp_wake_deep_sleep(void) { esp_default_wake_deep_sleep(); esp_rom_printf("Wake count %d\n", wake_count++); }.
The second way is a better option if you need to use strings, or write other more complex code. To reduce wake-up time use the CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP Kconfig option, see more information in Fast boot from Deep Sleep. During deep sleep, all RTC Fast memory areas will be validated with CRC. When ESP32 wakes up from deep sleep, the RTC fast memory will be validated with CRC again. If the validation passes, the wake stubs code will be executed. Otherwise, the normal initialization, bootloader and esp-idf codes will be executed.
Waking Up Refreshed: The Ideal Sleep Stage to Target
You may want to see also
Explore related products
$6.64 $6.99

Wake stubs are executed early during the wake-up process
Wake stubs are also used to read GPIO input. To do this, the HOLD bit must be cleared, GPIO output must be enabled, the GPIO output bit must be set high, and the watchdog must be fed. There is a delay of 1ms, and then the GPIO output bit is set low.
The second way to use wake stubs is a better option if you need to use strings or write other more complex code. To reduce wake-up time, use the CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP Kconfig option. During deep sleep, all RTC Fast memory areas will be validated with CRC. When ESP32 wakes up from deep sleep, the RTC fast memory will be validated with CRC again. If the validation passes, the wake stubs code will be executed. Otherwise, the normal initialization, bootloader and esp-idf codes will be executed.
Developing an Early Sleep and Wake Routine
You may want to see also
Explore related products

The second way is a better option if you need to use strings or write other more complex code
Deep sleep wake stub code is loaded into RTC Fast Memory, and any data it uses must also be loaded into RTC memory. The second way is a better option if you need to use strings or write other more complex code. This is because during deep sleep, all RTC Fast memory areas will be validated with CRC. When ESP32 wakes up from deep sleep, the RTC fast memory will be validated with CRC again. If the validation passes, the wake stubs code will be executed. Otherwise, the normal initialization, bootloader and esp-idf codes will be executed.
Brain Regions Regulating Sleep-Wake Cycles: An Overview
You may want to see also
Frequently asked questions
A deep sleep wake stub is a code that is loaded into "RTC Fast Memory".
When a deep sleep wake stub is executed, the RTC fast memory is validated with CRC. If the validation passes, the wake stub code will be executed. If not, the normal initialization, bootloader and esp-idf codes will be executed.
Any data that a deep sleep wake stub uses must also be loaded into RTC memory.
The contents of the RTC memory regions are held during deep sleep.
To go back to sleep from a deep sleep wake stub, you can clear the HOLD bit, enable GPIO output, set the GPIO output bit high, feed the watchdog, delay 1ms, and then set the GPIO output bit low.






![BY WISHTREND] Vitamin 75 maximizing cream, facial moisturizers, vitamin C&E, 50ml | All skin type, light-texture, refreshing-finish](https://m.media-amazon.com/images/I/517+T2sLERL._AC_UY218_.jpg)




































