Skip to content

Commit

Permalink
xtensa/esp32: Move RTC WDT deinit after initial setup
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
  • Loading branch information
gustavonihei committed Jun 25, 2021
1 parent 4073c9b commit ad14246
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions arch/xtensa/src/esp32/esp32_start.c
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ad14246

Please sign in to comment.