Dependancies
Buy the components
src/main.rs
use std::thread;
use std::time::Duration;
use esp_idf_sys as _;
use embedded_hal::digital::blocking::OutputPin;
use esp_idf_hal::peripherals::Peripherals;
fn main() {
esp_idf_sys::link_patches();
let peripherals = Peripherals::take().unwrap();
let mut led = peripherals.pins.gpio5.into_output().unwrap();
let n = 1;
while n == 1 {
led.set_high().unwrap();
thread::sleep(Duration::from_millis(1000));
led.set_low().unwrap();
thread::sleep(Duration::from_millis(1000));
println!("blink");
}
}
UPLOAD_PORT?=/dev/cu.usbmodem14*
PROJECT_NAME=blinky-rust-esp32s3
.PHONY: default compile upload log clean
default: clean compile upload
help: ## Show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
compile: ## Compile rust
cargo clean
cargo build
upload: ## Upload the firmware to the board
espflash $(UPLOAD_PORT) target/xtensa-esp32s3-espidf/debug/$(PROJECT_NAME)
log: ## Start the logs
espmonitor $(UPLOAD_PORT)
clean: ## Remove all build files
cargo clean
git clone https://github.com/esp-rs/rust-build.git
cd rust-build
./install-rust-toolchain.sh
. export-esp.sh
$PATH
export LIBCLANG_PATH="~/.espressif/tools/xtensa-esp32-elf-clang/esp-14.0.0-20220415-x86_64-apple-darwin/lib/"
export PATH="~/.espressif/tools/xtensa-esp32-elf-gcc/8_4_0-esp-2021r2-patch3-x86_64-apple-darwin/bin/:~/.espressif/tools/xtensa-esp32s2-elf-gcc/8_4_0-esp-2021r2-patch3-x86_64-apple-darwin/bin/:~/.espressif/tools/xtensa-esp32s3-elf-gcc/8_4_0-esp-2021r2-patch3-x86_64-apple-darwin/bin/:$PATH"
cargo install cargo-generate
cargo install ldproxy
cargo install espflash
cargo install espmonitor
$ cargo generate --vcs none --git https://github.com/esp-rs/esp-idf-template cargo
🤷 Project Name : hello
🔧 Destination: /Users/sayanee/Desktop/hello ...
🔧 Generating template ...
✔ 🤷 STD support · true
✔ 🤷 ESP-IDF native build version (v4.3.2 = previous stable, v4.4 = stable, mainline = UNSTABLE) · v4.4
? 🤷 Configure project to use Dev Containers (VS Code, GitHub Codespaces and Gitpod)? (beware: Dev Cont
✔ 🤷 Configure project to use Dev Containers (VS Code, GitHub Codespaces and Gitpod)? (beware: Dev Containers not available for esp-idf v4.3.2) · false
✔ 🤷 MCU · esp32s3
[ 1/10] Done: .cargo/config.toml
[ 2/10] Done: .cargo
[ 3/10] Done: .gitignore
[ 4/10] Done: .vscode
[ 5/10] Done: Cargo.toml
[ 6/10] Done: build.rs
[ 7/10] Done: rust-toolchain.toml
[ 8/10] Done: sdkconfig.defaults
[ 9/10] Done: src/main.rs
[10/10] Done: src
🔧 Moving generated files into: `/Users/sayanee/Desktop/hello`...
✨ Done! New project created /Users/sayanee/Desktop/hello
$ cd hello
src/main.rs
with the blinky codeCargo.toml
to add dependancies $ cargo build
espflash /dev/cu.usbmodem14101 target/xtensa-esp32s3-espidf/debug/hello
Start the serial monitor
espmonitor /dev/cu.usbmodem14101