Skip to content

ESP32 Wake Stub Not Executing

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 Wake Stub Not Executing. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 wake stub (RTC fast memory code) runs on cold boot but not on wake from deep sleep.

Quick Fix

Wrong

// No wake stub defined. Full setup() runs on every wake.
Full boot takes 150ms. Extra power consumed on every wake.
void RTC_IRAM_ATTR esp_wake_deep_sleep() {
  esp_default_wake_deep_sleep();
  // Quick actions: increment counter, read sensor, set GPIO
  RTC_DATA_ATTR int count = 0;
  count++;
  if (count % 10 == 0) {
    esp_deep_sleep_start();  // Continue sleep for 9/10 wakes
  }
}
void setup() {
  // Runs only when ESP decides to boot fully
  Serial.begin(115200);
  Serial.println("Full boot");
}
(Wakes 9 times without serial output, 10th wake: Full boot)

Prevention

Place wake stub in RTC_IRAM_ATTR section. Stub runs before DRAM is restored. Keep stub minimal (<512 bytes). Use stub to decide whether full boot is needed. Stub can access RTC_DATA_ATTR variables.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What is a wake stub?

A wake stub is a small program that runs immediately on wake from deep sleep before the main firmware boots. It executes from RTC fast memory.

Why use a wake stub?

Wake stubs reduce wake time from ~150ms to ~20ms. They can make wake decisions and re-enter sleep without full boot.

How large can a wake stub be?

Wake stubs are limited to about 8KB of RTC fast memory. Keep under 512 bytes for reliable operation.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro