Skip to main content

svdgen

OSS hardware description generation engine — parse CMSIS-SVD, apply declarative patches, and render arbitrary text artifacts through Jinja templates.

SVD file → Parse → Normalize → Patch → Render → Write

Typical outputs: C register headers, Markdown documentation, Rust PAC fragments — anything expressible as text.

Installation

pip install svdgen

For development:

pip install -e ".[dev]"

Quick Start

1. Create svdgen.toml in your project:

[project]
name = "my-bsp"

[input]
svd = "STM32F407.svd"

[output]
dir = "generated"

[[targets]]
name        = "c_headers"
template    = "c_header/peripheral.h.j2"
output_path = "include/{{ peripheral.name | lower }}.h"
scope       = "peripheral"

2. Generate:

svdgen generate

This parses the SVD, normalizes the model, renders one C header per peripheral, and writes them to generated/include/.

CLI

Command Description
svdgen generate Run the full pipeline and write output files
svdgen validate Validate config, inputs, and patches without writing files
svdgen inspect [PERIPH[.REG[.FIELD]]] Inspect the normalized device model
svdgen list peripherals|registers|fields|targets List model elements or configured targets
svdgen export-model Export the full normalized model as JSON

All commands accept --config / -c (default svdgen.toml), --dry-run, --verbose / -v, and --quiet / -q.

Patch Files

Patches are YAML files that modify the normalized model without editing the original SVD:

- target: "GPIOA.MODER"
  set:
    description: "GPIO port mode register (corrected)"
    reset_value: 0xFFFFFFFF

- target: "GPIOA.MODER.MODE0"
  rename: "MODER0"

- target: "GPIOB"
  disable: true

Selectors are dot-separated paths: PERIPH, PERIPH.REG, or PERIPH.REG.FIELD.

Python API

import svdgen

config = svdgen.load_config("svdgen.toml")
result = svdgen.run(config)

# or step by step:
parse_result = svdgen.parse_svd("device.svd")
device       = svdgen.normalize(parse_result)
patch_set    = svdgen.load_patches("patches/fixups.yaml")
patched      = svdgen.apply_patches(device, patch_set).device

Documentation

Examples

License

Apache-2.0 — see LICENSE.

Metadata

Release files for svdgen 0.1.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 svdgen 0.1.0
File Size Uploaded
svdgen-0.1.0.tar.gz 53.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for svdgen 0.1.0
File Interpreter ABI Platform
svdgen-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 86.2 kB

Release files / svdgen-0.1.0.tar.gz

Download URL svdgen-0.1.0.tar.gz
Size 53.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f7a07122e6bcc5d4f89b8e2830fd3be33a9a45103d160d8d0fc8dbf8e13e713e
BLAKE2b-256 checksum
How to use checksums
2ea9e911bd990c4d57e1e8d93cc27bc0fbbd68ba3832307423b45fcd82da845a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Apr 12, 2026.

Transparency log

Release files / svdgen-0.1.0-py3-none-any.whl

Download URL svdgen-0.1.0-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65ab5b2fb3a1cc930ca4fb8936b24f24a4ea4abfe806cedae18fa0e0129c205a
BLAKE2b-256 checksum
How to use checksums
a2df0e98a9d2ecef84bdc21794d9b68c40fe18ab429ea176d2eab9eca32ca197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Apr 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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