This is a work-in-progress fork of the Rust Standard Library targeting FreeRTOS. So far, it has basic support of threads and sync primitives.
- stdout via semi-hosting
- Support for panic abort and panic unwind
thumbv7m-none-eabi
tested on Qemu'smps2-an385
std library is tightly coupled with the Rust compiler, and it uses many internal features. Therefore a nightly toolchain must be used. Moreover, a specific nightly has to be used, the one that matches whenever last this library was updated from the upstream std library. This version is tracked in [supported-toolchain.txt]
It is recommended to include this repo as a submodule in your workspace, this is because the FreeRTOS build system needs to include c files from it.
$ git submodule add [email protected]:sheref-sidarous/freertos-std.git
- Add
freertos-std
dependency as thestd
library in Cargo.toml
std = {path = "../freertos-std", package = "freertos-std"}
Where path refers to where freertos-std
were checked out. Use features panic-unwind
and stdio-semihosting
if you want to.
- Build your app as a staticlib
[lib]
crate-type = ["staticlib"]
- Build the C file
src/sys/freertos/rust_std_shim.c
from freertos-std within your FreeRTOS the build system - Link the Rust app built as a static library
This library supports panic unwind, but to use it you'd need to recompile Rust toolchain to support unwind for your selected target. There is a helper script in freertos-std-example subfolder rust-unwind-toolchain
for an example of doing so.
Then in your rust app, enable freertos-std panic-unwind
feature and add the compiler flag -Cpanic=unwind
rustflags = ["-Cpanic=unwind"]
Check out freertos-std-example for an example that builds and runs this library using Qemu