diff --git a/components/esp_rom/esp32s31/Kconfig.soc_caps.in b/components/esp_rom/esp32s31/Kconfig.soc_caps.in index 01d4d65544e..2b04709a21b 100644 --- a/components/esp_rom/esp32s31/Kconfig.soc_caps.in +++ b/components/esp_rom/esp32s31/Kconfig.soc_caps.in @@ -106,3 +106,7 @@ config ESP_ROM_CACHE_WRITEBACK_NEEDS_SYNC_TWICE_MAP config ESP_ROM_SUPPORT_SECURE_BOOT_FAST_WAKEUP bool default y + +config ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB + bool + default y diff --git a/components/esp_rom/esp32s31/esp_rom_caps.h b/components/esp_rom/esp32s31/esp_rom_caps.h index 5f912f24886..68b7ac6574a 100644 --- a/components/esp_rom/esp32s31/esp_rom_caps.h +++ b/components/esp_rom/esp32s31/esp_rom_caps.h @@ -33,3 +33,4 @@ #define ESP_ROM_BOOTLOADER_OFFSET_FLASH (0x2000) // Bootloader offset in flash determined by the ROM bootloader #define ESP_ROM_CACHE_WRITEBACK_NEEDS_SYNC_TWICE_MAP (1) // ROM cache writeback related needs patch to avoid sync loss, need map parameter #define ESP_ROM_SUPPORT_SECURE_BOOT_FAST_WAKEUP (1) // ROM supports the secure boot fast wakeup feature +#define ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB (1) // ROM supports the HP core to jump to the RTC memory to execute stub code after waking up from deepsleep. diff --git a/components/esp_rom/esp32s31/include/esp32s31/rom/rtc.h b/components/esp_rom/esp32s31/include/esp32s31/rom/rtc.h index c263ded86bf..e027180dabe 100644 --- a/components/esp_rom/esp32s31/include/esp32s31/rom/rtc.h +++ b/components/esp_rom/esp32s31/include/esp32s31/rom/rtc.h @@ -11,6 +11,7 @@ extern "C" { #endif #include +#include #include #include "esp_assert.h" @@ -180,6 +181,37 @@ void software_reset(void); */ void software_reset_cpu(int cpu_no); +typedef void (* esp_rom_wake_func_t)(void); + +/** + * @brief Read stored RTC wake function address + * + * Returns pointer to wake address if a value is set in RTC registers, and stored length & CRC all valid. + * valid means that both stored stub length and stored wake function address are four-byte aligned non-zero values + * and the crc check passes + * + * @param None + * + * @return esp_rom_wake_func_t : Returns pointer to wake address if a value is set in RTC registers + */ +esp_rom_wake_func_t esp_rom_get_rtc_wake_addr(void); + +/** + * @brief Store new RTC wake function address + * + * Set a new RTC wake address function. If a non-NULL function pointer is set then the function + * memory is calculated and stored also. + * + * @param entry_addr Address of function. should be 4-bytes aligned otherwise it will not start from the stub after wake from deepsleep, + * if NULL length will be ignored and all registers are cleared to 0. + * + * @param length length of function in RTC fast memory. should be less than RTC Fast memory size and aligned to 4-bytes. + * otherwise all registers are cleared to 0. + * + * @return None + */ +void esp_rom_set_rtc_wake_addr(esp_rom_wake_func_t entry_addr, size_t length); + /** * @} */ diff --git a/examples/system/deep_sleep_wake_stub/README.md b/examples/system/deep_sleep_wake_stub/README.md index a74d74985f2..bfcd188bb20 100644 --- a/examples/system/deep_sleep_wake_stub/README.md +++ b/examples/system/deep_sleep_wake_stub/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-H21 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-H21 | ESP32-S2 | ESP32-S3 | ESP32-S31 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | --------- | # Deep Sleep Wake Stub Example