ESP Core Dump Utility

1.16.0 · active · verified Sun Apr 12

esp-coredump is a Python-based utility that aids in the post-mortem analysis of core dumps generated by Espressif chips (e.g., ESP32, ESP32-S3). It helps users retrieve and analyze the software state at the moment of an unrecoverable error, providing insights into crashed tasks, registers, and call stacks. The library is currently at version 1.16.0 and maintains an active release cadence, frequently adding support for new Espressif chips and addressing bugs.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically use `esp-coredump` to analyze a core dump file. It sets up a `CoreDump` object with dummy files for illustration and attempts to retrieve core dump information. For actual usage, replace the dummy paths with your device's core dump and application ELF files.

import os
from esp_coredump import CoreDump

# --- This is a demonstration with dummy files. ---
# In a real scenario, 'coredump.b64' would come from an ESP device
# and 'program.elf' would be your firmware's ELF file with debug symbols.

# Create dummy core dump and ELF files for the example to run
dummy_coredump_b64_content = "hDEAAAEAAAAOAAAAbAEAAA==" # Minimal valid-looking base64
dummy_elf_content = b"\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00" # Minimal ELF header

with open("dummy_coredump.b64", "w") as f:
    f.write(dummy_coredump_b64_content)
with open("dummy_program.elf", "wb") as f:
    f.write(dummy_elf_content)

try:
    # Instantiate the CoreDump object.
    # 'chip' must match your target Espressif chip (e.g., 'esp32', 'esp32s3', 'esp32c3').
    # 'core' is the path to your core dump file, and 'core_format' specifies its type.
    # 'prog' is the path to your application's ELF file containing debug symbols.
    coredump = CoreDump(
        chip='esp32',
        core='./dummy_coredump.b64',
        core_format='b64',
        prog='./dummy_program.elf',
        # If GDB is not in your system's PATH, specify its location:
        # gdb=os.environ.get('ESP_GDB_PATH', None)
    )

    print("--- Attempting to retrieve Core Dump Info ---")
    # This will print information about the core dump, including task states and call stacks.
    # With dummy files, this will likely raise an error but demonstrates API usage.
    coredump.info_corefile()

    # To start an interactive GDB debugging session:
    # print("\n--- Starting GDB session (interactive, will block) ---")
    # coredump.dbg_corefile()

except Exception as e:
    print(f"An error occurred (expected with dummy files for full analysis): {e}")

finally:
    # Clean up dummy files
    if os.path.exists("dummy_coredump.b64"):
        os.remove("dummy_coredump.b64")
    if os.path.exists("dummy_program.elf"):
        os.remove("dummy_program.elf")

view raw JSON →