Bladeren bron

Merge branch 'bugfix/int-wdt-fix' into 'master'

Fix the things that broke when adding the new WDTs

Seemingly, I broke a bunch of things when adding the interrupt WDTs and moved the panic handler to the esp32 directory. This fixes that, as well as the issue where flashing would trigger the int wdt. It also bodges in a fix for a merge artifact breaking the halt-on-first-thread-when-openocd-is-connected; that fix should be refined later.

See merge request !157

Ivan Grokhotkov 9 jaren geleden
bovenliggende
commit
19c4996bc8

+ 2 - 2
components/esp32/Kconfig

@@ -157,7 +157,7 @@ config ULP_COPROC_RESERVE_MEM
 
 choice ESP32_PANIC
     prompt "Panic handler behaviour"
-    default FREERTOS_PANIC_PRINT_REBOOT
+    default ESP32_PANIC_PRINT_REBOOT
     help
         If FreeRTOS detects unexpected behaviour or an unhandled exception, the panic handler is 
         invoked. Configure the panic handlers action here.
@@ -206,7 +206,7 @@ config INT_WDT
 config INT_WDT_TIMEOUT_MS
     int "Interrupt watchdog timeout (ms)"
     depends on INT_WDT
-    default 10
+    default 300
     range 10 10000
     help
         The timeout of the watchdog, in miliseconds. Make this higher than the FreeRTOS tick rate.

+ 3 - 2
components/esp32/int_wdt.c

@@ -24,6 +24,7 @@
 #include <esp_types.h>
 #include "esp_err.h"
 #include "esp_intr.h"
+#include "esp_attr.h"
 #include "soc/timer_group_struct.h"
 #include "soc/timer_group_reg.h"
 
@@ -66,7 +67,7 @@ void esp_int_wdt_init() {
 //Not static; the ISR assembly checks this.
 bool int_wdt_app_cpu_ticked=false;
 
-void vApplicationTickHook(void) {
+void IRAM_ATTR vApplicationTickHook(void) {
     if (xPortGetCoreID()!=0) {
         int_wdt_app_cpu_ticked=true;
     } else {
@@ -82,7 +83,7 @@ void vApplicationTickHook(void) {
     }
 }
 #else
-void vApplicationTickHook(void) {
+void IRAM_ATTR vApplicationTickHook(void) {
     if (xPortGetCoreID()!=0) return;
     TIMERG1.wdt_wprotect=TIMG_WDT_WKEY_VALUE;
     TIMERG1.wdt_config2=CONFIG_INT_WDT_TIMEOUT_MS*2;        //Set timeout before interrupt

+ 2 - 1
components/esp32/ld/esp32.common.ld

@@ -47,6 +47,7 @@ SECTIONS
     _iram_text_start = ABSOLUTE(.);
     *(.iram1 .iram1.*)
     *libfreertos.a:(.literal .text .literal.* .text.*)
+    *libesp32.a:panic.o(.literal .text .literal.* .text.*)
     *libphy.a:(.literal .text .literal.* .text.*)
     *librtc.a:(.literal .text .literal.* .text.*)
     *libpp.a:(.literal .text .literal.* .text.*)
@@ -92,7 +93,7 @@ SECTIONS
     KEEP(*(.gnu.linkonce.s2.*))
     KEEP(*(.jcr))
     *(.dram1 .dram1.*)
-    *libfreertos.a:panic.o(.rodata .rodata.*)
+    *libesp32.a:panic.o(.rodata .rodata.*)
     _data_end = ABSOLUTE(.);
     . = ALIGN(4);
     _heap_start = ABSOLUTE(.);

+ 5 - 1
components/esp32/panic.c

@@ -30,7 +30,7 @@
 
 #include "esp_gdbstub.h"
 #include "esp_panic.h"
-
+#include "esp_attr.h"
 
 /*
 Panic handlers; these get called when an unhandled exception occurs or the assembly-level
@@ -38,6 +38,10 @@ task switching / interrupt code runs into an unrecoverable error. The default ta
 overflow handler also is in here.
 */
 
+/*
+Note: The linker script will put everything in this file in IRAM/DRAM, so it also works with flash cache disabled.
+*/
+
 #if !CONFIG_ESP32_PANIC_SILENT_REBOOT
 //printf may be broken, so we fix our own printing fns...
 inline static void panicPutchar(char c) {

+ 1 - 1
components/freertos/FreeRTOS-openocd.c

@@ -18,6 +18,6 @@
 #define USED
 #endif
 
-#ifdef CONFIG_FREERTOS_DEBUG_OCDAWARE
+#ifdef CONFIG_ESP32_DEBUG_OCDAWARE
 const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1;
 #endif

+ 1 - 1
components/freertos/Kconfig

@@ -121,7 +121,7 @@ endchoice
 
 config FREERTOS_BREAK_ON_SCHEDULER_START_JTAG
     bool "Stop program on scheduler start when JTAG/OCD is detected"
-    depends on FREERTOS_DEBUG_OCDAWARE
+    depends on ESP32_DEBUG_OCDAWARE
     default y
     help
         If JTAG/OCD is connected, stop execution when the scheduler is started and the first

+ 6 - 7
components/freertos/tasks.c

@@ -1018,6 +1018,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
 
 			if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )
 			{
+#if portFIRST_TASK_HOOK
+				if ( xPortGetCoreID() == 0 ) {
+					vPortFirstTaskHook(pxTaskCode);
+				}
+#endif /* configFIRST_TASK_HOOK */
 				/* This is the first task to be created so do the preliminary
 				initialisation required.  We will not recover if this call
 				fails, but we will report the failure. */
@@ -1044,12 +1049,6 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
 						/* Schedule if nothing is scheduled yet, or overwrite a task of lower prio. */
 						if ( pxCurrentTCB[i] == NULL || pxCurrentTCB[i]->uxPriority <= pxNewTCB->uxPriority )
 						{
-#if portFIRST_TASK_HOOK
-							if ( i == 0) {
-								vPortFirstTaskHook(pxTaskCode);
-							}
-#endif /* configFIRST_TASK_HOOK */
-
 							pxCurrentTCB[i] = pxNewTCB;
 							break;
 						}
@@ -2309,7 +2308,7 @@ BaseType_t xSwitchRequired = pdFALSE;
 		{
 			/* Guard against the tick hook being called when the pended tick
 			count is being unwound (when the scheduler is being unlocked). */
-			if( uxPendedTicks == ( UBaseType_t ) 0U )
+			if( ( uxSchedulerSuspended[ xPortGetCoreID() ] != ( UBaseType_t ) pdFALSE ) || uxPendedTicks == ( UBaseType_t ) 0U )
 			{
 				vApplicationTickHook();
 			}

+ 1 - 0
components/vfs/vfs_uart.c

@@ -18,6 +18,7 @@
 #include "sys/errno.h"
 #include "sys/lock.h"
 #include "soc/uart_struct.h"
+#include "sdkconfig.h"
 
 static uart_dev_t* s_uarts[3] = {&UART0, &UART1, &UART2};
 static _lock_t s_uart_locks[3]; // per-UART locks, lazily initialized