From Theory to Real Hardware: Why Embedded Firmware Needs Dedicated Agent Skills #
In my previous engineering note, Designing Modular Agent Skills, I broke down why monolithic system prompts fail in production and how progressive disclosure (SKILL.md + deterministic scripts) solves context rot.
Nowhere is that failure mode more expensive than in Embedded Systems Engineering. When a general-purpose LLM writes web UI code, a hallucinated prop triggers a TypeScript error. When an LLM hallucinates in firmware or hardware bring-up, it can:
- Recommend wiring a 5 V UART/SPI line directly into a 3.3 V ESP32 or RP2040 pin, damaging the silicon.
- Assign an analog sensor to ESP32 ADC2 while Wi-Fi is active, or put an external pull-up on strapping pin
GPIO12(breaking flash boot voltage). - Place STM32H7 DMA buffers in DTCMRAM (inaccessible to
DMA1/DMA2) or forget D-Cache maintenance. - Call blocking
HAL_Delay()orprintf()inside an Interrupt Service Routine (ISR), or hang an agent session forever inside an interactive serial monitor (idf.py monitor/pio device monitor).
To solve this systematically, I built and open-sourced embedded-systems-kit—a modular, multi-platform C/C++ toolkit published on skills.sh and compatible with Antigravity, Claude Code, Cursor, Codex, and any Agent Skills-compliant client.
Architecture: 5 Focused Skills + Safety Rules + Code Auditor #
Rather than dumping an encyclopedia of MCU datasheets into one bloated prompt, embedded-systems-kit splits the embedded development lifecycle into 5 focused skills, backed by always-on hardware safety rules (rules/AGENTS.md) and a read-only audit subagent (agents/firmware-reviewer.md):
embedded-systems-kit/
├── plugin.json # Antigravity plugin manifest
├── rules/AGENTS.md # Always-on electrical, ISR & memory safety guardrails
├── agents/firmware-reviewer.md # Read-only firmware auditor (ISR, race, stack, timeouts)
├── skills/
│ ├── embedded-firmware-drivers/ # HAL-agnostic drivers, I2C/SPI/UART/DMA/ISR + C templates
│ ├── embedded-build-flash-ci/ # Auto-detect build, Flash/RAM size, bounded serial, linting
│ ├── embedded-debug-optimization/ # Cortex-M HardFault, ESP32 panic decode, GDB/OpenOCD
│ ├── embedded-rtos-lowpower/ # FreeRTOS static allocation, table-driven FSM, power budget
│ └── embedded-hardware-bringup/ # Staged bring-up, per-MCU guides, CMSIS-SVD & pin checks
└── tests/validate_plugin.py # Automated CI validator + unit tests + C11 syntax checkProgressive Disclosure for Per-MCU Hardware Knowledge #
One key architectural decision was what NOT to put inside SKILL.md. There are over a thousand STM32 part numbers alone; hardcoding full pinout tables bloats tokens and invites variant mismatches. Instead, the kit uses a three-layer knowledge model:
- Always-On Guardrails (
rules/AGENTS.md): Short, non-negotiable engineering rules—verify logic voltage levels, never guess register addresses, never block in ISRs, enforce explicit bus timeouts, and verify Flash/RAM footprint after edits. - On-Demand Family Guides (
references/mcu/): Concise, high-signal gotcha sheets loaded only when working on that specific family (esp32-family.md,stm32-family.md,rp2040-rp2350.md,arduino-avr.md). - Zero-Hallucination Ground Truth (
query_svd.py): Instead of guessing register offsets or bitmasks, the agent queries vendor CMSIS-SVD (.svd) XML files and STM32CubeMX (.ioc) project files directly.
8 Deterministic Python Helper Scripts #
Every fragile mechanical task is offloaded from LLM guesswork to cross-platform, standard-library-first Python scripts:
| Script | Responsibility |
|---|---|
detect_project.py |
Detects PlatformIO, ESP-IDF, CMake/STM32, Pico SDK, or Arduino projects and installed toolchains |
analyze_size.py |
Parses .elf / .map footprints to break down Flash (.text + .data) and RAM (.data + .bss) bloat |
serial_capture.py |
Non-interactive UART log capture with hard timeouts, stop regex, and automatic panic/HardFault detection |
run_static_analysis.py |
Wraps cppcheck and clang-tidy with embedded C/C++ presets |
decode_crash.py |
Extracts ESP32 backtraces and ARM Cortex-M CFSR/PC/LR dumps and resolves lines via addr2line |
power_budget_calc.py |
Computes average current draw and battery life from multi-state active/sleep duty cycles |
check_pin_conflicts.py |
Validates JSON pin maps for duplicates, strapping/flash/PSRAM pins, ADC2+Wi-Fi, Pico W CYW43, and 3.3 V/5 V hazards |
query_svd.py |
Queries exact register addresses/bitmasks from CMSIS-SVD .svd XML and exports .ioc pinouts to JSON |
Automated Verification & CI Pipeline #
Every commit is validated by GitHub Actions (.github/workflows/validate.yml) running python tests/validate_plugin.py:
- Verifies
plugin.jsonschema compliance and all 5SKILL.mdfrontmatters. - Verifies 33 internal relative links so no reference or script path silently breaks.
- Runs unit tests across all 8 Python scripts (including
derivedFromSVD parsing and.ioc->check_pin_conflicts.pyround-trip tests). - Syntax-checks the reusable C11 templates (
driver_template.c,ring_buffer.h,fsm_template.h) withgcc -std=c11 -Wall -Wextra -Werror -fsyntax-only.
Install & Try It Yourself #
Install directly into Antigravity, Claude Code, Cursor, Codex, or any compatible AI coding agent via the open Agent Skills CLI:
npx skills add r-iki/embedded-systems-kit- GitHub Repository: github.com/r-iki/embedded-systems-kit
- skills.sh Directory: skills.sh/r-iki/embedded-systems-kit
- Portfolio Showcase: Embedded Systems Kit Project Page
Need Custom AI Agent Skills or Embedded Firmware Engineering? #
If your team is building embedded firmware (ESP32, STM32, RP2040, IoT instrumentation) or wants to package internal engineering SOPs into production Agent Skills, explore my Engineering Services or get in touch directly.