{"id":13423275,"url":"https://github.com/stm32-rs/stm32f1xx-hal","last_synced_at":"2025-05-14T02:03:16.793Z","repository":{"id":41462242,"uuid":"161557523","full_name":"stm32-rs/stm32f1xx-hal","owner":"stm32-rs","description":"A Rust embedded-hal HAL impl for the STM32F1 family based on japarics stm32f103xx-hal","archived":false,"fork":false,"pushed_at":"2025-05-06T13:26:07.000Z","size":1872,"stargazers_count":597,"open_issues_count":92,"forks_count":184,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-06T14:43:54.203Z","etag":null,"topics":["embedded","hacktoberfest","hal","microcontrollers","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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":null,"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":"2018-12-12T23:24:52.000Z","updated_at":"2025-05-06T13:26:12.000Z","dependencies_parsed_at":"2024-03-25T20:26:14.343Z","dependency_job_id":"f3973e0b-5cdf-46c0-b173-37457a54521c","html_url":"https://github.com/stm32-rs/stm32f1xx-hal","commit_stats":{"total_commits":331,"total_committers":83,"mean_commits":"3.9879518072289155","dds":0.7794561933534743,"last_synced_commit":"4e902d2cd68100d17b5e2116d99bfcc5326983fd"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32f1xx-hal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32f1xx-hal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32f1xx-hal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stm32-rs%2Fstm32f1xx-hal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stm32-rs","download_url":"https://codeload.github.com/stm32-rs/stm32f1xx-hal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052666,"owners_count":22006716,"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":["embedded","hacktoberfest","hal","microcontrollers","rust"],"created_at":"2024-07-31T00:00:27.503Z","updated_at":"2025-05-14T02:03:16.735Z","avatar_url":"https://github.com/stm32-rs.png","language":"Rust","funding_links":[],"categories":["HAL implementation crates","Rust"],"sub_categories":["STMicroelectronics"],"readme":"# `stm32f1xx-hal`\n\n\u003e [HAL] for the STM32F1 family of microcontrollers\n\n[HAL]: https://crates.io/crates/embedded-hal\n\n[![Crates.io](https://img.shields.io/crates/d/stm32f1xx-hal.svg)](https://crates.io/crates/stm32f1xx-hal)\n[![Crates.io](https://img.shields.io/crates/v/stm32f1xx-hal.svg)](https://crates.io/crates/stm32f1xx-hal)\n[![Released API docs](https://docs.rs/stm32f1xx-hal/badge.svg)](https://docs.rs/stm32f1xx-hal)\n[![dependency status](https://deps.rs/repo/github/stm32-rs/stm32f1xx-hal/status.svg)](https://deps.rs/repo/github/stm32-rs/stm32f1xx-hal)\n[![Continuous integration](https://github.com/stm32-rs/stm32f1xx-hal/workflows/Continuous%20integration/badge.svg)](https://github.com/stm32-rs/stm32f1xx-hal)\n\n## Quick start guide\n\nEmbedded Rust development requires a bit more setup than ordinary development.\nFor this guide, we'll assume you're using a stm32 blue pill board (shown\nbelow), but if you have another f1 microcontroller, you should be able to adapt\nit.\n\n![blue pill pinout](BluePillPinout.jpg \"opt title\")\n\nYou will also need a debug probe, for example an [stlink v3\nmini](https://www.st.com/en/development-tools/stlink-v3mini.html) for programming and debugging.\n(There are many different STLink probes out there, all of them _should_ work fine with the instructions given here, other JTAG or SWD debug probes will work as well but will need different software or configuration).\n\n### Installing software\n\nTo program your microcontroller, you need to install:\n- [openocd](http://openocd.org/)\n- `gdb-multiarch` (on some platforms you may need to use `gdb-arm-none-eabi` instead, make sure to update `.cargo/config` to reflect this change)\n\nFinally, you need to install arm target support for the Rust compiler. To do\nso, run\n```\nrustup target install thumbv7m-none-eabi\n```\n\n\n### Setting up your project\n\nCreate a new Rust project as you usually do with `cargo init`. The hello world\nof embedded development is usually to blink an LED and code to do so is\navailable in [examples/blinky.rs](examples/blinky.rs). Copy that file to the\n`main.rs` of your project.\n\nYou also need to add some dependencies to your `Cargo.toml`:\n\n```toml\n[dependencies]\nembedded-hal = \"0.2.7\"\nnb = \"1\"\ncortex-m = \"0.7.6\"\ncortex-m-rt = \"0.7.1\"\n# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives\npanic-halt = \"0.2.0\"\n\n[dependencies.stm32f1xx-hal]\nversion = \"0.10.0\"\nfeatures = [\"rt\", \"stm32f103\", \"medium\"]\n```\n\nIf you build your project now, you should get a single error: `error: language\nitem required, but not found: eh_personality`. This unhelpful error message \nis fixed by compiling for the right target.\n\nWe also need to tell Rust how to link our executable, and how to lay out the\nresult in memory. To accomplish all this, copy\n[.cargo/config.toml](.cargo/config.toml) and [memory.x](memory.x) from the\nstm32f1xx-hal repo to your project.\n\n```bash\ncargo build\n```\n\nIf everything went well, your project should have built without errors.\n\n\n### Programming the microcontroller\n\nIt is now time to actually run the code on the hardware.  To do so plug your\ndebug probe into the blue pill and start `openocd` using\n```bash\nopenocd -f interface/stlink-v3.cfg -f target/stm32f1x.cfg\n```\nIf you are not using an stlink V3, change the interface accordingly. \nFor more information, see the [embeddonomicon].\n\nIf all went well, it should detect your microcontroller and say `Info :\nstm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints`. Keep it running in\nthe background.\n\nWe will use gdb for uploading the compiled binary to the microcontroller and\nfor debugging. Cargo will automatically start `gdb` thanks to the\n[.cargo/config](.cargo/config) you added earlier. `gdb` also needs to be told\nto connect to openocd which is done by copying [.gdbinit](.gdbinit) to the root\nof your project.\n\nYou may also need to tell `gdb` that it is safe to load `.gdbinit` from the\nworking directory.\n- Linux\n  ```bash\n  echo \"set auto-load safe-path $(pwd)\" \u003e\u003e ~/.gdbinit\n  ```\n- Windows\n  ```batch\n  echo set auto-load safe-path %CD% \u003e\u003e %USERPROFILE%\\.gdbinit\n  ```\n  *You may need restart your computer*\n\nIf everything was successful, cargo should compile your project, start gdb,\nload your program and give you a prompt. If you type `continue` in the gdb\nprompt, your program should start and the green led on the blue pill should\nstart blinking.\n\n\n### Going further\n\nFrom here on, you can start adding more code to your project to make it do\nsomething more interesting. For crate documentation, see\n[docs.rs/stm32f1xx-hal](https://docs.rs/stm32f1xx-hal). There are also a lot\nmore [examples](examples) available. If something is unclear in the docs or\nexamples, please, open an issue and we will try to improve it.\n\n\n\n\n## Selecting a microcontroller\n\nThis crate supports multiple microcontrollers in the\nstm32f1 family. Which specific microcontroller you want to build for has to be\nspecified with a feature, for example `stm32f103`. \n\nIf no microcontroller is specified, the crate will not compile.\n\nYou may also need to specify the density of the device with `medium`, `high` or `xl` \nto enable certain peripherals. Generally the density can be determined by the 2nd character \nafter the number in the device name (i.e. For STM32F103C6U, the 6 indicates a low-density\ndevice) but check the datasheet or CubeMX to be sure.\n* 4, 6 =\u003e low density, no feature required\n* 8, B =\u003e `medium` feature\n* C, D, E =\u003e `high` feature\n* F, G =\u003e `xl` feature\n\nFor microcontrollers of the `connectivity line` (`stm32f105` and `stm32f107`) no\ndensity feature must be specified.\n\n### Supported Microcontrollers\n\n* `stm32f100`\n* `stm32f101`\n* `stm32f103`\n* `stm32f105`\n* `stm32f107`\n\n## Trying out the examples\n\nYou may need to give `cargo` permission to call `gdb` from the working directory.\n- Linux\n  ```bash\n  echo \"set auto-load safe-path $(pwd)\" \u003e\u003e ~/.gdbinit\n  ```\n- Windows\n  ```batch\n  echo set auto-load safe-path %CD% \u003e\u003e %USERPROFILE%\\.gdbinit\n  ```\n  *You may need restart your computer*\n\nCompile, load, and launch the hardware debugger.\n```bash\n$ rustup target add thumbv7m-none-eabi\n\n# on another terminal\n$ openocd -f interface/$INTERFACE.cfg -f target/stm32f1x.cfg\n\n# flash and debug the \"Hello, world\" example. Change stm32f103 to match your hardware\n$ cargo run --features stm32f103 --example hello\n```\n\n`$INTERFACE` should be set based on your debugging hardware. If you are using\nan stlink V2, use `stlink-v2.cfg`. For more information, see the\n[embeddonomicon].\n\n[embeddonomicon]: https://rust-embedded.github.io/book/start/hardware.html\n\n\n\n## Using as a Dependency\n\nWhen using this crate as a dependency in your project, the microcontroller can \nbe specified as part of the `Cargo.toml` definition.\n\n```toml\n[dependencies.stm32f1xx-hal]\nversion = \"0.9.0\"\nfeatures = [\"stm32f100\", \"rt\"]\n```\n\n## Documentation\n\nThe documentation can be found at [docs.rs](https://docs.rs/stm32f1xx-hal/).\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  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%2Fstm32f1xx-hal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstm32-rs%2Fstm32f1xx-hal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstm32-rs%2Fstm32f1xx-hal/lists"}