mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
esp32: RWDT is used to reboot system in case of panic handler crash
also fixes TG1WDG protection bug in panic handler
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#include "esp_task_wdt.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_coexist.h"
|
||||
#include "esp_panic.h"
|
||||
#include "esp_core_dump.h"
|
||||
#include "trax.h"
|
||||
|
||||
@@ -92,6 +93,11 @@ static const char* TAG = "cpu_start";
|
||||
|
||||
void IRAM_ATTR call_start_cpu0()
|
||||
{
|
||||
#if CONFIG_FREERTOS_UNICORE
|
||||
RESET_REASON rst_reas[1];
|
||||
#else
|
||||
RESET_REASON rst_reas[2];
|
||||
#endif
|
||||
cpu_configure_region_protection();
|
||||
|
||||
//Move exception vectors to IRAM
|
||||
@@ -99,10 +105,25 @@ void IRAM_ATTR call_start_cpu0()
|
||||
"wsr %0, vecbase\n" \
|
||||
::"r"(&_init_start));
|
||||
|
||||
rst_reas[0] = rtc_get_reset_reason(0);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
rst_reas[1] = rtc_get_reset_reason(1);
|
||||
#endif
|
||||
// from panic handler we can be reset by RWDT or TG0WDT
|
||||
if (rst_reas[0] == RTCWDT_SYS_RESET || rst_reas[0] == TG0WDT_SYS_RESET
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
|| rst_reas[1] == RTCWDT_SYS_RESET || rst_reas[1] == TG0WDT_SYS_RESET
|
||||
#endif
|
||||
) {
|
||||
// stop wdt in case of any
|
||||
ESP_EARLY_LOGI(TAG, "Stop panic WDT");
|
||||
esp_panic_wdt_stop();
|
||||
}
|
||||
|
||||
memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start));
|
||||
|
||||
/* Unless waking from deep sleep (implying RTC memory is intact), clear RTC bss */
|
||||
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
|
||||
if (rst_reas[0] != DEEPSLEEP_RESET) {
|
||||
memset(&_rtc_bss_start, 0, (&_rtc_bss_end - &_rtc_bss_start) * sizeof(_rtc_bss_start));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user