In this brief article, we will explore how to set up the ESP32 development environment to build and run Rust code on the ESP-WROOM-32. This procedure is written to work on Ubuntu 22 with a 64-bit Intel processor. The ESP32 is connected to the PC via USB.


Installation

Install Ubuntu packages

sudo apt install -y build-essential libssl-dev pkg-config git
sudo apt install -y python3-pip python3-venv

Configure USB permissions

sudo usermod -aG dialout $USER
sudo usermod -aG tty $USER
# Restart the session

Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

Install espup for Xtensa (ESP-WROOM-32 architecture)

cargo install espup
espup install
source ~/export-esp.sh

Additional tools

cargo install cargo-generate espflash cargo-espflash ldproxy

Create a package, build and deploy

cargo generate --git https://github.com/esp-rs/esp-idf-template cargo
cd esp32-project

Build

source ~/export-esp.sh
cargo build

Flash on ESP32

espflash flash target/xtensa-esp32-espidf/debug/esp32-project --monitor

Troubleshooting

sudo apt install libudev-dev libusb-1.0-0-dev


Check permissions

ls -l /dev/ttyUSB0  # Must belong to 'dialout' group
# sudo usermod -a -G dialout $USER
# sudo chown $USER /dev/ttyUSB0

Check espflash version

espflash --version  # Requires v2.0+

Verify communication with ESP

espflash board-info