# cortex-unwind
Zero-dependency CLI tool to decode ARM Cortex-M hardware stack frames and map
crash sites to source lines via arm-none-eabi-addr2line.
When a Cortex-M core takes a HardFault, hardware stacks 8 registers
(r0..r3, r12, lr, pc, xPSR) onto the active stack. Paste those 8 words from a
UART fault log or GDB (x/8wx $sp) and this tool gives you the crash site.
Free & Open Source (MIT) by [Trust & Thread](https://www.trustandthread.com).
## Installation
pip install cortex-unwind
Or run with zero install:
curl -sL https://raw.githubusercontent.com/GaneshMba4066/cortex-unwind/main/cortex\_unwind.py | python3
## Quick Start
Pass the 8 hardware-stacked registers (R0 R1 R2 R3 R12 LR PC xPSR):
cortex-unwind 0x0 0x1 0x20000000 0x40021000 0x0 0x08001255 0x08001290 0x21000000
With an ELF file for instant symbol resolution of PC and LR:
cortex-unwind 0x0 0x1 0x20000000 0x40021000 0x0 0x08001255 0x08001290 0x21000000 build/firmware.elf
Got a raw hex dump from UART? Let --auto find the frame for you:
cortex-unwind --auto "0x00 0x01 0x20000000 0x40021000 0x00 0x08001255 0x08001290 0x21000000"
## What you get
- Stacked register breakdown with Thumb-bit notes on PC/LR
- Execution state: IPSR → active exception (HardFault, NMI, IRQn...), APSR flags
- Thumb-bit validation (clear T-bit = corrupt PC, flagged immediately)
- EXC\_RETURN decoding of LR — MSP/PSP selection and basic (8-word) vs FP-extended (26-word) frame detection, per ARMv7-M/ARMv8-M bit 4 encoding
- PC and LR mapped to function @ file:line when an ELF and arm-none-eabi-addr2line are available
- EXC_RETURN LRs are never symbolized (they aren't addresses — no misleading output)
## Requirements
- Python 3.6+, zero pip dependencies
- Optional: arm-none-eabi-addr2line (GNU Arm Embedded toolchain) + an unstripped .elf for source mapping
## Companion tools
- [cfsr-decode](https://github.com/GaneshMba4066/cfsr-decode) — decode the CFSR/HFSR fault *cause*
- cortex-unwind (this tool) — decode the crash *location*
- [Production Toolkit ($49)](https://www.trustandthread.com/toolkit/) — drop-in C HardFault handlers + runtime crash logging
- [Firmware Crash Checklist (free)](https://www.trustandthread.com/firmware-checklist/)
## License
MIT — Trust & Thread
Metadata
Release files for cortex-unwind 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cortex_unwind-1.1.0.tar.gz | 6.3 kB | Without provenance | Details for cortex_unwind-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cortex_unwind-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for cortex_unwind-1.1.0-py3-none-any.whl |
Total release size: 13.3 kB
Release files / cortex_unwind-1.1.0.tar.gz
| Download URL | cortex_unwind-1.1.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd117578081fe3c227b5f2472a8eec60d1d3f4bbd7c0eadf468f6755b009c28b
|
|
BLAKE2b-256 checksum How to use checksums |
17d6aa7719691f84dac8d6a6e2b0578187111977ea4799b26c8ff5c55948ec6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / cortex_unwind-1.1.0-py3-none-any.whl
| Download URL | cortex_unwind-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4358472ccaf3c380999a52ce58fd5d40d4da2a42a685afe461e091892b4ee75
|
|
BLAKE2b-256 checksum How to use checksums |
cad0a3947d91054ad6218b59f32dc18896587852e3111152cefff0810270ca56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Security for cortex-unwind 1.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.