Skip to main content

esp-riscv-trace

Decoder for RISC-V hardware instruction trace captured on Espressif chips.

It reads OpenOCD .esptrace captures and esp-coredump core ELFs with a trace note. It reconstructs the executed program flow, resolves each PC to a function and source line through the app ELF, and writes a text dump, a hot-spot table, the call history that led to a crash, or call stacks for a flame graph. Lost instruction continuity is reported as a gap.

It is a command-line tool. Other tools, such as esp-coredump, read captures and walk back from the fault of a crash through the Python API. The modules it does not describe are internal and have no stable API.

Supported chips

Chip Packet format
ESP32-C5 Efficient Trace 2.0
ESP32-C6 Processor Trace 1.0
ESP32-C61 Efficient Trace 2.0
ESP32-H2 Processor Trace 1.0
ESP32-H21 Processor Trace 1.0
ESP32-H4 Efficient Trace 2.0
ESP32-P4 Efficient Trace 2.0
ESP32-S31 Efficient Trace 2.0

Installation

Requires Python 3.11 or newer.

pip install esp-riscv-trace

Development install:

pip install -e '.[dev,test]'
pre-commit install -t pre-commit -t commit-msg

Capturing a trace

Enable CONFIG_ESP_RISCV_TRACE_ENABLE in the ESP-IDF application. The decoder reads loop-mode captures.

From OpenOCD (needs CONFIG_ESP_RISCV_TRACE_OPENOCD), in the telnet or GDB console:

esp riscv_trace start loop trace.esptrace        # start tracing every traced core
esp riscv_trace stop                             # stop and write trace.esptrace
esp riscv_trace start loop trace.esptrace 500    # stop by itself after 500 ms

After a panic, the firmware stops the trace before the debugger halts, and esp riscv_trace stop writes it. esp riscv_trace dump <file> writes buffers that are already stopped.

From a core dump: with core dump enabled, the trace starts at boot by default and the core dump stores the buffers. Pass the core dump ELF (for example from esp-coredump info_corefile -s coredump.elf ...) to this tool.

One capture holds only the last few milliseconds before it stopped. Profiling a running application sums many captures.

Quick start

esp-riscv-trace decode trace.esptrace --elf build/app.elf             # text dump of the executed instructions
esp-riscv-trace decode coredump.elf --elf build/app.elf --core 1      # trace from a core dump, one core
esp-riscv-trace stats trace.esptrace --elf build/app.elf --top 20     # hottest source lines
esp-riscv-trace stats trace.esptrace --elf build/app.elf --merge-cores --per-block
esp-riscv-trace history coredump.elf --elf build/app.elf              # calls and returns that led to the crash
esp-riscv-trace decode coredump.elf --elf build/app.elf --last 50     # last 50 instructions before the crash
esp-riscv-trace profile trace.esptrace --elf build/app.elf > app.folded  # call stacks for a flame graph

Without --elf, decode still runs but prints functions as ?(). ROM addresses resolve through --rom-elf or the ESP-IDF environment.

-h after a command lists its options. docs/commands.md describes the options and the output of every command, and docs/api.md the Python API.

A core dump profile in the Left Heavy view of speedscope:

speedscope Left Heavy view of a profile

Contributing

This project uses pre-commit to enforce code formatting and commit style. Set up the hooks with the development install above.

Run the tests from the repository root with pytest. tests/README.md explains the test captures and how to regenerate them.

License

Apache 2.0. See LICENSE.

Metadata

Release files for esp-riscv-trace 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for esp-riscv-trace 0.3.0
File Size Uploaded Provenance Actions
esp_riscv_trace-0.3.0.tar.gz 161.4 kB With provenance Details for esp_riscv_trace-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for esp-riscv-trace 0.3.0
File Interpreter ABI Platform Actions
esp_riscv_trace-0.3.0-py3-none-any.whl Python 3 none any Details for esp_riscv_trace-0.3.0-py3-none-any.whl

Total release size: 286.0 kB

Release files / esp_riscv_trace-0.3.0.tar.gz

Download URL esp_riscv_trace-0.3.0.tar.gz
Size 161.4 kB
Tags Source
SHA-256 checksum
How to use checksums
89d7624533554bc0a71f9bf71405ebee05271190204bf2f68f8b32fa40132c00
BLAKE2b-256 checksum
How to use checksums
3537b2e458fd79defb90a9c648a8ed4f3825551e994b880777d176d2add98cff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / esp_riscv_trace-0.3.0-py3-none-any.whl

Download URL esp_riscv_trace-0.3.0-py3-none-any.whl
Size 124.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b3a3f72aa66013db4d2bf5f8ad96a655ffc0f0cec868347a596245898ac0d60
BLAKE2b-256 checksum
How to use checksums
47be2929b530778c22f9754107032d219c6371553b7b114dc579caa571e462fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for esp-riscv-trace 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for esp_riscv_trace-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page