Embassy crates released and Rust stable support

January 22, 2024

The Embassy HAL, USB, networking, Bluetooth and bootloader crates have now been released to crates.io! Read on to learn about this major milestone for the Embassy project.

Following the recent releases of embedded-hal crates and Rust 1.75, the Embassy HALs for Nordic nRF, STM32 and Raspberry Pi RP2040 have now been released to crates.io (What is a HAL?).

This is a major milestone with contributions from a lot of people: thank you for all the contributions over the years! At the time of writing, 255 contributors have made changes to the Embassy code base in one way or the other.

The most time has probably been spent on the embassy-stm32 STM32 HAL, which has taken a different approach than other STM32 HALs. It's built upon the stm32-data project, which provides machine-readable metadata about all STM32 chips. embassy-stm32 is generated from this data for all 1400+ supported chips. This allows precise coverage of all STM32 families, quick support for newly released chips, and a unified API making it easy to port code between families and chips.

Something for everyone

A common source of confusion is that you have to buy into the entire Embassy ecosystem to use an Embassy HAL. However, the Embassy HAL crates all support both blocking and async operation in most cases, and you can use them without any runtime, or using another runtime such as RTIC. This way there should be very few cases where you can not use Embassy in one way or the other. The existence of the esp-hal which works with the Embassy executor shows that it goes both ways.

HAL traits

Embassy HALs implement the traits from embedded-hal (both blocking and async). With the release of embedded-hal 1.0, embedded Rust applications now have a stable API with semantic versioning that they can rely on for their applications. This improves maintainability for the applications themselves but also makes it easier to write drivers that will remain working for a long time.

Stable compiler

Starting with Rust 1.75, Embassy can now be compiled with a stable Rust compiler. This removes a roadblock for many who have reservations against using a nightly compiler. This will also improve the situation where different crates have different compiler support and put another hurdle for compiler regressions to impact Embassy applications.

USB

In addition to the HALs, the Embassy USB stack has also been released (embassy-usb and embassy-usb-driver). The USB stack is a fully async USB stack that works with all the Embassy HALs.

There are also some generic functionality in Embassy using it such as embassy-usb-logger and embassy-usb-dfu.

Networking

In addition to the existing embassy-net crate, there are now multiple network drivers released:

These drivers integrate ethernet and WiFi chips with the embassy-net networking stack (Embassy-net is an async layer on top of smoltcp TCP/IP stack).

Bootloader

Embassy Boot is a lightweight bootloader supporting firmware updates in a power-fail-safe way, with trial boots and rollbacks. With the release of Embassy HALs, the chip specific libraries can also be released: embassy-boot-nrf, embassy-boot-stm32 and embassy-boot-rp.

nrf-softdevice

The nrf-softdevice crates provide an idiomatic Rust API wrapping Nordic's Softdevice bluetooth stack for nRF52 series microcontrollers. Together with embassy-nrf, you can use it to build low-power applications that act as Bluetooth Low Energy central or peripheral devices.

The future

With all that out of the way, what is the way forward? As with all software, Embassy will still have bugs that needs fixing, new features that needs adding, so little will change in that regard. We will regularly release new versions of the crates to crates.io with the latest improvements and features.

Now that crates no longer need to be built from git, board support crates and anything requiring a dependency on the HAL can now also be released, and it will be interesting to see what developers will built in the coming year.

Clearly, 2024 will be the year of Rust on embedded. Help us spread the word by showing, demoing and talking about Embassy as well as Embedded Rust!

Thanks

Thanks to the Rust Foundation for sponsoring Dario Nieuwenhuis (@dirbaio)'s work on Embassy through the Fellowship grants program.

Also, many thanks to all contributors to helped make this release possible!

Back to top