diff options
| author | Trent Piepho <tpiepho@gmail.com> | 2024-03-02 01:25:10 -0800 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-03-08 15:55:17 +1100 |
| commit | af67be7adc4b76fead096fecd445ddeb6cc2c513 (patch) | |
| tree | e3ece0cbb8b50e6a62e8a79e6b1e5dabe8b6c732 /ports/esp32/modmachine.c | |
| parent | 9fc450689b7505a44460bd6cc3a25961e1e4306e (diff) | |
esp32/modmachine: Support bootloader on ESP32-S2/S3/C2/C3.
On these targets it's possible to enter the bootloader by setting a bit in
an RTC register before resetting.
Structure it in a way that a board can still provide a custom bootloader
handler. The handler here will be the default if none is provided, for any
board based on the supported targets.
Signed-off-by: Trent Piepho <tpiepho@gmail.com>
Diffstat (limited to 'ports/esp32/modmachine.c')
| -rw-r--r-- | ports/esp32/modmachine.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index a61d381e0..759455a59 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -220,6 +220,14 @@ static mp_int_t mp_machine_reset_cause(void) { } } +#if MICROPY_ESP32_USE_BOOTLOADER_RTC +#include "soc/rtc_cntl_reg.h" +NORETURN static void machine_bootloader_rtc(void) { + REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT); + esp_restart(); +} +#endif + #ifdef MICROPY_BOARD_ENTER_BOOTLOADER NORETURN void mp_machine_bootloader(size_t n_args, const mp_obj_t *args) { MICROPY_BOARD_ENTER_BOOTLOADER(n_args, args); |
