diff --git a/arch/xtensa/src/esp32/esp32_start.c b/arch/xtensa/src/esp32/esp32_start.c index a70549f12b..6d97e54db1 100644 --- a/arch/xtensa/src/esp32/esp32_start.c +++ b/arch/xtensa/src/esp32/esp32_start.c @@ -86,14 +86,6 @@ void IRAM_ATTR __start(void) uint32_t regval; uint32_t sp; - /* Kill the watchdog timer */ - - putreg32(RTC_CNTL_WDT_WKEY_VALUE, RTC_CNTL_WDTWPROTECT_REG); - regval = getreg32(RTC_CNTL_WDTCONFIG0_REG); - regval &= ~RTC_CNTL_WDT_EN; - putreg32(regval, RTC_CNTL_WDTCONFIG0_REG); - putreg32(0, RTC_CNTL_WDTWPROTECT_REG); - /* Make sure that normal interrupts are disabled. This is really only an * issue when we are started in un-usual ways (such as from IRAM). In this * case, we can at least defer some unexpected interrupts left over from @@ -129,6 +121,17 @@ void IRAM_ATTR __start(void) regval &= ~DPORT_APPCPU_CLKGATE_EN; putreg32(regval, DPORT_APPCPU_CTRL_B_REG); + /* The 2nd stage bootloader enables RTC WDT to check on startup sequence + * related issues in application. Hence disable that as we are about to + * start the NuttX environment. + */ + + putreg32(RTC_CNTL_WDT_WKEY_VALUE, RTC_CNTL_WDTWPROTECT_REG); + regval = getreg32(RTC_CNTL_WDTCONFIG0_REG); + regval &= ~RTC_CNTL_WDT_EN; + putreg32(regval, RTC_CNTL_WDTCONFIG0_REG); + putreg32(0, RTC_CNTL_WDTWPROTECT_REG); + /* Set CPU frequency configured in board.h */ esp32_clockconfig();