Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ancillary Crates Overview

Before going into a detailed description of the various packages and concepts for writing an application, it might be useful to have a superficial familiarity with the whole ecosystem, both in the esp-hal sense and in the broader Embedded Rust sense.

esp-hal Ecosystem

The first step in working with a project is to create it, the main way to do this is to use esp-generate. Read more about it in the section dedicated to this tool.

The core crate that ties all work with Espressif chips in Rust is the esp-hal crate. Through it, you will be able to perform basic initialization of the chip, as well as access drivers for the peripherals available on the chip. The full esp-hal documentation for selected chip will give unambiguous information about what peripherals are available to use, and the stability of their respective drivers.

Furthermore, you may want to use more advanced functionality of the chip. For example, network and connectivity. This part of the ecosystem is the responsibility of esp-radio, which combines drivers for the communication protocols available on one or another of Espressif's products: Wi-Fi, BLE, esp-now and low-level IEEE 802.15.4 for the lower layers of communication. More detailed information for each chip is available in the esp-radio sub-repository.

For more advanced work with chip memory and to use collections from the alloc crate in no_std that require heap allocation, you are welcome to use esp-alloc. A separate chapter in the book is devoted to this.

The table below briefly describes all crates in the esp-hal ecosystem and their purposes:

CrateDescriptionStability
esp-allocMemory allocation utilities.Unstable
esp-backtraceProvides backtraces support.Unstable
esp-bootloader-esp-idfOffers additional support for the ESP-IDF 2nd stage bootloader, including OTA.Unstable
esp-buildBuild utilities for use with esp-hal and other related packages, intended for use in build scripts.Unstable
esp-configConfiguration system.Unstable
esp-halBare-metal (no_std) HAL for all Espressif ESP32 devices.Stable*
esp-hal-embassyEmbassy support for esp-hal.Unstable
esp-hal-proc-macrosProcedural macros for use with the esp-hal family of HAL packages.Unstable
esp-lp-halBare-metal (no_std) HAL for the low power and ultra-low power cores found in some Espressif devices.Unstable
esp-metadataMetadata for Espressif devices, primarily intended for use in build scripts.Unstable
esp-preemptThreading and thread-aware synchronization primitives, primarily used for esp-radio.Unstable
esp-printlnPrint and logging functionality for Espressif devices.Unstable
esp-riscv-rtMinimal startup/runtime for RISC-V CPUs from Espressif.Unstable
esp-rom-sysROM code support.Unstable
esp-syncSynchronization primitives for Espressif devices.Unstable
esp-storageStorage utilities for Espressif devices.Unstable
esp-radioWi-Fi, BLE, IEEE8 802.15.4 and ESP-NOW functionality for Espressif devices.Unstable
xtensa-lxLow-level access to Xtensa LX processors and peripherals.Unstable
xtensa-lx-rtMinimal startup/runtime for Xtensa LX CPUs from Espressif.Unstable

⚠️ Note: The stability of individual peripheral drivers within esp-hal varies. Refer to the Peripheral support section for per-peripheral stability details.

Embedded Rust Ecosystem Integration

The most popular Hardware Abstraction Layer in the Embedded Rust environment is embedded-hal, which provides a number of traits for several peripherals that allow writing HAL agnostic device drivers. esp-hal implements these traits within its drivers. In addition, various traits from different crates used in the embedded Rust industry have also been implemented, such as rand_core traits for our Random Number Generator (RNG) peripheral, as well as embedded-io traits, which are analogues of std::io traits for no_std applications.