HAIR is a vendor-neutral intermediate representation for describing MCU and SoC hardware with enough structure, provenance, and reviewability to support deterministic downstream generation.
This repository is currently focused on three things:
- defining the layered HAIR schema and optional MCU/Embassy profile layers
- supporting evidence-first extraction and audit workflows
- implementing a small Rust CLI for validation, structural diffing, SVD generation, and Embassy-oriented code generation
The current repository baseline is intentionally conservative.
- One device per top-level HAIR document. Shared hardware can be imported from separate HAIR sub-documents, but each top-level document still describes one concrete device variant.
- Evidence-first modeling. Approved source material is captured in an explicit evidence manifest, and extracted facts stay tied to provenance inside the HAIR document.
- Deterministic lowering. Generators may only emit behavior justified by the approved HAIR inputs, and they should fail explicitly when required data is missing or out of scope.
- Workflow-gated extraction. Source discovery, extraction, and audit are repository workflows, not implicit side effects of generation.
Today this repository contains:
- a layered JSON Schema set under
schema/ - optional
profiles.mcuSocandprofiles.embassyHalspecialization layers - a seeded canonical-normalization vocabulary under
docs/canonical-terms.md - a Rust crate (
edition = "2024") that implements the current CLI - governed repository requirements, design, and validation baselines under
specs/ - workflow skills under
.github/skills/for source discovery, extraction, audit, and repository maintenance - reference evidence bundles under
evidence/for five concrete devices across four vendors - checked-in generated SVD, PAC, Embassy, and smoke-test artifacts for the bundles that currently anchor regression coverage
- GitHub Actions workflows that regenerate artifacts, check generated HALs for
rustfmt/clippycleanliness, and run QEMU smoke where supported
| Path | Purpose |
|---|---|
schema/ |
Core HAIR schema layers, profile schemas, and the evidence-manifest schema |
docs/ |
Human-oriented schema, CLI, profile, and canonical-terminology guides |
specs/ |
Governing repository requirements, design, and validation baselines |
src/main.rs |
Current Rust CLI implementation |
evidence/ |
Reference device bundles, manifests, reports, and generated artifacts |
.github/skills/ |
Repository workflows for discovery, extraction, audit, bootstrap, evolve, and maintain |
The top-level schema is schema/hair.json. A HAIR document can include:
metadataimportsprovenancestructuresemanticsphysicalnormalizationvalidationprofiles
The repository also defines schema/evidence-manifest.json, which is the input format for evidence-first extraction workflows.
| File | Role |
|---|---|
schema/hair.json |
Top-level HAIR document schema |
schema/common.json |
Shared primitive types and reusable helpers |
schema/provenance.json |
Sources, evidence, reviews, and provenance records |
schema/structure.json |
Devices, peripherals, interrupts, registers, fields, and memory regions |
schema/semantics.json |
Behaviors, operations, state machines, and semantic relationships |
schema/physical.json |
Clocks, timing, pins, packages, power/reset domains, and electrical constraints |
schema/normalization.json |
Canonical mappings, naming rules, and vendor quirks |
schema/validation.json |
Declarative validation rules and validation profiles |
schema/profiles/mcu.json |
Canonical MCU/SoC topology and block classification layer |
schema/profiles/embassy-hal.json |
Embassy-generation lowering contract |
schema/evidence-manifest.json |
Approved-source manifest for extraction workflows |
The current Rust CLI implements these commands:
hair validate <input>
hair generate svd <input> [--output <path>]
hair generate embassy <input> --output-dir <path>
hair generate embassy-host <input> --output-dir <path>
hair diff <left> <right>
| Command | Current behavior |
|---|---|
validate |
Checks one HAIR JSON document against the repository schema set rooted at schema/hair.json |
generate svd |
Lowers a validated HAIR document to CMSIS-SVD-style output |
generate embassy |
Lowers a validated HAIR document to an embedded-target Embassy-style HAL crate |
generate embassy-host |
Lowers the same Embassy contract to a separate host-only std companion crate |
diff |
Compares two HAIR document revisions structurally, including git-backed inputs |
Validate a reference HAIR document:
cargo run -- validate evidence\st\stm32f405rgt6\hair.jsonGenerate SVD output:
cargo run -- generate svd evidence\wch\ch32v203c8t6\hair.json --output ch32v203c8t6.svdGenerate an embedded-target Embassy crate:
cargo run -- generate embassy evidence\texas-instruments\lm3s6965\hair.json --output-dir out\embassyGenerate a host-emulated Embassy companion crate:
cargo run -- generate embassy-host evidence\texas-instruments\lm3s6965\hair.json --output-dir out\embassy-hostCompare a working-tree HAIR document against its committed version:
cargo run -- diff git:HEAD:evidence/st/stm32f405rgt6/hair.json evidence\st\stm32f405rgt6\hair.jsonRun the Rust regression suite:
cargo testextract and normalize are not current CLI commands. The repository treats source discovery, extraction, and audit as explicit workflows.
The main workflow skills are:
find-mcu-sourcesextractauditbootstrapevolvemaintain
Use the workflow docs and generated reports under evidence/ when you need an evidence-backed extraction or audit trail rather than just schema validation or generation.
The repository currently carries five top-level HAIR bundles across four vendors. They exercise different parts of the schema, lowering surface, and evidence/audit workflow.
| Vendor | Device | Bundle contents today | Validation path in repo |
|---|---|---|---|
| ST | stm32f405rgt6 |
hair.json, evidence reports, generated SVD/PAC/Embassy crates, embassy-smoke |
CI regenerates checked-in artifacts and runs the QEMU smoke harness |
| WCH | ch32v203c8t6 |
hair.json, evidence reports, audit report |
Reference HAIR-only bundle today; no checked-in generated artifacts or smoke harnesses |
| WCH | ch32v203g6u6 |
hair.json, evidence reports, audit report, generated SVD/PAC/Embassy crates, embassy-smoke, embassy-pwm-smoke, embassy-rtc-smoke, embassy-adc-dma-smoke, embassy-watchdog-smoke, embassy-flash-smoke, embassy-neopixel-smoke, embassy-usb-cdc-smoke |
CI regenerates checked-in artifacts and builds every smoke harness; runtime smoke remains hardware-oriented and is intentionally not run in hosted CI |
| Espressif | esp32-c3fn4 |
hair.json, evidence reports, generated Embassy crate, embassy-smoke, embassy-usb-smoke |
CI builds and lints the checked-in HAL plus smoke harnesses; run-qemu-smoke.ps1 covers QEMU execution manually |
| Texas Instruments | lm3s6965 |
hair.json, evidence reports, generated SVD/PAC/Embassy crates, embassy-smoke |
CI regenerates checked-in artifacts and runs the QEMU smoke harness |
This table summarizes executable smoke coverage that exists today, not every driver kind modeled in each bundle.
| Device | Validation mode | Peripherals or surfaces exercised |
|---|---|---|
stm32f405rgt6 |
QEMU in CI | gpio API surface on GPIOA (without reliable state readback), usart, embassy-time |
ch32v203c8t6 |
None today | No checked-in runtime smoke coverage yet |
ch32v203g6u6 |
Hardware smoke packaging + device run | rcc, gpio, embassy-time, pwm, rtc, adc + dma, watchdog, flash, usb-device/USB CDC, NeoPixel-style GPIO data path |
esp32-c3fn4 |
QEMU smoke via run-qemu-smoke.ps1 |
uart, interrupt; boot path is also observed, but GPIO state is not asserted in QEMU |
lm3s6965 |
QEMU in CI | rcc, gpio, uart, spi, i2c, timer, watchdog, flash, interrupt, embassy-time |
The table below summarizes the checked-in device bundles that currently include a top-level hair.json, along with the peripheral driver kinds modeled in each bundle's current profiles.embassyHal surface and the QEMU smoke coverage currently wired in this repository.
| Vendor | Device | HAIR JSON | Supported peripherals | QEMU-tested today |
|---|---|---|---|---|
| ST | stm32f405rgt6 |
evidence/st/stm32f405rgt6/hair.json |
gpio-port, i2c, spi, uart, usart, interrupt |
CI runs the checked-in Embassy smoke with qemu-system-arm -M netduinoplus2 -nographic -semihosting -kernel "$SMOKE_BINARY"; the smoke source exercises GPIOA APIs, USART1, and Embassy time, but does not assert GPIO state transitions because QEMU readback is unreliable |
| WCH | ch32v203c8t6 |
evidence/wch/ch32v203c8t6/hair.json |
rcc, gpio-port, uart, usart, spi, i2c, timer, pwm, adc, dma, flash, interrupt |
No QEMU path; no checked-in runtime smoke harnesses for this bundle |
| WCH | ch32v203g6u6 |
evidence/wch/ch32v203g6u6/hair.json |
rcc, gpio-port, uart, spi, i2c, timer, pwm, adc, dma, flash, interrupt, rtc, usb, watchdog |
No QEMU path; checked-in CH32 hardware smoke harnesses cover Embassy blink, USB CDC, ADC DMA, watchdog, flash, NeoPixel GPIO, and GPIO EXTI wait packaging |
| Espressif | esp32-c3fn4 |
evidence/espressif/esp32-c3fn4/hair.json |
rcc, gpio-port, interrupt, uart, i2c, spi, adc |
Manual run-qemu-smoke.ps1 uses the pinned containerized esp32c3 QEMU path and checks boot/UART/interrupt smoke plus PASS; the current smoke firmware does not exercise GPIO |
| Texas Instruments | lm3s6965 |
evidence/texas-instruments/lm3s6965/hair.json |
rcc, gpio-port, uart, spi, i2c, timer, interrupt |
CI runs the checked-in Embassy smoke with qemu-system-arm -M lm3s6965evb -display none -monitor none -serial stdio -semihosting-config enable=on,target=native -kernel "$SMOKE_BINARY"; the harness prints to UART0 stdio and exercises RCC, GPIO, SSI, I2C, timers, watchdog, flash, NVIC/SysTick, and Embassy time |
These are important limits of the current baseline:
validateis currently schema-conformance-first; it does not execute declarativevalidation.rules- Embassy generation requires both
profiles.mcuSocandprofiles.embassyHal - generator behavior is intended to be explicit and evidence-bounded, not placeholder-driven
- broader long-term goals such as richer validation execution, more import semantics, and additional generators remain future work
Start with these documents:
docs/schema.md— layered schema overviewdocs/canonical-terms.md— repository-owned canonical normalization seed vocabularydocs/mcu-profile.md— MCU/SoC profile contractdocs/embassy-hal-profile.md— Embassy HAL generation contractdocs/cli.md— current CLI contractspecs/requirements.md— repository requirements baselinespecs/design.md— repository design baselinespecs/validation.md— validation baseline
Contributions should preserve the current repository guarantees:
- keep HAIR explicit and semantically precise
- preserve provenance and evidence boundaries
- prefer deterministic lowerings over ad hoc generation
- fail explicitly on unsupported or ambiguous inputs
- update the governing specs and docs when repository guarantees change
HAIR is released under the MIT License.