Skip to content

Example of Rust integration into an ESP-IDF project, for ESP32 series of chips

License

Notifications You must be signed in to change notification settings

MabezDev/rust-esp32-example

 
 

Repository files navigation

Rust ESP32 Example

An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.

This example starts a FreeRTOS task to call a function in Rust and display the results in C.

Setup

First, install the ESP-IDF SDK as shown in the Get Started guides. For best support of the ESP32-C3, install the SDK from the master branch.

ESP32 and ESP32-S series

To support the Xtensa instruction set, build and install custom LLVM and Rust toolchains as shown in the Rust On Xtensa guide.

Alternatively you might build the project in the container where image already contains pre-installed Rust and ESP-IDF:

docker run -it georgikrocks/esp-idf-rust /bin/bash
idf.py build

ESP32-C3

Install the RISCV target for Rust:

rustup target add riscv32i-unknown-none-elf

Configure

First ensure that the environment variables for the ESP32 SDK are properly set up. If you have followed the instructions in the Getting Started guide, activate the environment with the get_idf alias:

get_idf

Next, configure the project for the desired MCU.

For the ESP32:

idf.py set-target esp32
idf.py menuconfig

For the ESP32-S2:

idf.py set-target esp32s2
idf.py menuconfig

For the ESP32-C3:

idf.py set-target esp32c3
idf.py menuconfig

Build

Build the project by running:

idf.py build

This also runs Cargo internally, building a static library out of Rust code.

Flash

Flash the compiled binary by running:

idf.py -p /dev/cu.SLAB_USBtoUART flash

Monitor

Connect to the UART over USB port to monitor the application console:

idf.py -p /dev/cu.SLABtoUART monitor

To exit the monitor, press Ctrl-].

Debugging on ESP32-WROVER-KIT

openocd -f board/esp32-wrover-kit-3.3v.cfg

About

Example of Rust integration into an ESP-IDF project, for ESP32 series of chips

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CMake 37.6%
  • Rust 19.2%
  • C 18.5%
  • Dockerfile 18.5%
  • PowerShell 6.2%