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 through the Python API. The other modules 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.2.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.2.0
File Size Uploaded Provenance Actions
esp_riscv_trace-0.2.0.tar.gz 120.9 kB With provenance Details for esp_riscv_trace-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 222.1 kB

Release files / esp_riscv_trace-0.2.0.tar.gz

Download URL esp_riscv_trace-0.2.0.tar.gz
Size 120.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6ff4de8c54c86e054e3b78697552107819e17ece2ad33ae68f384c98e19dce94
BLAKE2b-256 checksum
How to use checksums
8314875c4ec98ebe493c03e373a00a86c291fe2a0c9bab71782dfb650128d1ac
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 11, 2026.

Transparency log

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

Download URL esp_riscv_trace-0.2.0-py3-none-any.whl
Size 101.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
79fcd8acc82e1bb949c36c507b1065847f72326fbe1e266f6884099f343f2833
BLAKE2b-256 checksum
How to use checksums
a9a952b2e5ac85604e29abb40ca9cc3a6b7e04608d22fe52e868851ac5eddb50
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 11, 2026.

Transparency log

Security for esp-riscv-trace 0.2.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.2.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 11, 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.2.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