|
|
@@ -36,6 +36,7 @@
|
|
|
#include "regi2c_ctrl.h"
|
|
|
#include "bootloader_console.h"
|
|
|
#include "bootloader_flash_priv.h"
|
|
|
+#include "bootloader_soc.h"
|
|
|
#include "esp_efuse.h"
|
|
|
|
|
|
static const char *TAG = "boot.esp32c3";
|
|
|
@@ -263,7 +264,7 @@ static inline void bootloader_hardware_init(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static inline void bootloader_glitch_reset_disable(void)
|
|
|
+static inline void bootloader_ana_reset_config(void)
|
|
|
{
|
|
|
/*
|
|
|
For origin chip & ECO1: only support swt reset;
|
|
|
@@ -271,11 +272,27 @@ static inline void bootloader_glitch_reset_disable(void)
|
|
|
For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
|
|
|
*/
|
|
|
uint8_t chip_version = bootloader_common_get_chip_revision();
|
|
|
- if (chip_version < 2) {
|
|
|
- REG_SET_FIELD(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SEL, RTC_CNTL_FIB_SUPER_WDT_RST);
|
|
|
- } else {
|
|
|
- // checked on ESP32-C3 revisions 2 and 3
|
|
|
- REG_SET_FIELD(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SEL, RTC_CNTL_FIB_SUPER_WDT_RST | RTC_CNTL_FIB_BOR_RST);
|
|
|
+ switch (chip_version) {
|
|
|
+ case 0:
|
|
|
+ case 1:
|
|
|
+ //Enable WDT reset. Disable BOR and GLITCH reset
|
|
|
+ bootloader_ana_super_wdt_reset_config(true);
|
|
|
+ bootloader_ana_bod_reset_config(false);
|
|
|
+ bootloader_ana_clock_glitch_reset_config(false);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ //Enable WDT and BOR reset. Disable GLITCH reset
|
|
|
+ bootloader_ana_super_wdt_reset_config(true);
|
|
|
+ bootloader_ana_bod_reset_config(true);
|
|
|
+ bootloader_ana_clock_glitch_reset_config(false);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ default:
|
|
|
+ //Enable WDT, BOR, and GLITCH reset
|
|
|
+ bootloader_ana_super_wdt_reset_config(true);
|
|
|
+ bootloader_ana_bod_reset_config(true);
|
|
|
+ bootloader_ana_clock_glitch_reset_config(true);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -284,7 +301,7 @@ esp_err_t bootloader_init(void)
|
|
|
esp_err_t ret = ESP_OK;
|
|
|
|
|
|
bootloader_hardware_init();
|
|
|
- bootloader_glitch_reset_disable();
|
|
|
+ bootloader_ana_reset_config();
|
|
|
bootloader_super_wdt_auto_feed();
|
|
|
// protect memory region
|
|
|
bootloader_init_mem();
|