Giter Club home page Giter Club logo

freertos-rust's Introduction

FreeRTOS-rust

This project is based on code from freertos.rs and some additions to simplify the usage of FreeRTOS in embedded applications written in Rust.

In contrast to freertos.rs this crate differs in these points:

  • The application main() entry point is written in Rust.
  • The FreeRTOS scheduler can be started from Rust.
  • The FreeRTOS heap MemMang/heap/heap_x.cis used as global memory allocator for Rust
  • No need for a Clang skeleton project

How it works

The freertos-cargo-build build-dependency compiles the FreeRTOS code from its original "C" sources files into an archive to be linked against your Rust app. Internally it uses the cc crate and some meta info provided by your apps build.rs:

  1. A path to the FreeRTOS Sources
  2. A path to the app specific FreeRTOSConfig.h
  3. A relative path to the FreeRTOS port to be used, e.g. for ARM Cortex-M3 cores.
  4. Optional: Additional C code to be compiled

The freertos-rust dependency provides an interface to access all FreeRTOS functionality from your (embedded) Rust app.

Usage

  1. Checkout FreeRTOS: https://github.com/FreeRTOS/FreeRTOS-Kernel

  2. Add dependencies to your Rust apps Cargo.toml

    [dependencies]
    freertos-rust = "*"
    
    [build-dependencies]
    freertos-cargo-build = "*"
    
  3. Add this snippet to your apps build.rs:

    fn main() {
        let mut b = freertos_cargo_build::Builder::new();
    
        // Path to FreeRTOS kernel or set ENV "FREERTOS_SRC" instead
        b.freertos("path/to/FreeRTOS-Kernel");
        b.freertos_config("src");       // Location of `FreeRTOSConfig.h` 
        b.freertos_port("GCC/ARM_CM3"); // Port dir relativ to 'FreeRTOS-Kernel/portable' 
        b.heap("heap_4.c");             // Set the heap_?.c allocator to use from 
                                        // 'FreeRTOS-Kernel/portable/MemMang' (Default: heap_4.c)       
    
        // b.get_cc().file("More.c");   // Optional additional C-Code to be compiled
    
        b.compile().unwrap_or_else(|e| { panic!("{}", e.to_string()) });
    }
    

Used C compiler

freertos-cargo-build depends on the cc crate. So the C compiler used can be set by using the CC enviroment variable or otherwise defined by internal defaults. For the ARM architecture this is the arm-none-eabi-gcc which can be found here.

Examples

To get started there are examples in freertos-rust-examples for:

  • Cortex M33 (nRF9160)
  • Cortex M3 (STM32L151CBU6A)
  • Cortex M4 (STM32F411CEU6)
  • Windows
  • ...more to come...

Project Crates

License

This repository is using the MIT License. Some parts might state different licenses that need to be respected when used.

freertos-rust's People

Contributors

schteve avatar tothero avatar reitermarkus avatar niondir avatar agerasev avatar joe1994 avatar johnathancn avatar iamthecarl avatar jalonwong avatar jean-santos avatar apullin avatar manishearth avatar sheref-sidarous avatar stefanb7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.