Rust bindings for ESP-IDF

(Espressif's IoT Development Framework)

Background

The ESP-IDF API in Rust, with support for each ESP chip (ESP32, ESP32S2, ESP32S3, ESP32C3 etc.) based on the Rust target.

CI

For more information, check out: * The Rust on ESP Book * The esp-idf-template project * The esp-idf-svc project * The esp-idf-hal project * The Rust for Xtensa toolchain * The Rust-with-STD demo project

Build

Feature native

This is the default feature for downloading all tools and building the ESP-IDF framework using the framework's "native" (own) tooling. It relies on build and installation utilities available in the embuild crate.

The native builder installs all needed tools to compile this crate as well as the ESP-IDF framework itself.

(Native builder only) Using cargo-idf to interactively modify ESP-IDF's sdkconfig file

TBD: Upcoming

Feature pio

This is a backup feature for installing all build tools and building the ESP-IDF framework. It uses PlatformIO via the embuild crate.

Similarly to the native builder, the pio builder also automatically installs all needed tools (PlatformIO packages and frameworks in this case) to compile this crate as well as the ESP-IDF framework itself.

NOTE: The pio builder is less flexible than the default native builder in that it can work with only one, specific version of ESP-IDF. At the time of writing, this is V4.3.2.

(PIO builder only) Using cargo-pio to interactively modify ESP-IDF's sdkconfig file

To enable Bluetooth, or do other configurations to the ESP-IDF sdkconfig you might take advantage of the cargo-pio Cargo subcommand: * To install it, issue cargo install cargo-pio --git https://github.com/ivmarkov/cargo-pio * To open the ESP-IDF interactive menuconfig system, issue cargo pio espidf menuconfig in the root of your binary crate project * To use the generated/updated sdkconfig file, follow the steps described in the "Bluetooth Support" section

Configuration

Environment variables are used to configure how the ESP-IDF framework is compiled.

Note that instead of / in addition to specifying those on the command line, you can also put these in a .config/cargo.toml file inside your crate directory (or a parent directory of your crate) by using the recently stabilized Cargo configurable-env feature.

The following environment variables are used by the build script:

More info

If you are interested how it all works under the hood, check the build.rs build script of this crate.