#sys #idf #esp-idf #esp32

sys esp-idf-sys

Bindings for ESP-IDF (Espressif’s IoT Development Framework)

6 releases

new 0.16.3 Jul 27, 2021
0.16.2 Jul 21, 2021
0.1.2 Aug 7, 2019

#72 in Hardware support

Download history 10/week @ 2021-04-08 16/week @ 2021-04-15 64/week @ 2021-04-22 8/week @ 2021-04-29 9/week @ 2021-05-06 6/week @ 2021-05-13 5/week @ 2021-05-20 7/week @ 2021-05-27 7/week @ 2021-06-03 9/week @ 2021-06-10 5/week @ 2021-06-17 7/week @ 2021-06-24 10/week @ 2021-07-01 8/week @ 2021-07-08 50/week @ 2021-07-15 42/week @ 2021-07-22

53 downloads per month
Used in 3 crates

MIT license

21KB
490 lines

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, ESP32C3 etc.) based on the Rust target

Build

  • The build requires the Rust ESP32 STD compiler fork to be configured and installed as per the instructions there.
  • The relevant Espressif toolchain, as well as the ESP-IDF itself are all automatically downloaded during the build by utilizing the cargo-pio library crate.
  • Check the "Hello, World" demo for how to use and build this crate

Bluetooth Support

In order to enable Bluetooth support with either Bluedroid or NimBLE, there is some additional work:

  • Go to the root of your binary crate project (e.g., the "Hello, World" demo)
  • Create a .cargo/config.toml file if it does not exist there yet. You can copy it from the "Hello, World" demo
  • Include in it the following:
[env]
...
ESP_IDF_SYS_GLOB_0 = { value = "/sdkconfig" }
  • Next, create a file sdkconfig at the root of binary crate your project. This could be generated with cargo pio espidf menuconfig if you install cargo-pio (see below) but a minimal manual example follows:
CONFIG_BT_ENABLED=y
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
CONFIG_BTDM_CTRL_MODE_BTDM=n
// Uncomment whichever of these you need
//CONFIG_BT_BLUEDROID_ENABLED=y
//CONFIG_BT_NIMBLE_ENABLED=y

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

More info

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

Dependencies

~0–2.6MB
~54K SLoC