/rust-build

Workflows for building Rust fork esp-rs/rust with Xtensa support

Primary LanguageShellMIT LicenseMIT

rust-build

This repository contains:

  • workflows for building Rust fork esp-rs/rust with Xtensa support
  • binary artifacts in Releases

Quick start

The installation process of ready to use custom build of Rust and LLVM:

Installation

Rust on Xtensa Installation for macOS

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.

Prerequisites

Installation commands

./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.59.0.1 --export-file export-esp-rust.sh
source ./export-esp-rust.sh

Rust on Xtensa Installation for Linux

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.

Prerequisites

apt-get install -y git curl gcc ninja-build cmake libudev-dev python3 python3-pip libusb-1.0-0 libssl-dev pkg-config libtinfo5

Installation commands

./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.59.0.1 --export-file export-esp-rust.sh
source ./export-esp-rust.sh

Get source code of examples

curl -LO "https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip"
unzip main.zip
cd rust-esp32-example-main

Select architecture for the build

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

Build and flash

idf.py build flash

Rust on Xtensa Installation for Windows x64

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.

Prerequisites

  • Visual Studio - installed with option Desktop development with C++ - components: MSVCv142 - VS2019 C++ x86/64 build tools, Windows 10 SDK

Visual Studio Installer - configuration

Installation commands for PowerShell

./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.59.0.1 --export-file Export-EspRust.ps1
source ./Export-EspRust.ps1

Get source code of examples

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

Select architecture for the build

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

Build and flash

idf.py build flash

ESP32-C3

Install the RISCV target for Rust:

rustup target add riscv32i-unknown-none-elf

Rust with Podman or Docker

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

There are two different images published to Dockerhub:

Podman example with mapping multiple /dev/ttyUSB from host computer to the container:

podman run --device /dev/ttyUSB0 --device /dev/ttyUSB1 -it docker.io/espressif/idf-rust-examples

Docker (does not support flashing from container):

docker run -it espressif/idf-rust-examples

If you are using the idf-rust-examples image, instructions will be displayed on the screen.