Rust Toolchain Setup

1. Install Rust

If you don't have Rust installed yet:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Follow the prompts and accept the defaults. After installation, restart your terminal or run:

source $HOME/.cargo/env

Verify:

rustc --version
cargo --version

2. Add the RISC-V Target

The ESP32-C3 uses a RISC-V architecture. Add the target:

rustup target add riscv32imc-unknown-none-elf

3. Install espflash

espflash is used to flash firmware to ESP32 chips and monitor serial output:

cargo install espflash

This may take a few minutes to compile. Verify:

espflash --version

4. Install esp-generate

esp-generate creates new ESP32 Rust projects from templates:

cargo install esp-generate

5. Generate a Test Project

Let's make sure everything works together:

esp-generate --chip esp32c3 hello-uferris
cd hello-uferris

When prompted, select:

  • Which HAL?esp-hal
  • Enable WiFi/BLE? → No (for now)

The project should generate without errors.

6. Build the Test Project

cargo build --release

This first build will take a while as it downloads and compiles dependencies. Subsequent builds are fast.

If `cargo build --release` completes without errors, your toolchain is ready. Next: [Hardware Verification](./hardware.md).

Troubleshooting

cargo install is slow

This is normal for the first install — Rust compiles from source. Grab a coffee.

Target not found

Make sure you're using a recent rustup:

rustup self update
rustup update
rustup target add riscv32imc-unknown-none-elf

Permission errors on Linux

You may need to add your user to the dialout group for serial port access (this matters for the next step):

sudo usermod -a -G dialout $USER

Log out and back in for this to take effect.