]> granicus.if.org Git - esp-idf/commitdiff
cpu_start: disable boot watchdog only after starting the main task
authorIvan Grokhotkov <ivan@espressif.com>
Wed, 7 Dec 2016 17:41:27 +0000 (01:41 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Wed, 7 Dec 2016 17:42:37 +0000 (01:42 +0800)
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

index 81c748c11f23ed97f2ed1a9ea0a796409d508d36..5924bc91d5c02daf7b286c4ac1ecce96e30b2f79 100644 (file)
@@ -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);
 }