Need help with stm32f4xx-hal?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

217 Stars 130 Forks Other 762 Commits 34 Opened issues


A Rust embedded-hal HAL for all MCUs in the STM32 F4 family

Services available


Need anything else?

Contributors list

stm32f4xx-hal Released API docs Minimum Supported Rust Version Continuous integration Bors enabled

stm32f4xx-hal contains a multi device hardware abstraction on top of the peripheral access API for the STMicro STM32F4 series microcontrollers. The selection of the MCU is done by feature gates, typically specified by board support crates. Currently supported configurations are:

  • stm32f401
  • stm32f405
  • stm32f407
  • stm32f410
  • stm32f411
  • stm32f412
  • stm32f413
  • stm32f415
  • stm32f417
  • stm32f423
  • stm32f427
  • stm32f429
  • stm32f437
  • stm32f439
  • stm32f446
  • stm32f469
  • stm32f479

The idea behind this crate is to gloss over the slight differences in the various peripherals available on those MCUs so a HAL can be written for all chips in that same family without having to cut and paste crates for every single model.

Collaboration on this crate is highly welcome as are pull requests!

This crate relies on Adam Greigs fantastic stm32f4 crate to provide appropriate register definitions and implements a partial set of the embedded-hal traits.

Some of the implementation was shamelessly adapted from the stm32f1xx-hal crate originally started by Jorge Aparicio.

Setting up your project

Check if the BSP for your board exists in the stm32-rs page. If it exists, the

crate should be already included, so you can use the bsp as BSP for your project.

Otherwise, create a new Rust project as you usually do with

cargo init
. The "hello world" of embedded development is usually to blink a LED. The code to do so is available in examples/ Copy that file to the
of your project.

You also need to add some dependencies to your

embedded-hal = "0.2"
nb = "1"
cortex-m = "0.7"
cortex-m-rt = "0.7"
# Panic behaviour, see for alternatives
panic-halt = "0.2"

[dependencies.stm32f4xx-hal] version = "0.10" features = ["rt", "stm32f407"] # replace the model of your microcontroller here

We also need to tell Rust how to link our executable and how to lay out the result in memory. To accomplish all this, copy .cargo/config and memory.x from the

repository to your project and make sure the sizes match up with the datasheet. Also note that there might be different kinds of memory which are not equal; to be on the safe side only specify the size of the first block at the specified address.


0-clause BSD license.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.