|
|
|
@@ -30,7 +30,6 @@
|
|
|
|
|
|
|
|
|
|
#include "esp_private/panic_internal.h"
|
|
|
|
|
#include "port/panic_funcs.h"
|
|
|
|
|
#include "esp_rom_sys.h"
|
|
|
|
|
|
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
|
@@ -59,10 +58,6 @@
|
|
|
|
|
#include "esp_gdbstub.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
|
|
|
|
#include "hal/usb_serial_jtag_ll.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bool g_panic_abort = false;
|
|
|
|
|
static char *s_panic_abort_details = NULL;
|
|
|
|
|
|
|
|
|
@@ -73,13 +68,13 @@ static wdt_hal_context_t wdt1_context = {.inst = WDT_MWDT1, .mwdt_dev = &TIMERG1
|
|
|
|
|
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
|
|
|
|
|
|
|
|
|
#if CONFIG_ESP_CONSOLE_UART
|
|
|
|
|
static uart_hal_context_t s_panic_uart = { .dev = CONFIG_ESP_CONSOLE_UART_NUM == 0 ? &UART0 :&UART1 };
|
|
|
|
|
static uart_hal_context_t s_panic_uart = { .dev = CONFIG_ESP_CONSOLE_UART_NUM == 0 ? &UART0 : &UART1 };
|
|
|
|
|
|
|
|
|
|
void panic_print_char(const char c)
|
|
|
|
|
{
|
|
|
|
|
uint32_t sz = 0;
|
|
|
|
|
while (!uart_hal_get_txfifo_len(&s_panic_uart));
|
|
|
|
|
uart_hal_write_txfifo(&s_panic_uart, (uint8_t *) &c, 1, &sz);
|
|
|
|
|
while(!uart_hal_get_txfifo_len(&s_panic_uart));
|
|
|
|
|
uart_hal_write_txfifo(&s_panic_uart, (uint8_t*) &c, 1, &sz);
|
|
|
|
|
}
|
|
|
|
|
#endif // CONFIG_ESP_CONSOLE_UART
|
|
|
|
|
|
|
|
|
@@ -92,27 +87,6 @@ void panic_print_char(const char c)
|
|
|
|
|
}
|
|
|
|
|
#endif // CONFIG_ESP_CONSOLE_USB_CDC
|
|
|
|
|
|
|
|
|
|
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
|
|
|
|
//Timeout; if there's no host listening, the txfifo won't ever
|
|
|
|
|
//be writable after the first packet.
|
|
|
|
|
|
|
|
|
|
#define USBSERIAL_TIMEOUT_MAX_US 50000
|
|
|
|
|
static int s_usbserial_timeout = 0;
|
|
|
|
|
|
|
|
|
|
void panic_print_char(const char c)
|
|
|
|
|
{
|
|
|
|
|
while (!usb_serial_jtag_ll_txfifo_writable() && s_usbserial_timeout < (USBSERIAL_TIMEOUT_MAX_US / 100)) {
|
|
|
|
|
esp_rom_delay_us(100);
|
|
|
|
|
s_usbserial_timeout++;
|
|
|
|
|
}
|
|
|
|
|
if (usb_serial_jtag_ll_txfifo_writable()) {
|
|
|
|
|
usb_serial_jtag_ll_write_txfifo((const uint8_t *)&c, 1);
|
|
|
|
|
s_usbserial_timeout = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif //CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if CONFIG_ESP_CONSOLE_NONE
|
|
|
|
|
void panic_print_char(const char c)
|
|
|
|
|
{
|
|
|
|
@@ -122,7 +96,7 @@ void panic_print_char(const char c)
|
|
|
|
|
|
|
|
|
|
void panic_print_str(const char *str)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; str[i] != 0; i++) {
|
|
|
|
|
for(int i = 0; str[i] != 0; i++) {
|
|
|
|
|
panic_print_char(str[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -171,7 +145,7 @@ static void reconfigure_all_wdts(void)
|
|
|
|
|
//Reconfigure TWDT (Timer Group 0)
|
|
|
|
|
wdt_hal_init(&wdt0_context, WDT_MWDT0, MWDT0_TICK_PRESCALER, false); //Prescaler: wdt counts in ticks of TG0_WDT_TICK_US
|
|
|
|
|
wdt_hal_write_protect_disable(&wdt0_context);
|
|
|
|
|
wdt_hal_config_stage(&wdt0_context, 0, 1000 * 1000 / MWDT0_TICKS_PER_US, WDT_STAGE_ACTION_RESET_SYSTEM); //1 second before reset
|
|
|
|
|
wdt_hal_config_stage(&wdt0_context, 0, 1000*1000/MWDT0_TICKS_PER_US, WDT_STAGE_ACTION_RESET_SYSTEM); //1 second before reset
|
|
|
|
|
wdt_hal_enable(&wdt0_context);
|
|
|
|
|
wdt_hal_write_protect_enable(&wdt0_context);
|
|
|
|
|
|
|
|
|
@@ -216,29 +190,29 @@ void esp_panic_handler(panic_info_t *info)
|
|
|
|
|
info->exception = PANIC_EXCEPTION_ABORT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* For any supported chip, the panic handler prints the contents of panic_info_t in the following format:
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Guru Meditation Error: Core <core> (<exception>). <description>
|
|
|
|
|
* <details>
|
|
|
|
|
*
|
|
|
|
|
* <state>
|
|
|
|
|
*
|
|
|
|
|
* <elf_info>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* ----------------------------------------------------------------------------------------
|
|
|
|
|
* core - core where exception was triggered
|
|
|
|
|
* exception - what kind of exception occured
|
|
|
|
|
* description - a short description regarding the exception that occured
|
|
|
|
|
* details - more details about the exception
|
|
|
|
|
* state - processor state like register contents, and backtrace
|
|
|
|
|
* elf_info - details about the image currently running
|
|
|
|
|
*
|
|
|
|
|
* NULL fields in panic_info_t are not printed.
|
|
|
|
|
*
|
|
|
|
|
* */
|
|
|
|
|
/*
|
|
|
|
|
* For any supported chip, the panic handler prints the contents of panic_info_t in the following format:
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Guru Meditation Error: Core <core> (<exception>). <description>
|
|
|
|
|
* <details>
|
|
|
|
|
*
|
|
|
|
|
* <state>
|
|
|
|
|
*
|
|
|
|
|
* <elf_info>
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* ----------------------------------------------------------------------------------------
|
|
|
|
|
* core - core where exception was triggered
|
|
|
|
|
* exception - what kind of exception occured
|
|
|
|
|
* description - a short description regarding the exception that occured
|
|
|
|
|
* details - more details about the exception
|
|
|
|
|
* state - processor state like register contents, and backtrace
|
|
|
|
|
* elf_info - details about the image currently running
|
|
|
|
|
*
|
|
|
|
|
* NULL fields in panic_info_t are not printed.
|
|
|
|
|
*
|
|
|
|
|
* */
|
|
|
|
|
if (info->reason) {
|
|
|
|
|
panic_print_str("Guru Meditation Error: Core ");
|
|
|
|
|
panic_print_dec(info->core);
|
|
|
|
@@ -322,7 +296,7 @@ void esp_panic_handler(panic_info_t *info)
|
|
|
|
|
wdt_hal_disable(&rtc_wdt_ctx);
|
|
|
|
|
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
|
|
|
|
|
panic_print_str("Entering gdb stub now.\r\n");
|
|
|
|
|
esp_gdbstub_panic_handler((esp_gdbstub_frame_t *)info->frame);
|
|
|
|
|
esp_gdbstub_panic_handler(info->frame);
|
|
|
|
|
#else
|
|
|
|
|
#if CONFIG_ESP_COREDUMP_ENABLE
|
|
|
|
|
static bool s_dumping_core;
|
|
|
|
@@ -347,7 +321,8 @@ void esp_panic_handler(panic_info_t *info)
|
|
|
|
|
#if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
|
|
|
|
|
|
|
|
|
if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) {
|
|
|
|
|
switch (info->exception) {
|
|
|
|
|
switch (info->exception)
|
|
|
|
|
{
|
|
|
|
|
case PANIC_EXCEPTION_IWDT:
|
|
|
|
|
esp_reset_reason_set_hint(ESP_RST_INT_WDT);
|
|
|
|
|
break;
|
|
|
|
@@ -373,10 +348,10 @@ void esp_panic_handler(panic_info_t *info)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void __attribute__((noreturn,no_sanitize_undefined)) panic_abort(const char *details)
|
|
|
|
|
void __attribute__((noreturn)) panic_abort(const char *details)
|
|
|
|
|
{
|
|
|
|
|
g_panic_abort = true;
|
|
|
|
|
s_panic_abort_details = (char *) details;
|
|
|
|
|
s_panic_abort_details = (char*) details;
|
|
|
|
|
|
|
|
|
|
#if CONFIG_APPTRACE_ENABLE
|
|
|
|
|
#if CONFIG_SYSVIEW_ENABLE
|
|
|
|
@@ -388,7 +363,7 @@ void __attribute__((noreturn,no_sanitize_undefined)) panic_abort(const char *det
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
*((int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
|
|
|
|
|
while (1);
|
|
|
|
|
while(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Weak versions of reset reason hint functions.
|
|
|
|
|