This repository contains:
- workflows for building Rust fork esp-rs/rust with Xtensa support
- binary artifacts in Releases
The installation process of ready to use custom build of Rust and LLVM:
- macOS Big Sur M1, macOS Big Sur x86_64, Linux x86_64
- Windows 10, 11 x64
- Podman/Docker
- Not supported: Linux arm64 - missing support in ESP-IDF - espressif/esp-idf#6475
Following instructions are specific for ESP32 and ESP32-S series based on Xtensa architecture.
Instructions for ESP-C series based on RISC-V architecture are described in document for ESP32-C3.
Tested OS: macOS Big Sur M1, macOS Big Sur x86_64, Linux x86_64
- rustup - https://rustup.rs/
./install-rust-toolchain.sh
Export variables displayed at the end of the script.
Installation of different version of toolchain:
./install-rust-toolchain.sh --toolchain-version 1.57.0.0 --export-file export-esp-rust.sh
source ./export-esp-rust.sh
curl -LO "https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip"
unzip main.zip
cd rust-esp32-example-main
For the ESP32 - default (Xtensa architecture):
idf.py set-target esp32
For the ESP32-S2 (Xtensa architecture):
idf.py set-target esp32s2
For the ESP32-S3 (Xtensa architecture):
idf.py set-target esp32s3
idf.py build flash
Following instructions are specific for ESP32 and ESP32-S series based on Xtensa architecture.
Instructions for ESP-C series based on RISC-V architecture are described in document for ESP32-C3.
Tested OS: Windows 10 x64
- Visual Studio - installed with option Desktop development with C++ - components: MSVCv142 - VS2019 C++ x86/64 build tools, Windows 10 SDK
./Install-RustToolchain.ps1
Export variables displayed at the end of the output from the script.
Installation of different version of toolchain:
./Install-RustToolchain.sh --toolchain-version 1.57.0.0 --export-file Export-EspRust.ps1
source ./Export-EspRust.ps1
Invoke-WebRequest https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip -OutFile rust-esp32-example.zip
Expand-Archive rust-esp32-example.zip
cd rust-esp32-example-main
For the ESP32 - default (Xtensa architecture):
idf.py set-target esp32
For the ESP32-S2 (Xtensa architecture):
idf.py set-target esp32s2
For the ESP32-S3 (Xtensa architecture):
idf.py set-target esp32s3
idf.py build flash
Install the RISCV target for Rust:
rustup target add riscv32i-unknown-none-elf
Alternatively you might build the project in the container where image already contains pre-installed Rust and ESP-IDF.
Podman example with mapping multiple /dev/ttyUSB from host computer to the container:
podman run --device /dev/ttyUSB0 --device /dev/ttyUSB1 -it espressif/idf-rust-examples
Docker (does not support flashing from container):
docker run -it espressif/idf-rust-examples
Then follow instructions displayed on the screen.