From 13d802262a6c6d854be94266dd6f113f95680d65 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 8 Dec 2016 01:41:27 +0800 Subject: [PATCH] cpu_start: disable boot watchdog only after starting the main task Boot watchdogs were disabled very early in startup code. It was possible to introduce an infinite loop anywhere in the many functions called from startup code, and this would not be detected by interrupt watchdog and task watchdog. This change postpones disabling of boot watchdogs to the point when the scheduler is running. Also replaces register expressed using integer address with a name. --- components/esp32/cpu_start.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index 81c748c11f..5924bc91d5 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -26,6 +26,7 @@ #include "soc/dport_reg.h" #include "soc/io_mux_reg.h" #include "soc/rtc_cntl_reg.h" +#include "soc/timer_group_reg.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -89,10 +90,6 @@ static const char* TAG = "cpu_start"; void IRAM_ATTR call_start_cpu0() { - //Kill wdt - REG_CLR_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN); - REG_CLR_BIT(0x6001f048, BIT(14)); //DR_REG_BB_BASE+48 - cpu_configure_region_protection(); //Move exception vectors to IRAM @@ -247,6 +244,9 @@ static void do_global_ctors(void) static void main_task(void* args) { + // Now that the application is about to start, disable boot watchdogs + REG_CLR_BIT(TIMG_WDTCONFIG0_REG(0), TIMG_WDT_FLASHBOOT_MOD_EN_S); + REG_CLR_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN); app_main(); vTaskDelete(NULL); }