gitmyhub

embassy

Rust ★ 9.4k updated 1d ago

Modern embedded framework, using Rust and async.

Embassy is a Rust framework for writing firmware that runs directly on microcontrollers, letting multiple tasks run concurrently with async/await without a traditional operating system, which saves memory and extends battery life.

RustSTM32nRFRP2040probe-rssetup: hardcomplexity 4/5

Embassy is a framework for writing software that runs directly on microcontrollers, the small chips found inside embedded devices like sensors, IoT gadgets, and custom electronics. It is built with the Rust programming language and uses a feature called async/await, which makes it possible to run multiple tasks at the same time without needing a traditional operating system or a separate real-time kernel.

The way async/await works in this context is that tasks are converted at compile time into small state machines that take turns running. There is no need to allocate memory for each task separately, and the processor can sleep automatically when there is nothing to do, which helps battery-powered devices last much longer. This approach is described by the project as faster and smaller than traditional real-time operating systems.

Embassy includes hardware support libraries for a range of popular microcontroller families, including STM32 chips, Nordic Semiconductor nRF chips, Raspberry Pi RP2040 and RP2350 chips, Texas Instruments MSPM0, and others. These libraries give you safe, readable ways to control hardware features like GPIO pins, timers, and communication buses without writing low-level register code directly.

Beyond the core hardware support, Embassy ships with a set of additional components: a time system that works globally without needing per-task configuration, a networking stack covering Ethernet, TCP, UDP, and DHCP, Bluetooth Low Energy support for several chip families, a USB stack for building USB devices, and a bootloader that supports safe over-the-air firmware updates with rollback capability.

The project provides many example programs organized by chip family, and getting started requires the Rust toolchain plus a flashing tool called probe-rs. Documentation, an API reference, and a community chat room are available on the project website.

Where it fits