Toolchain Setup
The example code is based on the Rust embedded-hal
[31] and stm32f4xx-hal
[54]. If you have not used Rust on a microcontroller before, please see the Embedded Rust Book [32] on how to set up the Rust toolchain and the basics of embedded Rust development.
For the example application, we will use an STM32F446RE microcontroller with an Arm Cortex-M4F CPU. First, we add the target in rustup
and change to the nightly version of the compiler.
rustup target add thumbv7em-none-eabihf
rustup default nightly
Listing: Adjusting the default Rust toolchain from the command line.
Please note that the nightly compiler is needed only for early kernel versions. The few nightly features in use will be replaced in the future, so that the kernel compiles with the stable version.
There are project templates provided for Bern RTOS based applications. First, we must install some additional tools to create a project (cargo-generate
) and to flash the target (probe-run
).
cargo install cargo-generate
cargo install probe-run
Listing: Installing additional packages from the command line.