This repository contains an example firmware project targeting the ESP32 using the esp-hal ecosystem. The default build target is xtensa-esp32-none-elf and requires the Espressif Rust toolchain.
- Install
espup:cargo install espup
- Provision the Espressif toolchain and Xtensa Rust components:
espup install
- Configure the environment in each new shell session:
. "$HOME/export-esp.sh"
Wi-Fi credentials are embedded into the binary at compile time. To keep them out of version control:
- Copy the provided template and populate it with your network details:
cp .env.example .env
- Edit
.envand setESP_WIFI_SSIDandESP_WIFI_PASSWORD.
During builds the script reads .env (or falls back to host environment variables) and exports the credentials using cargo:rustc-env. The build will fail if either value is missing or empty, ensuring secrets are configured before flashing. The .env file is ignored by Git by default.
With the environment configured, build the firmware in release mode:
cargo build -rThe build artifacts will be placed under target/xtensa-esp32-none-elf/release/.
The cargo runner is configured to use espflash. After connecting the board, run:
cargo runThis will flash the firmware and open a serial monitor using defmt log formatting.
- If the linker (
xtensa-esp32-elf-gcc) cannot be found, ensure you've sourcedexport-esp.shin the current shell. - The global allocator is initialized from a static heap; the compiler emits a warning about mutable statics, which is expected for this pattern in
no_stdenvironments.