Chapter 4. API Guides
4.12.1 Overview
In certain situations, execution of the program can not be continued in a well defined way. In ESP-IDF, these situations
include:
• CPU Exceptions: Illegal Instruction, Load/Store Alignment Error, Load/Store Prohibited error, Double Ex-
ception.
• System level checks and safeguards:
– Interrupt watchdog timeout
– Task watchdog timeout (only fatal if CONFIG_ESP_TASK_WDT_PANIC is set)
– Cache access error
– Memory protection fault
– Brownout detection event
– Stack overflow
– Stack smashing protection check
– Heap integrity check
– Undefined behavior sanitizer (UBSAN) checks
• Failed assertions, via assert, configASSERT and similar macros.
This guide explains the procedure used in ESP-IDF for handling these errors, and provides suggestions on trou-
bleshooting the errors.
4.12.2 Panic Handler
Every error cause listed in the Overview will be handled by the panic handler.
The panic handler will start by printing the cause of the error to the console. For CPU exceptions, the message will
be similar to
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was␣
,→unhandled.
For some of the system level checks (interrupt watchdog, cache access error), the message will be similar to
Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory␣
,→region accessed). Exception was unhandled.
In all cases, the error cause will be printed in parentheses. See Guru Meditation Errors for a list of possible error
causes.
Subsequent behavior of the panic handler can be set using CONFIG_ESP_SYSTEM_PANIC configuration choice. The
available options are:
• Print registers and reboot (CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT) —default option.
This will print register values at the point of the exception, print the backtrace, and restart the chip.
• Print registers and halt (CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT)
Similar to the above option, but halt instead of rebooting. External reset is required to restart the program.
• Silent reboot (CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT)
Don’t print registers or backtrace, restart the chip immediately.
• Invoke GDB Stub (CONFIG_ESP_SYSTEM_PANIC_GDBSTUB)
Start GDB server which can communicate with GDB over console UART port. This option will only provide
read-only debugging or post-mortem debugging. See GDB Stub for more details.
• Invoke dynamic GDB Stub (ESP_SYSTEM_GDBSTUB_RUNTIME)
Start GDB server which can communicate with GDB over console UART port. This option allows the user to
debug a program at run time and set break points, alter the execution, etc. See GDB Stub for more details.
The behavior of the panic handler is affected by two other configuration options.
• If CONFIG_ESP32S2_DEBUG_OCDAWARE is enabled (which is the default), the panic handler will detect
whether a JTAG debugger is connected. If it is, execution will be halted and control will be passed to the
debugger. In this case, registers and backtrace are not dumped to the console, and GDBStub / Core Dump
functions are not used.
Espressif Systems 1335
Submit Document Feedback
Release v4.4