ESP32: deep sleep seems to cut clock to ULP processor
It seems like going to deep sleep stops the ULP processor. I uploaded a counter code to the ULP and it counts nicely as long as main CPUs running. When going to deep sleep counting stops but the counter value remains so the ULP was not reset or memory erased. After coming back from deep sleep counting works again.
As a side note: I would like to suggest to also add the ULP as a wakeup source in the esp32 package (in addition to the EXT, timer and touch options).
ports/esp32/ulp: Initial draft PR for RISCV ULP support S2/S3
The S2 and S3 chips contain a RISCV ULP co-processor in addition to the FSM ULP.
This PR is an initial attempt to provide access to the RISCV co-processor from micropython.
Operation
- During build cmake checks for the existence of file ports/esp32/ulp_riscv/main.c
- main.c is compiled and included in the micropython firmware bin file
- Calling ULP.riscv_load_binary() will load binary to ULP co-processor
- Calling ULP.riscv_run() will run RISCV ULP.
Example
Tested with IDF v4.4.4, micropython latest
MicroPython 3229791b6-dirty on 2023-05-20; INSIGHT_S3_GENERIC with ESP32-S3
Type "help()" for more information.
>>> import esp32
>>> ulp = esp32.ULP()
>>> ulp.riscv_load_binary()
>>> ulp.riscv_run()
>>>
>>> import machine
>>> machine.deepsleep(0)
After calling run() GPIO_14 will blink rapidly.
After entering deepsleep, GPIO_14 will continue to blink.
Next steps/improvements
- Move main.c ULP code to more appropriate location, possibly to board definition sub-folder?
- Support sharing variables between ULP and main program
- Documentation/examples