{"id":13423262,"url":"https://github.com/stm32-rs/stm32-rs","last_synced_at":"2025-05-12T13:33:22.518Z","repository":{"id":39613388,"uuid":"92896971","full_name":"stm32-rs/stm32-rs","owner":"stm32-rs","description":"Embedded Rust device crates for STM32 microcontrollers","archived":false,"fork":false,"pushed_at":"2025-05-11T04:38:47.000Z","size":66617,"stargazers_count":1455,"open_issues_count":71,"forks_count":242,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-05-11T05:18:48.443Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://stm32-rs.github.io/stm32-rs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stm32-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-31T02:43:32.000Z","updated_at":"2025-05-10T19:12:51.000Z","dependencies_parsed_at":"2023-02-13T23:00:27.310Z","dependency_job_id":"71656c74-fcb8-4760-8941-6683e40e6dcc","html_url":"https://github.com/stm32-rs/stm32-rs","commit_stats":{"total_commits":1911,"total_committers":174,"mean_commits":"10.982758620689655","dds":0.8419675562532706,"last_synced_commit":"a8687bb1486871b1ac551498d7f680074e4e4c22"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stm32-rs","download_url":"https://codeload.github.com/stm32-rs/stm32-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253519936,"owners_count":21921261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T00:00:26.729Z","updated_at":"2025-05-12T13:33:22.468Z","avatar_url":"https://github.com/stm32-rs.png","language":"Python","funding_links":[],"categories":["Peripheral Access Crates","Python"],"sub_categories":["STMicroelectronics"],"readme":"# STM32 Peripheral Access Crates\n\n[![CI](https://github.com/stm32-rs/stm32-rs/workflows/CI/badge.svg?branch=master)](https://github.com/stm32-rs/stm32-rs)\n[![crates.io](https://img.shields.io/crates/v/stm32c0.svg?label=stm32c0)](https://crates.io/crates/stm32c0)\n[![crates.io](https://img.shields.io/crates/v/stm32f0.svg?label=stm32f0)](https://crates.io/crates/stm32f0)\n[![crates.io](https://img.shields.io/crates/v/stm32f1.svg?label=stm32f1)](https://crates.io/crates/stm32f1)\n[![crates.io](https://img.shields.io/crates/v/stm32f2.svg?label=stm32f2)](https://crates.io/crates/stm32f2)\n[![crates.io](https://img.shields.io/crates/v/stm32f3.svg?label=stm32f3)](https://crates.io/crates/stm32f3)\n[![crates.io](https://img.shields.io/crates/v/stm32f4.svg?label=stm32f4)](https://crates.io/crates/stm32f4)\n[![crates.io](https://img.shields.io/crates/v/stm32f7.svg?label=stm32f7)](https://crates.io/crates/stm32f7)\n[![crates.io](https://img.shields.io/crates/v/stm32g0.svg?label=stm32g0)](https://crates.io/crates/stm32g0)\n[![crates.io](https://img.shields.io/crates/v/stm32g4.svg?label=stm32g4)](https://crates.io/crates/stm32g4)\n[![crates.io](https://img.shields.io/crates/v/stm32h5.svg?label=stm32h5)](https://crates.io/crates/stm32h5)\n[![crates.io](https://img.shields.io/crates/v/stm32h7.svg?label=stm32h7)](https://crates.io/crates/stm32h7)\n[![crates.io](https://img.shields.io/crates/v/stm32l0.svg?label=stm32l0)](https://crates.io/crates/stm32l0)\n[![crates.io](https://img.shields.io/crates/v/stm32l1.svg?label=stm32l1)](https://crates.io/crates/stm32l1)\n[![crates.io](https://img.shields.io/crates/v/stm32l4.svg?label=stm32l4)](https://crates.io/crates/stm32l4)\n[![crates.io](https://img.shields.io/crates/v/stm32l5.svg?label=stm32l5)](https://crates.io/crates/stm32l5)\n[![crates.io](https://img.shields.io/crates/v/stm32mp1.svg?label=stm32mp1)](https://crates.io/crates/stm32mp1)\n[![crates.io](https://img.shields.io/crates/v/stm32wl.svg?label=stm32wl)](https://crates.io/crates/stm32wl)\n[![crates.io](https://img.shields.io/crates/v/stm32wb.svg?label=stm32wb)](https://crates.io/crates/stm32wb)\n[![Matrix](https://img.shields.io/matrix/stm32-rs:matrix.org)](https://matrix.to/#/#stm32-rs:matrix.org)\n\nThis repository provides Rust device support crates for all STM32\nmicrocontrollers, providing a safe API to that device's peripherals using\n[svd2rust] and a community-built collection of patches to the basic SVD files.\nThere is one crate per device family, and each supported device is a\nfeature-gated module in that crate. These crates are commonly known as\nperipheral access crates or \"PACs\".\n\n[svd2rust]: https://github.com/rust-embedded/svd2rust\n\nTo view the generated code that makes up each crate, visit the\n[stm32-rs-nightlies](https://github.com/stm32-rs/stm32-rs-nightlies)\nrepository, which is automatically rebuilt on every commit to stm32-rs master.\nThe stm32-rs repository contains the patches to the underlying SVD files and\nthe tooling to generate the crates.\n\nWhile these crates are widely used, not every register of every device will\nhave been tested on hardware, and so errors or omissions may remain. We can't\nmake any guarantee of correctness. Please report any bugs you find!\n\nYou can see current coverage status for each chip\n[here](https://stm32-rs.github.io/stm32-rs/). Coverage means that individual fields are\ndocumented with possible values, but even devices with low coverage should\nhave every register and field available in the API. That page also allows you\nto drill down into each field on each register on each peripheral.\n\n## Using Device Crates In Your Own Project\n\nIn your own project's `Cargo.toml`:\n```toml\n[dependencies.stm32f4]\nversion = \"0.15.1\"\nfeatures = [\"stm32f405\", \"rt\"]\n```\n\nThe `rt` feature is optional but helpful. See\n[svd2rust](https://docs.rs/svd2rust/latest/svd2rust/#the-rt-feature) for\ndetails.\n\nThen, in your code:\n\n```rust\nuse stm32f4::stm32f405;\n\nlet mut peripherals = stm32f405::Peripherals::take().unwrap();\n```\n\nRefer to `svd2rust` [documentation](https://docs.rs/svd2rust) for further usage.\n\nReplace `stm32f4` and `stm32f405` with your own device; see the individual\ncrate READMEs for the complete list of supported devices. All current STM32\ndevices should be supported to some level.\n\n## Using Latest \"Nightly\" Builds\n\nWhenever the master branch of this repository is updated, all device crates are\nbuilt and deployed to the\n[stm32-rs-nightlies](https://github.com/stm32-rs/stm32-rs-nightlies)\nrepository. You can use this in your `Cargo.toml`:\n\n```toml\n[dependencies.stm32f4]\ngit = \"https://github.com/stm32-rs/stm32-rs-nightlies\"\nfeatures = [\"stm32f405\", \"rt\"]\n```\n\nThe nightlies should always build and be as stable as the latest release, but\ncontain the latest patches and updates.\n\n## Generating Device Crates / Building Locally\n\n* Install `svd2rust`, `svdtools`, and `form`:\n    * On x86-64 Linux, run `make install` to download pre-built binaries at the\n      current version used by stm32-rs\n    * Otherwise, build using `cargo` (double check versions against `scripts/tool_install.sh`):\n        * `cargo install form --version 0.12.1`\n        * `cargo install svdtools --version 0.4.6`\n        * `cargo install svd2rust --version 0.36.1`\n* Install rustfmt: `rustup component add rustfmt`\n* Generate patched SVD files: `make patch` (you probably want `-j` for all `make` invocations)\n    * Alternatively you could install `cargo-make` runner and then use it instead of `make`. Works on MS Windows natively:\n        * `cargo install cargo-make`\n        * `cargo make patch`\n* Generate svd2rust device crates: `make svd2rust`\n* Optional: Format device crates: `make form`\n\nBasically, the full process is:\n\n```\n+--------------------------+  +------------------------+  +--------------------------+  +--------------------------+\n| ST-supplied SVD archives |  | SVD peripheral patches |  | Peripheral fields detail |  | Perip. fields collecting |\n|     in 'svd/vendor/'     |  |  in 'devices/patches/' |  |    in 'devices/fields'   |  |   in 'devices/collect'   |\n+--------------------------+  +------------------------+  +--------------------------+  +--------------------------+\n             |                            |                            |                             |\n             |                            |                        (optional)                    (optional)\n       `make extract`                     |                            |                             |\n             |                            +----------------------------+-----------------------------+\n             |                                                         |\n             v                                                         v\n+----------------------------+                            +--------------------------+\n|   ST-supplied SVD files    |                            |    SVD device changes    |\n|         in 'svd/'          |                            |      in 'devices/'       |\n+----------------------------+                            +--------------------------+\n              |                                                        |\n              +---------------------------+----------------------------+\n                                          |\n                                    `make patch`\n                                  (using svdtools)\n                                          |\n                                          v\n                              +------------------------+\n                              |   Patched SVD files    |\n                              |       in 'svd/'        |\n                              +------------------------+\n                                          |\n                                   `make svd2rust`\n                                          |\n                                          v\n                              +------------------------+\n                              | Generated STM32 crates |\n                              |      in 'stm32*/'      |\n                              +------------------------+\n                                          |\n                                 `make form` (optional)\n                                          |\n                                          v\n                              +------------------------+\n                              | Formatted STM32 crates |\n                              |      in 'stm32*/'      |\n                              +------------------------+\n```\n\n## Motivation and Objectives\n\nThis project serves two purposes:\n\n* Create a source of high-quality STM32 SVD files, with manufacturer errors\n  and inconsistencies fixed. These files could be used with svd2rust or other\n  tools, or in other projects. They should hopefully be useful in their own\n  right.\n* Create and publish svd2rust-generated crates covering all STM32s, using\n  the SVD files.\n\nWhen this project began, many individual crates existed for specific STM32\ndevices, typically maintained separately with hand-edited updates to the SVD\nfiles. This project hopes to reduce that duplication of effort and centralise\nthe community's STM32 device support in one place.\n\n## Helping\n\nThis project is still young and there's a lot to do!\n\n* More peripheral patches need to be written, most of all. See what we've got\n  in `devices/` and grab a reference manual!\n  * Each `stm32*.yaml` file is a patch for a specific device SVD.\n  * To avoid repetition, common patches are written per peripheral in\n    `devices/patches`. Search there if a patch you want to add doesn't already\n    exist!\n  * Register fields description in `devices/fields` are not a part of the\n    CMSIS-SVD specification but enable type-safe friendly-name interface\n    (enumerated values) for highly detailed crates.\n  * `devices/collect` is here for collecting in `array`s, `cluster`s and `derive`s\n    to minimize duplication.\n* Also everything needs testing, and you can't so easily automate finding bugs\n  in the SVD files...\n\n### Adding New Devices\n\n* Update SVD zips in `svd/vendor` to include new SVDs.\n* Run `make extract` to extract the new zip files.\n* Add new YAML file in `devices/` with the new SVD path and include any\n  required SVD patches for this device, such as renaming or merging fields.\n* Add the new devices to `stm32_part_table.yaml`.\n* Add the new devices to `scripts/makecrates.py`.\n* You can run `scripts/matchperipherals.py` script to find out what existing\n  peripherals could be cleanly applied to this new SVD. If they look sensible,\n  you can include them in your device YAML.  This requires a Python environment with the `pyyaml`\n  and `svdtools` dependencies.\n  Example command: `python scripts/matchperipherals.py devices/fields/rcc devices/stm32h562.yaml`\n* Re-run `scripts/makecrates.py devices/` to update the crates with the new devices.\n* Run `make` to rebuild, which will make a patched SVD and then run `svd2rust`\n  on it to generate the final library.\n\nIf adding a new STM32 family (not just a new device to an existing family), complete\nthese steps as well:\n\n* Add the new devices to the `CRATES` field in `Makefile`.\n* Update this Readme to include the new devices.\n* Add the devices to `workflows/ci.yaml` and `workflows/nightlies.yaml`.\n\n### Updating Existing Devices/Peripherals\n\n* Using Linux, run `make extract` at least once to pull the SVDs out.\n* Edit the device or peripheral YAML (see below for format).\n* Using Linux, run `make` to rebuild all the crates using `svd patch` and `svd2rust`.\n* Test your new stuff compiles: `cd stm32f4; cargo build --features stm32f405`\n\nIf you've added a new peripheral, consider using the `matchperipherals.py`\nscript to see which devices it would cleanly apply to.\n\nTo generate a new peripheral file from scratch, consider using\n`periphtemplate.py`, which creates an empty peripheral file based on a single\nSVD file, with registers and fields ready to be populated. For single bit wide\nfields with names ending in 'E' or 'D' it additionally generates sample\n\"Enabled\"/\"Disabled\" entries to save time.\n\n### Device and Peripheral YAML Format\n\nPlease see the [svdtools](https://github.com/stm32-rs/svdtools) documentation\nfor full details of the patch file format.\n\n### Style Guide\n\n* Enumerated values should be named in the past tense (\"enabled\", \"masked\",\n  etc).\n* Descriptions should start with capital letters but do not end with a period\n\n## Releasing\n\nNotes for maintainers:\n\n1. Create PR preparing for new release:\n    * Update `CHANGELOG.md` with changes since last release and new contributors\n    * Update `README.md` to bump version number in example snippet\n    * Update `scripts/makecrates.py` to update version number for generated PACs\n2. Merge PR once CI passes, pull master locally.\n3. `make clean`\n4. `make -j16 form`\n5. `for f in stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32g0 stm32g4 stm32mp1 stm32u0 stm32u5 stm32wl stm32wb; cd $f; pwd; cargo publish --allow-dirty --no-default-features; cd ..; end`\n6. `git tag -a vX.X.X -m vX.X.X`\n7. `git push vX.X.X`\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstm32-rs%2Fstm32-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstm32-rs%2Fstm32-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstm32-rs%2Fstm32-rs/lists"}