wokwi-features
wokwi-features copied to clipboard
Simulated ESP device does not return from light sleep on idle
Describe the bug
I'm using power management on my esp32s3 firmware to put the device to sleep when idle. This works fine on the physical device, as it sleeps a few milliseconds between tasks. However, when this happens during simulation (=FreeRTOS's idle task puts the device to light sleep), the simulation never returns to a running state.
To Reproduce
https://github.com/lptr/light-sleep-on-idle
There are the following requirements to reproduce the problem (all set up in the repo above):
- in
sdkconfigtheCONFIG_FREERTOS_USE_TICKLESS_IDLEoption needs to be enabled, - in
main.cwe need to callesp_pm_configure()to enable light sleep on idle, - the device needs to be idle, e.g. by running
vTaskDelay().
Once the device enters the delay it never comes back to running in the simulator.
Full console output:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2810,len:0x178c
load:0x403c8700,len:0x4
load:0x403c8704,len:0xcb8
load:0x403cb700,len:0x2db0
entry 0x403c8914
I (23) boot: ESP-IDF v5.3.1-dirty 2nd stage bootloader
I (24) boot: compile time Nov 28 2024 22:22:31
I (25) boot: Multicore bootloader
I (28) boot: chip revision: v0.0
I (31) boot.esp32s3: Boot SPI Speed : 80MHz
I (36) boot.esp32s3: SPI Mode : DIO
I (40) boot.esp32s3: SPI Flash Size : 4MB
I (45) boot: Enabling RNG early entropy source...
I (51) boot: Partition Table:
I (54) boot: ## Label Usage Type ST Offset Length
I (62) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (69) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (76) boot: 2 factory factory app 00 00 00010000 00100000
I (84) boot: End of partition table
I (88) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0ae38h ( 44600) map
I (128) esp_image: segment 1: paddr=0001ae60 vaddr=3fc94000 size=02b14h ( 11028) load
I (140) esp_image: segment 2: paddr=0001d97c vaddr=40374000 size=0269ch ( 9884) load
I (151) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=192c8h (103112) map
I (225) esp_image: segment 4: paddr=000392f0 vaddr=4037669c size=0d8c8h ( 55496) load
I (277) esp_image: segment 5: paddr=00046bc0 vaddr=600fe000 size=00100h ( 256) load
I (280) esp_image: segment 6: paddr=00046cc8 vaddr=600fe100 size=00008h ( 8) load
I (309) boot: Loaded app from partition at offset 0x10000
I (310) boot: Disabling RNG early entropy source...
I (321) cpu_start: Multicore app
I (331) cpu_start: Pro cpu start user code
I (332) cpu_start: cpu freq: 160000000 Hz
I (333) app_init: Application information:
I (334) app_init: Project name: light-sleep-on-idle
I (340) app_init: App version: 1
I (345) app_init: Compile time: Nov 28 2024 22:22:19
I (351) app_init: ELF file SHA256: 7853b124d...
I (356) app_init: ESP-IDF: v5.3.1-dirty
I (361) efuse_init: Min chip rev: v0.0
I (366) efuse_init: Max chip rev: v0.99
I (371) efuse_init: Chip rev: v0.0
I (376) heap_init: Initializing. RAM available for dynamic allocation:
I (383) heap_init: At 3FC974A0 len 00052270 (328 KiB): RAM
I (389) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (395) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (401) heap_init: At 600FE108 len 00001EE0 (7 KiB): RTCRAM
I (410) spi_flash: detected chip: gd
I (412) spi_flash: flash io: dio
I (417) sleep: Configure to isolate all GPIO pins in sleep state
I (424) sleep: Enable automatic switching of GPIO sleep configuration
I (442) main_task: Started on CPU0
I (452) main_task: Calling app_main()
I (452) pm: Frequency switching config: CPU_MAX: 160, APB_MAX: 80, APB_MIN: 40, Light sleep: ENABLED
I (452) sleep: Code start at 0x42000020, total 103110, data start at 0x3c020020, total 44600 Bytes
I aitn't dead!
Expected behavior
I aitn't dead! should be printed once every second, instead of just once.
The simulated device should return to running after a very short period of time, as FreeRTOS only puts the device to light sleep until the end of the requested vTaskDelay().
Environment (please complete the following information):
Version: 1.95.3 (system setup) Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813 Date: 2024-11-13T14:50:04.152Z Electron: 32.2.1 ElectronBuildId: 10427718 Chromium: 128.0.6613.186 Node.js: 20.18.0 V8: 12.8.374.38-electron.0 OS: Windows_NT x64 10.0.22631