freertos-next 0.8.0

Create to use FreeRTOS in rust projects. The freertos-build crate can be used to build and link FreeRTOS from source inside build.rs.
Documentation

FreeRTOS

CI Crates.io Docs.rs License Downloads

freertos-next is a Rust wrapper for the FreeRTOS API.

  • It bundles the official FreeRTOS-Kernel sources (currently V11.2.0). If you need a customized setup, you can prepare your own kernel source files and call b.freertos("path/to/your/kernel"); in your build.rs.
  • It implements several traits to ensure smooth integration with embedded projects:

The crate is published as freertos-next on crates.io because the more obvious names (freertos, freertos-rust) are already taken.

📦 Usage

  1. Add the dependencies to your application:
cargo add freertos-next
cargo add --build freertos-build
  1. Add the following snippet to your application's build.rs:
fn main() {
    let mut b = freertos_build::Builder::new();
    b.freertos_config("src_c"); // Path to your FreeRTOSConfig.h
    b.compile().unwrap();
}
  1. Optional configuration:
// Use your own FreeRTOS-Kernel source tree
b.freertos("path/to/FreeRTOS-Kernel");

// Override the default port (relative to FreeRTOS-Kernel/portable)
b.freertos_port("GCC/ARM_CM3");

// Select the heap allocator from FreeRTOS-Kernel/portable/MemMang
// Default: heap_4.c
b.heap("heap_4.c");

freertos-next works together with freertos-build. A complete example using freertos-next with stm32f1-hal is available here: stm32f1-FreeRTOS-example

📘 C Compiler

freertos-build uses the cc crate to compile the FreeRTOS kernel. The C compiler can be configured via the CC environment variable, or it will fall back to the defaults provided by cc.

For ARM targets, the expected compiler is arm-none-eabi-gcc, which can be obtained from the ARM GNU toolchain.

Install

# Ubuntu
sudo apt-get install -y gcc-arm-none-eabi

# Windows (Scoop)
scoop install gcc-arm-none-eabi

See also the main repository.