diff --git a/README.md b/README.md index d303fe41f34..3317fa99159 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ [![CI](https://github.com/esp-rs/esp-idf-sys/actions/workflows/ci.yml/badge.svg)](https://github.com/esp-rs/esp-idf-sys/actions/workflows/ci.yml) [![Documentation](https://img.shields.io/badge/docs-esp--rs-brightgreen)](https://esp-rs.github.io/esp-idf-sys/esp_idf_sys/index.html) -## Background - The ESP-IDF API in Rust, with support for each ESP chip (ESP32, ESP32S2, ESP32S3, ESP32C3, etc.) based on the Rust target. For more information, check out: @@ -16,6 +14,15 @@ For more information, check out: * The [Rust for Xtensa toolchain](https://github.com/esp-rs/rust-build) * The [Rust-with-STD demo](https://github.com/ivmarkov/rust-esp32-std-demo) project +**Table of contents** +- [Build](#build) +- [Features](#features) +- [sdkconfig](#sdkconfig) +- [Build configuration](#build-configuration) +- [Extra esp-idf components](#extra-esp-idf-components) +- [Conditional compilation](#conditional-compilation) +- [More info](#more-info) + ## Build - To build this crate, please follow all the build requirements specified in the [ESP-IDF Rust Hello World template crate](https://github.com/esp-rs/esp-idf-template) @@ -26,34 +33,43 @@ For more information, check out: - Check the [ESP-IDF Rust Hello World template crate](https://github.com/esp-rs/esp-idf-template) for a "Hello, world!" Rust template demonstrating how to use and build this crate. - Check the [demo](https://github.com/ivmarkov/rust-esp32-std-demo) crate for a more comprehensive example in terms of capabilities. -## 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](https://github.com/ivmarkov/embuild) crate. +## Features +- ### `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](https://github.com/ivmarkov/embuild) crate. -The `native` builder installs all needed tools to compile this crate as well as the ESP-IDF framework itself. + 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 +- ### `pio` -TBD: Upcoming + This is a backup feature for installing all build tools and building the ESP-IDF framework. It uses [PlatformIO](https://platformio.org/) via the + [embuild](https://github.com/ivmarkov/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. -## Feature `pio` -This is a backup feature for installing all build tools and building the ESP-IDF framework. It uses [PlatformIO](https://platformio.org/) via the -[embuild](https://github.com/ivmarkov/embuild) crate. + > ⚠️ 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. -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. +## sdkconfig -**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. +The esp-idf makes use of an [sdkconfig](#espidfsdkconfig-espidfsdkconfig) file for its +compile-time component configuration (see the [esp-idf +docs](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#project-configuration) +for more information). This config is separate from the [build configuration](#build-configuration). -### (PIO builder only) Using cargo-pio to interactively modify ESP-IDF's `sdkconfig` file +### (*native* builder only) Using cargo-idf to interactively modify ESP-IDF's `sdkconfig` file + +TBD: Upcoming + +### (*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 +## Build configuration -There are two ways to configure how the ESP-IDF framework is compiled. +There are two ways to configure how the ESP-IDF framework is compiled: 1. Environment variables, denoted by `$VARIABLE`; > The environment variables can be passed on the command line, or put into the `[env]` @@ -70,11 +86,15 @@ There are two ways to configure how the ESP-IDF framework is compiled. > ⚠️ Environment variables always take precedence over `Cargo.toml` metadata. -> 🛈 **Note**: *workspace directory* +> 🛈 **Note**: *workspace directory* +> The workspace directory mentioned here is always the directory containing the +> `Cargo.lock` file and the `target` directory (where the build artifacts are stored). It +> can be overridden with the `CARGO_WORKSPACE_DIR` environment variable, should this not +> be the right directory. +> (See +> [`embuild::cargo::workspace_dir`](https://docs.rs/embuild/latest/embuild/cargo/fn.workspace_dir.html) +> for more information). > -> The workspace directory mentioned here is always the -> directory containing the `Cargo.lock` file and the `target` directory (where the build -> artifacts are stored). > There is no need to explicitly add a > [`[workspace]`](https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspace-section) > section to the `Cargo.toml` of the workspace directory. @@ -90,6 +110,8 @@ The following configuration options are available: Defaults to `sdkconfig.defaults`. + In case of the environment variable, multiple elements should be `;`-separated. + > 🛈 **Note** > For each defaults file in this list, a more specific file will also be searched and > used. This happens with the following patterns and order (least to most specific): @@ -131,7 +153,7 @@ The following configuration options are available: > determine the compiler optimizations of the `esp-idf`, **however** if the compiler > optimization options are already set in the `sdkconfig` **they will be used instead.** -- ### *`esp_idf_tools_install_dir`*, `$ESP_IDF_TOOLS_INSTALL_DIR`: +- ### *`esp_idf_tools_install_dir`*, `$ESP_IDF_TOOLS_INSTALL_DIR` The install location for the ESP-IDF framework tooling. @@ -147,7 +169,7 @@ The following configuration options are available: directory](https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script), and will be deleted when `cargo clean` is invoked; - `global` - the tooling will be installed or used in its standard directory - (`~/.platformio` for PlatformIO, and `~./espressif` for the native ESP-IDF toolset); + (`~/.platformio` for PlatformIO, and `~/.espressif` for the native ESP-IDF toolset); - `custom: