talira

Embassy

The next-generation framework for embedded applications

open sourceMIT OR Apache-2.0free

Embassy is a framework for writing firmware for microcontrollers in async Rust, with no runtime, garbage collector, operating system or heap allocation. Its executor runs tasks cooperatively and sleeps the core when there's nothing to do, and several executors at different priorities can preempt each other for real-time work. It comes with hardware abstraction layers for every STM32 family, Nordic nRF52, nRF53, nRF54 and nRF91, Raspberry Pi RP2040 and RP23xx, TI MSPM0 and NXP MCX-A, and works with the separate esp-hal for ESP32 and other third-party HALs. Around them are crates for timers (embassy-time), a TCP/IP stack (embassy-net), a device-side USB stack, a power-fail-safe bootloader with rollback, and Bluetooth LE through trouble, nrf-softdevice and embassy-stm32-wpan. It's licensed MIT or Apache-2.0.

Problems it solves

  • write microcontroller firmware in Rust without hand-rolling interrupt-driven state machines
  • run several concurrent tasks on an STM32 without an RTOS
  • my battery-powered device should sleep whenever no task has work to do
  • add a TCP/IP stack with DHCP to an embedded Rust project
  • make my RP2040 board show up as a USB serial port or HID device
  • update firmware in the field with a bootloader that rolls back if the new image fails
  • use Bluetooth LE from Rust on an nRF52 or nRF54
  • wait on timers in embedded code with async/await instead of busy loops
  • one async HAL style across STM32, Nordic and Raspberry Pi chips
  • give high-priority real-time tasks preemption over background work without an RTOS

Features

  • async executor with no heap allocation, sleeping the core when idle
  • multiple priority executors for preemption
  • embassy-time timers, Instant and Duration
  • HALs: embassy-stm32 (all STM32 families), embassy-nrf, embassy-rp, embassy-mspm0, embassy-mcxa
  • embassy-net TCP/IP stack with Ethernet, UDP, ICMP and DHCP
  • network drivers for WIZnet, ENC28J60, ESP-Hosted, nRF91, PPP and ADIN1110
  • embassy-usb device stack with CDC ACM, HID and DFU
  • embassy-boot power-fail-safe bootloader with trial boots and rollbacks
  • BLE through trouble, nrf-softdevice and embassy-stm32-wpan
  • cyw43 Wi-Fi driver for the Raspberry Pi Pico W
View 2 more
  • works with esp-hal, ch32-hal, py32-hal and ra-hal
  • embassy-sync primitives and embassy-futures

Alternatives

The same job

These do what Embassy does.

  1. RTIC Real-Time Interrupt-driven Concurrency: the hardware accelerated Rust RTOS

Compare Embassy with the top 3