16 KiB
Embedded Rust
This is a curated list of resources related to embedded and low-level programming in the programming language Rust, including a list of useful crates.
Table of contents
- Community
- Books, blogs and training materials
- Tools
- Device crates
- HAL implementation crates
- Architecture support crates
- Board support crates
- Driver crates
- no-std crates
- Rust forks
- License
Community
In 2018 Rust community has created an embedded workgroup to help drive adoption in the Rust ecosystem.
-
Embedded WG, including newsletters with progress updates.
-
You can usually find the members of the embedded WG on the
#rust-embedded
channel (server:irc.mozilla.org
). -
embedded.rs Telegram chat about Rust for microcontrollers in Russian language.
Books, blogs and training materials
- Discovery by @japaric — this book is an introductory course on microcontroller-based embedded systems that uses Rust as the teaching language.
- Exploring Rust on Teensy by @branan — Beginner set of articles on getting into embedded dev in Rust.
- Pragmatic Bare Metal Rust A starter article about starting Rust development on STM32 microcontrollers (cubeMX + FFI).
- Using Rust in an Embedded Project: A Simple Example Article and some links on setting up Rust cross-compiling.
- Robigalia IoT operating system in Rust running on secure seL4 microkernel.
- Tock An embedded operating system designed for running multiple concurrent, mutually distrustful applications on low-memory and low-power microcontrollers
- intermezzOS A small teaching operating system in Rust. A book with some explanations is also included.
- Raspberry Pi Bare Metal Programming with Rust
- 32-bit Version (most Pi1 and Pi2 variants) A starter article on OSdev with Rust on RPi (cross-compiler setup and a very basic LED-blinking kernel).
- 64-bit Version (Pi2 Model B v1.2 and all Pi3) A growing collection of tutorials, from simple booting to interfacing components like UARTs or random number generators; Features a painless cross-toolchain setup.
- Fearless concurrency by @japaric — How to easily develop Rust programs for pretty much any ARM Cortex-M microcontroller with memory-safe concurrency.
- RTFM v2 Real-Time For the Masses — Cortex-M programming framework for building concurrent applications.
- cortex-m rtfm RTFM framework for ARM Cortex-M microcontrollers
- msp430 rtfm RTFM framework for MSP430 MCUs
- FreeRTOS.rs Rust interface for the FreeRTOS API
Tools
- xargo Rust package manager with support for non-default std libraries — build rust runtime for your own embedded system.
- svd2rust Generate Rust structs with register mappings from SVD files.
- μtest unit testing for microcontrollers and other no-std systems.
- bindgen Automatically generates Rust FFI bindings to C and C++ libraries. -
- cortex-m semihosting Semihosting for ARM Cortex-M processors
Device crates
Register definition for microcontroller families. Usually generated using svd2rust
. -
NOTE You may be able to find even more device crates by searching for the
svd2rust
keyword on crates.io!
Nordic
nrf51
Peripheral access API for nRF51 microcontrollers (generated using svd2rust) -
NXP
STMicroelectronics
stm32f042
-stm32f103xx
Peripheral access API for STM32F103XX microcontrollers (generated using svd2rust) -stm32f100xx
Peripheral access API for STM32F100XX microcontrollers (generated using svd2rust) -stm32f30x
Peripheral access API for STM32F30X microcontrollers (generated using svd2rust) -stm32f429
Peripheral access API for STM32F429 microcontrollers (generated using svd2rust) -stm32l151
-
MSP430
msp430g2553
Peripheral access API for MSP430G2553 microcontrollers (generated using svd2rust)- rust on msp Simple blinking LED example that runs on MSP430.
- msp430 quickstart some examples for msp430
HAL implementation crates
Implementations of embedded-hal
for microcontroller families and systems running some OS. -
NOTE You may be able to find even more HAL implementation crates by searching for the
embedded-hal-impl
and embedded-hal
keywords on crates.io!
OS
linux-embedded-hal
for embedded Linux systems like the Raspberry Pi. -
Nordic
NXP
Also check the list of NXP board support crates!
STMicroelectronics
Also check the list of STMicroelectronics board support crates!
stm32f042-hal
-- Has examples that can run on boards like the Nucleo-F042K6 and similar boards
stm32f103xx-hal
- Has examples that can run on boards like the Blue pill, Nucleo-F103RB and similar boards
Texas Instruments
Architecture support crates
Crates tailored for general CPU architectures.
ARM
cortex-m
Low level access to Cortex-M processors
Board support crates
Crates tailored for specific development boards.
Nordic
NXP
frdm-kw41z
- FRDM-KW41Z -
STMicroelectronics
nucleo-f042k6
- Nucleo-F042K6nucleo-f103rb
- Nucleo-F103RBf3
Board Support Crate for the STM32F3DISCOVERY -blue-pill
Board Support Crate for Blue Pill.
Driver crates
Platform agnostic crates to interface external components. These crates use the embedded-hal
interface to support all the devices and systems that implement the embedded-hal
traits.
The list below contains drivers developed as part of the Weekly Driver initiative and that have achieved the "released" status (published on crates.io + documentation / short blog post).
- L3GD20 - SPI - Gyroscope - Intro blog post -
- LSM303DLHC - I2C - Accelerometer + compass (magnetometer) - Intro blog post -
- MCP3008 - SPI - 8 channel 10-bit ADC - Intro blog post -
- ENC28J60 - SPI - Ethernet controller - Intro blog post -
- MCP3425 - I2C - 16-bit ADC - Intro blog post -
- SGP30 - I2C - Gas sensor - Intro blog post -
- HTS221 - I2C - Humidity and temperature sensor - Intro blog post -
NOTE You may be able to find even more driver crates by searching for the embedded-hal-driver
keyword on crates.io!
WIP
Work in progress drivers. Help the authors make these crates awesome!
- MFRC522 - SPI - RFID tag reader/writer
- MPU9250 - SPI - Accelerometer + gyroscope + compass
- motor-driver - Motor drivers: L298N, TB6612FNG, etc.
- MAG3110 - I2C - Magnetometer
- SI5351 - I2C - clock generator
- SI7021 - I2C - Humidity and temperature sensor
- MAX7219 - SPI - LED display driver
- DS3231 - I2C - real time clock
- BH1750 - I2C - ambient light sensor (lux meter)
- SHT2x - I2C - temperature / humidity sensors
- INA260 - I2C - power monitor -
- SSD1306 - I2C - OLED display driver
- ILI9341 - SPI - TFT LCD display
- HD44780 - Parallel port - LCD controller
- MCP9808 - I2C - Temperature sensor -
- MMA7660FC - I2C - 3-axis accelerometer
- AXP209 - I2C - Power management unit
- DS3234 - SPI - Real time clock
- PCD8544 - SPI - 48x84 pixels matrix LCD controller
- HC-SR04 - DIO - Ultrasound sensor
- AFE4400 - SPI - Pulse oximeter
- SX1278 - SPI - Long range (LoRa) transceiver
- RFM69 - SPI - ISM radio transceiver
- LS010B7DH01 - SPI - Memory LCD
- MAX31855 - SPI - Thermocouple digital converter
- SHT3x - I2C - Temperature / humidity sensors
- SX1509 - I2C - IO Expander / Keypad driver
no-std crates
#![no_std]
crates designed to run on resource constrained devices.
- bit_field: manipulating bitfields and bitarrays -
- heapless: provides
Vec
,String
,LinearMap
,RingBuffer
backed by fixed-size buffers - - managed: provides
ManagedSlice
,ManagedMap
backed by either their std counterparts or fixed-size buffers for#![no_std]
. - - smoltcp: a small TCP/IP stack that runs without
alloc
Rust forks
AVR
- AVR Rust Fork of Rust with AVR support.
License
This list is licensed under
- CC0 1.0 Universal License (LICENSE-CC0 or https://creativecommons.org/publicdomain/zero/1.0/legalcode)