// the find
rust-embedded/svd2rust
Generate Rust register maps (`struct`s) from SVD files
svd2rust takes CMSIS-SVD files — the XML register descriptions that chip vendors ship for Cortex-M and RISC-V parts — and generates Rust PAC (peripheral access crate) code from them. If you're writing bare-metal Rust for microcontrollers, this is the tool that produces the strongly-typed register structs the whole embedded Rust ecosystem builds on.
The generated code is type-safe at the bit-field level: you get distinct types for each register and field, so writing to a read-only bit is a compile error, not a runtime bug. It's the official tool of the rust-embedded working group, meaning major PACs (stm32-rs, nrf-hal, etc.) are all generated by this and tested continuously against real SVDs. The regression harness (svd2rust-regress) downloads actual vendor SVDs and compiles the output — you catch regressions against the real world, not just unit tests. RISC-V support landed alongside the original Cortex-M target, so it's not an ARM-only tool.
SVD files from vendors are frequently wrong — wrong bit widths, missing peripherals, incorrect access permissions — and svd2rust faithfully translates the garbage, so a broken SVD produces a broken PAC; there's no validation layer that catches obviously bogus register definitions before codegen. The generated output is verbose machine code: thousands of lines of structs and impls that are essentially unreadable, which makes debugging PAC issues painful. The tool has no awareness of chip errata, so silicon bugs that require specific register access sequences have to be patched manually in the downstream HAL layer. Documentation in the README is thin — the real docs live on docs.rs, which means new adopters who hit issues have to read generated API docs to understand the generator's own behavior.