install

Always install Rust using Rustup. Even on a Mac. You will always get the most reliable and up-to-date toolchain.

build examples

Assuming there is a ./example/hello.rs file

cargo build --example hello

Add run script to your Rust project

JoshMcguigan/cargo-run-script: Bringing `npm run-script` to Rust

cargo install

To install a tool via cargo do cargo install. To install it from a specific verison in git do

shell
cargo install espflash --git https://github.com/JurajSadel/espflash.git

To choose a branch do

shell
cargo install espflash --git https://github.com/JurajSadel/espflash.git --branch feat/reset-args

embedded

For embedded development, once Rust itself is installed, you'll need to install the esp toolchain with espup, then use it to install the esp toolchains. This will take a while.

shell
# do this somewhere other than a rust project dir.
cargo install espup --locked
# add .cargo/bin to your path
export PATH="$PATH:/Users/username/.cargo/bin"

# then install the esp toolchains. This will take a while.
espup install
# source the env vars
. ~/export-esp.sh

# tool to generate new esp projects
cargo install esp-generate
# tool to flash the attached device
cargo install espflash --locked

# make a new esp project
esp-generate --chip=esp32s3 your-project

Leave the default options, hit 's', cd into the project, and build it! Make sure to enable 'log' so you can do the helloworld.

shell
cd your-project
cargo build
cargo run

if you get a waiting for download message, press the RST button and run it again. Then you should see hello world printed.

switch power off press and hold the trackball switch power on have 2 seconds release the trackball

also needed ESP-IDF:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-macos-setup.html#get-started-get-esp-idf

brew install cmake ninja dfu-util

T-Deck with Rust

I'm using the latest esp-hal, which is 1.0.0-beta.1 at the time of this writing (June 10st 2025) I can get the blinky example to compile, but since the t-deck doesn't have a user accessible GPIO pin that doesn't do anything.

I created a repo with examples for the Tdeck showing how to set up the display, connect to wifi, access the keyboard and trackball, and read the battery level.