zeroclaw/firmware/zeroclaw-esp32/SETUP.md
ehu shubham shaw d7c1fd7bf8
security(deps): remove vulnerable xmas-elf dependency via embuild (#414)
* security(deps): remove vulnerable xmas-elf dependency via embuild

* chore(deps): update dependencies and improve ESP-IDF compatibility

- Updated `bindgen`, `embassy-sync`, `embedded-svc`, and `embuild` versions in `Cargo.lock`.
- Added patch section in `Cargo.toml` to use latest esp-rs crates for better compatibility with ESP-IDF 5.x.
- Enhanced README with updated prerequisites and build instructions for Python and Rust tools.
- Introduced `rust-toolchain.toml` to pin nightly Rust and added necessary components.
- Modified GPIO handling in `main.rs` to improve pin management and added support for 64-bit time_t in ESP-IDF.
- Updated `.cargo/config.toml` for new linker and runner configurations.

* docs: add detailed setup guide for ESP32 firmware and link in README

- Introduced a new `SETUP.md` file with comprehensive step-by-step instructions for building and flashing the ZeroClaw ESP32 firmware.
- Updated `README.md` to include a link to the new setup guide for easier access to installation and troubleshooting information.

* chore: update .gitignore and refactor main.rs for improved readability

- Added .embuild/ to .gitignore to exclude ESP32 build cache.
- Refactored code in main.rs for better readability by adjusting the formatting of the handle_request function call.

* docs: add newline for better readability in README.md

- Added a newline in the protocol section of README.md to enhance clarity and formatting.

* chore: configure workspace settings in Cargo.toml

- Added workspace configuration to `Cargo.toml` with members and resolver settings for improved project management.

---------

Co-authored-by: ehushubhamshaw <eshaw1@wpi.edu>
Co-authored-by: Will Sarg <12886992+willsarg@users.noreply.github.com>
2026-02-17 08:18:41 -05:00

3.4 KiB
Raw Blame History

ESP32 Firmware Setup Guide

Step-by-step setup for building the ZeroClaw ESP32 firmware. Follow this if you run into issues.

Quick Start (copy-paste)

# 1. Install Python 3.12 (ESP-IDF needs 3.103.13, not 3.14)
brew install python@3.12

# 2. Install virtualenv (PEP 668 workaround on macOS)
/opt/homebrew/opt/python@3.12/bin/python3.12 -m pip install virtualenv --break-system-packages

# 3. Install Rust tools
cargo install espflash ldproxy

# 4. Build
cd firmware/zeroclaw-esp32
export PATH="/opt/homebrew/opt/python@3.12/libexec/bin:$PATH"
cargo build --release

# 5. Flash (connect ESP32 via USB)
espflash flash target/riscv32imc-esp-espidf/release/zeroclaw-esp32 --monitor

Detailed Steps

1. Python

ESP-IDF requires Python 3.103.13. Python 3.14 is not supported.

brew install python@3.12

2. virtualenv

ESP-IDF tools need virtualenv. On macOS with Homebrew Python, PEP 668 blocks pip install; use:

/opt/homebrew/opt/python@3.12/bin/python3.12 -m pip install virtualenv --break-system-packages

3. Rust Tools

cargo install espflash ldproxy
  • espflash: flash and monitor
  • ldproxy: linker for ESP-IDF builds

4. Use Python 3.12 for Builds

Before every build (or add to ~/.zshrc):

export PATH="/opt/homebrew/opt/python@3.12/libexec/bin:$PATH"

5. Build

cd firmware/zeroclaw-esp32
cargo build --release

First build downloads and compiles ESP-IDF (~515 min).

6. Flash

espflash flash target/riscv32imc-esp-espidf/release/zeroclaw-esp32 --monitor

Troubleshooting

"No space left on device"

Free disk space. Common targets:

# Cargo cache (often 520 GB)
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/src

# Unused Rust toolchains
rustup toolchain list
rustup toolchain uninstall <name>

# iOS Simulator runtimes (~35 GB)
xcrun simctl delete unavailable

# Temp files
rm -rf /var/folders/*/T/cargo-install*

"can't find crate for core" / "riscv32imc-esp-espidf target may not be installed"

This project uses nightly Rust with build-std, not espup. Ensure:

  • rust-toolchain.toml exists (pins nightly + rust-src)
  • You are not sourcing ~/export-esp.sh (that's for Xtensa targets)
  • Run cargo build from firmware/zeroclaw-esp32

"externally-managed-environment" / "No module named 'virtualenv'"

Install virtualenv with the PEP 668 workaround:

/opt/homebrew/opt/python@3.12/bin/python3.12 -m pip install virtualenv --break-system-packages

"expected i64, found i32" (time_t mismatch)

Already fixed in .cargo/config.toml with espidf_time64 for ESP-IDF 5.x. If you use ESP-IDF 4.4, switch to espidf_time32.

"expected *const u8, found *const i8" (esp-idf-svc)

Already fixed via [patch.crates-io] in Cargo.toml using esp-rs crates from git. Do not remove the patch.

10,000+ files in git status

The .embuild/ directory (ESP-IDF cache) has ~100k+ files. It is in .gitignore. If you see them, ensure .gitignore contains:

.embuild/

Optional: Auto-load Python 3.12

Add to ~/.zshrc:

# ESP32 firmware build
export PATH="/opt/homebrew/opt/python@3.12/libexec/bin:$PATH"

Xtensa Targets (ESP32, ESP32-S2, ESP32-S3)

For nonRISC-V chips, use espup instead:

cargo install espup espflash
espup install
source ~/export-esp.sh

Then edit .cargo/config.toml to use xtensa-esp32-espidf (or the correct target).