This is a simple example of how to use Rust to program an ESP32 microcontroller.
This project is based on the esp-idf-template project.
See Prequisites
Add user to dialout group to access serial port:
sudo usermod -a -G dialout $USERInstall cargo espflash:
cargo install cargo-espflashcargo espflash board-infooutputs:
[2024-02-04T12:12:44Z INFO ] Serial port: '/dev/ttyUSB0'
[2024-02-04T12:12:44Z INFO ] Connecting...
[2024-02-04T12:12:45Z INFO ] Unable to connect, retrying with extra delay...
[2024-02-04T12:12:46Z INFO ] Using flash stub
Chip type: esp32 (revision v1.0)
Crystal frequency: 40MHz
Flash size: 4MB
Features: WiFi, BT, Dual Core, 240MHz, Coding Scheme None
MAC address: 24:6f:28:00:00:00If you get an error like:
[2024-02-04T12:12:44Z INFO ] Serial port: '/dev/ttyUSB0'
[2024-02-04T12:12:44Z INFO ] Connecting...
[2024-02-04T12:12:45Z INFO ] Unable to connect, retrying with extra delay...Try to press the boot button on the ESP32 board and run the command again.
Copy example.env to .env and adjust the settings.
. $HOME/export-esp.sh
cargo buildI tested on two boards:
To configure the right pins, you can use the v2 or v3 feature:
cargo build --features v2cargo espflash flash --release --monitor --partition-table partitions.csv