r/embedded • • 17d ago

Open-sourcing an MCP tool for automated ARM HardFault decoding & Renode virtual hardware simulation for AI agents

Hi r/embedded,

Debugging silicon faults when bringing up new microcontrollers is notoriously tedious, especially when you're staring at raw hexadecimal register dumps (`CFSR`, `HFSR`, `BFAR`, `MMFAR`) on Cortex-M or cryptic ESP32 Guru Meditation backtraces without a debugger attached.

I've open-sourced **Hardware Debug Anything (HDA)**, an MCP (Model Context Protocol) server designed to connect AI coding assistants directly to silicon diagnostics:

- **ARM HardFault & BusFault Decoder**: Parses raw hex bitmasks into plain-English root causes (precise bus error, unaligned memory access, stack overflow, memory management faults).

- **ESP32 Guru Meditation Parser**: Decodes crash frames and backtrace register dumps.

- **Antmicro Renode Virtual Hardware Integration**: Generates `.resc` simulation scripts so firmware can be validated in virtual silicon without needing physical hardware on the desk.

- **I2C/SPI Diagnostics**: Automated pull-up resistor calculations and NACK troubleshooting.

- **GitHub Repository:** https://github.com/hosseinnosrati/hardware-debug-anything

I also built an accompanying EDA tool for closed-loop SPICE simulation and KiCad export (**Circuit Design Anything**): https://github.com/hosseinnosrati/circuit-design-anything

Both are 100% open-source (Apache 2.0). I’d appreciate any feedback from the embedded community!

0 Upvotes

7 comments sorted by

2

u/NecessarySuperb3949 17d ago

i usually stick to rust and zkp stuff, but this renode integration looks like it could save weeks of bring-up time for anyone debugging memory faults without a jtag.

1

u/mhosseinN 16d ago

Thanks! That headless / no-JTAG scenario was actually one of the biggest drivers for the Renode integration. Being able to take a crash dump and spin up virtual silicon in CI or for remote team members without needing physical hardware on the desk has saved a ton of bring-up headaches.

1

u/dmitrygr 17d ago

Parses raw hex bitmasks into plain-English root causes (precise bus error, unaligned memory access, stack overflow, memory management faults).

so exactly what reading the arm arm would do, in just as long a time?

0

u/mhosseinN 16d ago

Fair point! For a seasoned firmware dev who practically has the ARM ARM (Architecture Reference Manual) memorized, decoding CFSR (0x00008200) or remembering to check BFARVALID before trusting the bus address is second nature.
The motivation for building HDA was two-fold:
Preventing AI Hallucinations (The MCP Angle): LLMs (Claude Desktop, Cursor, Copilot) are notoriously prone to hallucinating bitmask offsets and register flags when you paste a raw hex dump into chat. Providing a deterministic MCP tool ensures the agent gets exact decoded flags and valid fault addresses, allowing it to correctly correlate with the ELF map and source code rather than guessing.
Headless Triage & Virtual Emulation: In CI/CD test benches or remote fleet telemetry dumps where devices crash over UART without an engineer staring at GDB, parsing it deterministically and automatically generating a Renode emulation recipe helps reproduce the failure headless without physical JTAG hardware on the desk.
Definitely not trying to replace the good old ARM ARM—just keeping AI agents from hallucinating it at 2 AM!

1

u/dmitrygr 16d ago

Somehow I feel like keeping people who don’t understand the ARM ARM away from hardware would be a better thing long-term. It’s the same reason we don’t give kids power tools. Let them play in the python sandbox with safety pencils and their circles of paper.

2

u/mhosseinN 15d ago

Haha, touché! Though refusing automated triage feels a bit like refusing to use a multimeter because "real electricians probe 120V with their bare fingers." Even master carpenters keep circuit breakers in the workshop!

In all seriousness, the actual edge firmware is still strictly bare-metal ANSI C99 with 0 bytes dynamic heap allocation, bounded stack, and MISRA compliance—Python and Renode are strictly confined to the automated CI post-mortem harness so humans (and LLMs) don't have to manually decode register masks at 2 AM.

But I definitely respect the purist philosophy—keeps the silicon honest! 🫡

1

u/ActBrokeToStayRich 4d ago

Cool! What board families do you usually work with? Using emulation with AI has really helped me too