Repository navigation
Core dump analysis
English · Русский
After an ESP32 crash, you can download a memory dump and turn it into a report of the cause, call stack and task state. Use tools/analyze_coredump.py for this.
Analysis runs on your computer with PlatformIO's Python, esp_coredump and GDB. You can disconnect the ESP32 while it runs.
- After the device restarts, open System on the portal's main page and click Core dump under Last reset reason. The REST API also supports programmatic dump downloads.
- Copy the
firmware.elfwith debug symbols from the exact build running on the ESP32 when it crashed. PlatformIO places it in.pio/build/<environment>/firmware.elf, for example.pio/build/s3_mini/firmware.elffor S3. - Keep the source revision and local changes used for that build alongside these files.
Important
The ELF must be archived before rebuilding or flashing another version. A newly rebuilt ELF is not a substitute, even when the version string is unchanged.
The decoder checks the dump and compares the ELF identity when it is recorded in the dump. Debug symbols come from the ELF. This file is required for decoding even if you have the .bin firmware image.
The download can fail in the following ways.
| Result | Cause |
|---|---|
| HTTP 404 | No saved dump is available |
| HTTP 500 | Image or partition validation failed before the response started |
| Transfer stopped after a successful response | Flash reading may have failed during the download |
Warning
The binary dump can contain sensitive data from device memory. Store it privately.
The commands below run in a terminal in the project directory. The examples assume that PlatformIO is
installed in its default location and that the input files have been copied into
crashes.
Print the report in the console:
& "$env:USERPROFILE\.platformio\penv\Scripts\python.exe" tools/analyze_coredump.py crashes/crash.bin crashes/firmware.elf --stdoutSave a UTF-8 text file:
& "$env:USERPROFILE\.platformio\penv\Scripts\python.exe" tools/analyze_coredump.py crashes/crash.bin crashes/firmware.elf crashes/report.txtAdd --stdout to the second command to both save and print the report. Omitting
the output filename also prints the report, without requiring --stdout.
The equivalent Linux commands run from the project directory:
"$HOME/.platformio/penv/bin/python" tools/analyze_coredump.py crashes/crash.bin crashes/firmware.elf --stdout"$HOME/.platformio/penv/bin/python" tools/analyze_coredump.py crashes/crash.bin crashes/firmware.elf crashes/report.txtThe same --stdout option saves and prints the report together. These commands use Linux GDB executables from the local PlatformIO installation.
Analysis requires PlatformIO's Python with esp_coredump and pygdbmi. If these modules are missing, the following commands install them into that environment.
& "$env:USERPROFILE\.platformio\penv\Scripts\python.exe" -m pip install esp-coredump pygdbmi"$HOME/.platformio/penv/bin/python" -m pip install esp-coredump pygdbmiThe script detects the chip from the dump container, checks the ELF architecture and selects the matching Xtensa or RISC-V GDB. Available chip names depend on the installed esp_coredump version and are listed in --help.
GDB is located under ~/.platformio/packages. The required tools are installed when your board's environment is built in PlatformIO.
The dump and ELF paths are sufficient for normal analysis. Use these options for a nonstandard installation or to select tools manually.
| Option | Meaning |
|---|---|
--chip CHIP |
Explicit chip selection. The default is auto. The selected target must match the dump and ELF architecture. |
--platformio-home PATH |
PlatformIO Core directory containing packages. The default is ~/.platformio. |
--gdb PATH |
Full path to the target-compatible GDB executable. |
--rom PATH |
Optional full path to a ROM ELF matching the target and chip revision. |
--source-map PATH |
Optional directory containing an archived system.cpp for the deliberate diagnostic test's source excerpt. This is not a general source-path remapper. |
Xtensa targets use the tool-xtensa-esp-elf-gdb package, with a chip-specific
xtensa-<chip>-elf-gdb executable or the available generic Xtensa GDB. RISC-V
targets use tool-riscv32-esp-elf-gdb/bin/riscv32-esp-elf-gdb. Executable names end
in .exe on Windows.
When matching target/revision information and ROM files are available, ROM
symbols are selected from tool-esp-rom-elfs. Otherwise analysis continues
without ROM symbols. ROM frames may lack names or source information. --rom
allows an explicit matching ROM ELF but is not required to generate a report.
Function names, source paths and line numbers come from the ELF's DWARF information. --source-map adds a diagnostic test source excerpt if you have its archived source. The full command syntax is available with --help.
Console output contains the report. When writing only to a file, the script prints a short JSON summary with task and frame counts and whether heap data is available.
| Exit code | Meaning |
|---|---|
| 0 | Report created |
| 1 | Analysis failed |
| 2 | Invalid arguments |
Setup and chip selection errors are explained on stderr. Unexpected failures show the error type and script location. The report contains processed GDB and decoder results.
| Section | Contents |
|---|---|
| Header | Detected target and CPU architecture, input dump and ELF paths, dump size, and decoder information. |
BUILD INFORMATION |
Captured firmware version, build date/time, Git commit, PlatformIO environment, Arduino core and ESP-IDF SDK versions, plus device information recorded at startup, when available. |
PANIC CAUSE |
Recognized diagnostic panic text, crashed thread/task, and TCB address. Arbitrary panic strings are omitted. |
ADDITIONAL CRASH METRICS |
Panic CPU core and uptime, plus the last completed internal-heap and PSRAM measurements and their age. |
EXCEPTION REGISTERS |
ESP-IDF exception information such as exception cause and fault address, when present. |
CRASHED THREAD REGISTERS |
Numeric CPU register values for the selected crashed thread. |
COMPLETE CRASHED THREAD STACK |
Every frame GDB can unwind, with function names and source paths/line numbers when DWARF provides them. Runtime arguments are omitted. |
| Test-specific sections | Known numeric test markers and a matching source excerpt for the deliberately injected diagnostic panic. These sections are not general local-variable or source dumps. |
ALL SAVED TASKS |
Saved tasks, priorities, stack pointers, approximate stack use, and complete recoverable stacks. The crashed task is marked. |
EXCEPTION REGISTERS decodes the additional Xtensa exception details when
present. For RISC-V, the report instead directs you to the numeric GDB registers
in CRASHED THREAD REGISTERS.
In BUILD INFORMATION, you can compare the version, Git revision and build environment with the saved ELF. Local source changes also affect the build.
The date and time in this section refer to compilation on the build computer. ESP32 uptime at the crash appears in the panic metrics.
Chip model and revision, core count, CPU frequency (MHz) and flash capacity (bytes) are recorded when the ESP32 starts. Frequency can change later. Older dumps show not captured for some fields.
| Field | Interpretation |
|---|---|
| CPU core at panic | The core that entered the panic handler. The fault may have originated on another core. |
| Uptime at panic | Time since boot in milliseconds, stored as a 64-bit value without the 49.7-day wraparound of 32-bit millis(). It is not wall-clock time. |
| Heap snapshot uptime | Saved measurement time since boot, in milliseconds. |
| Heap snapshot age at panic | Difference between panic uptime and snapshot uptime, in milliseconds. A value of 0 is valid. Age is unavailable if either uptime was not captured. It shows how close the measurement was to the crash. |
The INTERNAL HEAP and PSRAM HEAP sections are labeled last completed snapshot
and contain the SDK's multi_heap_info_t statistics:
| Report field (SDK field) | Interpretation |
|---|---|
Total free (total_free_bytes) |
Free bytes in the measured memory type. Internal heap and PSRAM are measured separately. |
Total allocated (total_allocated_bytes) |
Bytes currently allocated according to the allocator. This does not identify owners or requested object sizes. |
Largest free block (largest_free_block) |
Size in bytes of the largest free block. Comparing it with free bytes in the same memory section helps assess fragmentation. |
Minimum free, SDK counter (minimum_free_bytes) |
The SDK's minimum-free counter since boot, as observed at measurement time. A much lower minimum than the latest free value suggests earlier memory pressure. |
Allocated blocks (allocated_blocks) |
Number of allocated allocator blocks, not a count of application objects. |
Free blocks (free_blocks) |
Number of free allocator blocks. Many free blocks with a small largest block can indicate fragmentation. |
Total blocks (total_blocks) |
Total number of allocator blocks in the measured memory type. |
Note
The report uses the last completed measurement before the crash. The usual interval is 100 ms and can be longer under load. Internal RAM and PSRAM are sampled in turn. The sample age is available if the panic timestamp was captured.
A large free total with a small largest block suggests fragmentation.
If sampling was interrupted, the decoder skips both memory records. The panic CPU core and uptime are recorded separately and may still be available. Not available (no registered PSRAM heap in the snapshot) means the completed sample had no registered PSRAM heap. not captured means the dump lacks the data needed for that field.
Older firmware using CrashRecorder::ext remains supported. Those dumps provide
only heap, core, and whole-second uptime, with the original 32-bit millis()
wraparound at about 49.7 days. Earlier CoreDumpMetrics formats may show a
smaller set of panic-time heap fields instead of cached memory sections. The report labels distinguish these formats. Additional metrics cannot be recovered retroactively.
- Read
PANIC CAUSE, then locate the first relevant application frame in the crashed thread. Foresp_system_abort(), the SDK's abort/panic frames explain how execution stopped. Their application caller explains why. - Check exception cause and fault address. For example, a load/store exception with a near-zero address can suggest a null-pointer access. Corruption may have occurred earlier than the instruction where it was detected.
- Check measurement age, then compare free, minimum-free, and largest-block statistics within each memory type. Low free memory suggests pressure. A small largest block relative to free bytes can suggest fragmentation. These measurements alone do not identify a leak or establish which allocation failed.
- Inspect all saved task stacks for concurrent activity, waits, and suspicious call chains. Correlate this with the application's expected scheduling.
Failed to start OpenTherm task manager, Failed to start Core task manager,
and Failed to start System task manager identify an unsuccessful worker
startup. The firmware also aborts if the Sensors worker fails to start. The
current analyzer recognizes the first three messages explicitly. For the
Sensors worker, the caller frame in src/main.cpp and the available heap
measurements can help identify the failure.
In the recognized deliberate ESP32-S3 diagnostic test, IllegalInstruction
comes from the intentional Xtensa abort trap used by esp_system_abort().
It should not by itself be interpreted as an unexpected invalid instruction in
application code.
The stack shows the call chain active at the crash. GDB recovers every available frame. Recoverable depth depends on optimizations, tail calls, debug symbols and stack corruption. A frame marked no DWARF source location could not be assigned a reliable source line by the script.
Task stack used/free values are estimates from saved TCB pointers. They are not historical stack high-water marks, and a running task's saved top pointer may precede the fault. A small estimate deserves investigation but is not sufficient evidence of stack overflow.
The report deliberately excludes arbitrary runtime arguments, strings, and local variables. An omitted panic string or unrecognized task name is therefore not necessarily missing from the binary dump. Source paths in the report are the paths stored in the matching firmware's debug information. The corresponding archived sources provide the relevant code; a subsequently edited working tree may differ.