fix(panic_handler): Updated panic handler to use RTC WDT

This commit updates the following:
- Updates the panic handler to use only the RTC WDT to reset the system.
- Refactors some of the panic handler code.
- Updates Bluetooth files where in they now feed the WDTs instead of
  reconfiguring them.
- Removes some unnecessary configuration of WDTs from various files.
- Added a unit test to verify that the system does not lock up when the
  panic handler is stuck.
- Updates the memprot unit tests to work with the refactored panic
  handler.

Closes https://github.com/espressif/esp-idf/issues/15166
Closes https://github.com/espressif/esp-idf/issues/15018
Closes https://github.com/espressif/esp-idf/issues/10110
This commit is contained in:
Sudeep Mohanty
2025-03-06 09:17:26 +01:00
parent b0306575a8
commit cd887ef59a
20 changed files with 578 additions and 163 deletions
+71 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -25,6 +25,9 @@
#include "hal/mpu_hal.h"
#include "rom/cache.h"
volatile uint32_t g_panic_handler_stuck = 0;
volatile uint32_t g_panic_handler_crash = 0;
/* Test utility function */
extern void esp_restart_noos(void) __attribute__ ((noreturn));
@@ -133,6 +136,34 @@ void test_panic_extram_stack_bss(void)
#endif // ESP_COREDUMP_ENABLE_TO_FLASH && FREERTOS_TASK_CREATE_ALLOW_EXT_MEM
void __attribute__((no_sanitize_undefined)) test_panic_handler_stuck(void *arg)
{
g_panic_handler_stuck = 1;
/* Cause a panic */
#ifdef __XTENSA__
asm("ill"); // should be an invalid operation on xtensa targets
#elif __riscv
asm("unimp"); // should be an invalid operation on RISC-V targets
#endif
vTaskDelete(NULL);
}
void __attribute__((no_sanitize_undefined)) test_panic_handler_crash(void *arg)
{
g_panic_handler_crash = 1;
/* Cause a panic */
#ifdef __XTENSA__
asm("ill");
#elif __riscv
asm("unimp");
#endif
vTaskDelete(NULL);
}
#if !CONFIG_FREERTOS_UNICORE
static void infinite_loop(void* arg) {
(void) arg;
@@ -149,8 +180,47 @@ void test_task_wdt_cpu1(void)
}
}
void test_panic_handler_stuck1(void)
{
/* Cause the panic on core 1 */
xTaskCreatePinnedToCore(test_panic_handler_stuck, "panic_handler_stuck", 2048, NULL, 1, NULL, 1);
while(1) {
vTaskDelay(10);
}
}
void test_panic_handler_crash1(void)
{
/* Cause the panic on core 1 */
xTaskCreatePinnedToCore(test_panic_handler_crash, "panic_handler_crash", 2048, NULL, 1, NULL, 1);
while(1) {
vTaskDelay(10);
}
}
#endif
void test_panic_handler_stuck0(void)
{
/* Cause the panic on core 0 */
xTaskCreatePinnedToCore(test_panic_handler_stuck, "panic_handler_stuck", 2048, NULL, 1, NULL, 0);
while(1) {
vTaskDelay(10);
}
}
void test_panic_handler_crash0(void)
{
/* Cause the panic on core 0 */
xTaskCreatePinnedToCore(test_panic_handler_crash, "panic_handler_crash", 2048, NULL, 1, NULL, 0);
while(1) {
vTaskDelay(10);
}
}
void __attribute__((no_sanitize_undefined)) test_storeprohibited(void)
{
*(int*) 0x4 = 0;