summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32/modmachine.c8
-rw-r--r--ports/esp32/mpconfigport.h8
2 files changed, 16 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);
diff --git a/ports/esp32/mpconfigport.h b/ports/esp32/mpconfigport.h
index 0474b7eaf..f004c78b0 100644
--- a/ports/esp32/mpconfigport.h
+++ b/ports/esp32/mpconfigport.h
@@ -268,6 +268,14 @@ typedef long mp_off_t;
#define MICROPY_HW_ENABLE_MDNS_RESPONDER (1)
#endif
+#ifndef MICROPY_BOARD_ENTER_BOOTLOADER
+// RTC has a register to trigger bootloader on these targets
+#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3
+#define MICROPY_ESP32_USE_BOOTLOADER_RTC (1)
+#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) machine_bootloader_rtc()
+#endif
+#endif
+
#ifdef MICROPY_BOARD_ENTER_BOOTLOADER
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
#else