/rust-esp32-hello-world

ESP32 Xtensa Hello World

Primary LanguageDockerfile

About

Build status

AZ-Delivery ESP-32 Dev Kit C V4 board Hello World.

ESP32 uses a dual core 32-bit Xtensa LX6 CPU. It's supported by the xtensa-esp32-none-elf rust target.

NB Also see https://github.com/rgl/rust-esp32c6-hello-world.

NB Also see https://github.com/rgl/platformio-esp32-arduino-hello-world.

Usage (Ubuntu 22.04 host)

This ESP32 board connects to the computer as a USB serial device, as such, you should add your user to the dialout group:

# add yourself to the dialout group to be able to write to the USB serial
# device without root permissions.
sudo usermod -a -G dialout $USERNAME
# enter a new shell with the dialout group enabled.
# NB to make this permanent its easier to reboot the system with sudo reboot
#    or to logout/login your desktop.
su - $USER

Install the dependencies:

Connect the ESP32 board USB to your computer.

NB The dev container expected the USB device to be at /dev/ttyUSB0.

Open this directory with the Dev Container plugin.

Open bash inside the Visual Studio Code Terminal.

List the installed rust tools chains:

rustup toolchain list -v

You should see something alike:

1.90.0-x86_64-unknown-linux-gnu (default) /home/vscode/.rustup/toolchains/1.90.0-x86_64-unknown-linux-gnu
esp (active) /home/vscode/.rustup/toolchains/esp

Dump the information about the esp attached to the /dev/ttyUSB0 serial port defined in espflash_ports.toml and allowed in devcontainer.json:

espflash --version
espflash list-ports
espflash board-info

You should see something alike:

espflash 4.2.0
/dev/ttyUSB0  EA60:10C4  Silicon Labs  CP2102 USB to UART Bridge Controller
[2025-10-24T21:05:30Z INFO ] Serial port: '/dev/ttyUSB0'
[2025-10-24T21:05:30Z INFO ] Connecting...
[2025-10-24T21:05:34Z INFO ] Using flash stub
Chip type:         esp32 (revision v1.0)
Crystal frequency: 40 MHz
Flash size:        4MB
Features:          WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC address:       24:62:ab:e0:29:3c
Security features: None

Build, flash and run:

cargo build --release
espflash flash target/xtensa-esp32-none-elf/release/rust-esp32-hello-world --monitor

NB This project was initially bootstrapped using esp-generate as:

esp-generate \
  --headless \
  --chip esp32 \
  --option alloc \
  --option unstable-hal \
  --option embassy \
  --option defmt \
  --option esp-backtrace \
  --option ci \
  --option vscode \
  rust-esp32-hello-world