Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ runner = "espflash flash --monitor"

rustflags = [ "--cfg", "espidf_time64"]

[target.xtensa-esp32s3-espidf] # Esp32-S3
linker = "ldproxy"
runner = "espflash flash --monitor"
rustflags = [ "--cfg", "espidf_time64"]

[unstable]
build-std = ["std", "panic_abort"]

Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ opt-level = "z"
[features]
default = []
esp32c3 = []
esp32s3 = []
#experimental = ["esp-idf-svc/experimental"]

[dependencies]
Expand All @@ -57,6 +58,7 @@ ws2812-esp32-rmt-driver = { version = "0.12", default-features = false, features
rgb = "0.8.52" # <-- brings rgb::RGB8 into scope
names = "0.14"
once_cell = "1.19" # not sure if good idea WDYT?
libc = "0.2"

[build-dependencies]
embuild = "0.33.1"
Expand Down
30 changes: 30 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ build *args:
build-c3 *args:
MCU=esp32c3 cargo build --release --target riscv32imc-esp-espidf --features esp32c3 {{args}}

build-s3 *args:
MCU=esp32s3 cargo build --release --target xtensa-esp32s3-espidf --features esp32s3 {{args}}

flash:
espflash flash --monitor --chip esp32c6 target/riscv32imac-esp-espidf/release/esp-wifi-ap

flash-c3:
espflash flash --monitor --chip esp32c3 target/riscv32imc-esp-espidf/release/esp-wifi-ap

flash-s3:
espflash flash --monitor --chip esp32s3 target/xtensa-esp32s3-espidf/release/esp-wifi-ap

# Default recipe (ESP32-C6)
run *args:
# Show coloured output in the terminal,
Expand Down Expand Up @@ -45,6 +51,21 @@ release-c3 *args:
# copy a colour-stripped log to the clipboard
env MCU=esp32c3 cargo run --release --bin esp-wifi-ap --target riscv32imc-esp-espidf --features esp32c3 {{args}}

# Run with ESP32-S3
run-s3 *args:
# Show coloured output in the terminal,
# copy a colour-stripped log to the clipboard
unbuffer env MCU=esp32s3 cargo run --bin esp-wifi-ap --target xtensa-esp32s3-espidf --features esp32s3 {{args}} 2>&1 \
| tee /dev/tty \
| sed -r 's/${COLOR_RE}//g' \
| pbcopy

# Release with ESP32-S3
release-s3 *args:
# Show coloured output in the terminal,
# copy a colour-stripped log to the clipboard
env MCU=esp32s3 cargo run --release --bin esp-wifi-ap --target xtensa-esp32s3-espidf --features esp32s3 {{args}}

# Run client (ESP32-C6)
run-client *args:
# Show coloured output in the terminal,
Expand All @@ -63,5 +84,14 @@ run-client-c3 *args:
| sed -r 's/${COLOR_RE}//g' \
| pbcopy

# Run client with ESP32-S3
run-client-s3 *args:
# Show coloured output in the terminal,
# copy a colour-stripped log to the clipboard
unbuffer env MCU=esp32s3 cargo run --bin esp-wifi-client --target xtensa-esp32s3-espidf --features esp32s3 {{args}} 2>&1 \
| tee /dev/tty \
| sed -r 's/${COLOR_RE}//g' \
| pbcopy

where_my_esp_at:
ls -lt /dev/tty.usb* /dev/cu.usb* 2>/dev/null | awk '{print $NF}'
56 changes: 47 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This project provides two binaries:
- **Distance Measurement**:
- AP: RTT (Round Trip Time) for precise ranging
- Client: RSSI-based distance estimation
- **Chip Support**: ESP32-C6 (default) and ESP32-C3
- **Chip Support**: ESP32-C6 (default), ESP32-C3, and ESP32-S3
- **Robust Logging**: Comprehensive Wi-Fi event and connection status logging
- **Static DHCP Reservations**: Pin specific client MACs to deterministic IP addresses through `.env`
- **Network Cycling**: Client can cycle through multiple Wi-Fi networks with button press
Expand All @@ -32,15 +32,23 @@ This project provides two binaries:
- **Architecture**: RISC-V 32-bit single-core @ 160 MHz
- **Memory**: 400 KB SRAM, 384 KB ROM

### ESP32-S3 (Optional Feature)
- **Target**: `xtensa-esp32s3-espidf`
- **Chip**: esp32s3
- **Feature flag**: `--features esp32s3`
- **Architecture**: Xtensa LX7 dual-core @ 240 MHz
- **Memory**: 512 KB SRAM, 384 KB ROM
- **Measured Wi-Fi throughput (STA mode)**: ~4.5 Mbps down / ~5 Mbps up

### Key Differences
| Feature | ESP32-C6 | ESP32-C3 |
|---------|----------|----------|
| Architecture | RISC-V 32-bit dual-core | RISC-V 32-bit single-core |
| CPU Speed | 160 MHz | 160 MHz |
| Target | `riscv32imac-esp-espidf` | `riscv32imc-esp-espidf` |
| Wi-Fi | 802.11 b/g/n | 802.11 b/g/n |
| Bluetooth | LE 5.0 + Zigbee/Thread | LE 5.0 |
| Build Command | `just build` | `just build-c3` |
| Feature | ESP32-C6 | ESP32-C3 | ESP32-S3 |
|---------|----------|----------|----------|
| Architecture | RISC-V 32-bit dual-core | RISC-V 32-bit single-core | Xtensa LX7 dual-core |
| CPU Speed | 160 MHz | 160 MHz | 240 MHz |
| Target | `riscv32imac-esp-espidf` | `riscv32imc-esp-espidf` | `xtensa-esp32s3-espidf` |
| Wi-Fi | 802.11 b/g/n | 802.11 b/g/n | 802.11 b/g/n |
| Bluetooth | LE 5.0 + Zigbee/Thread | LE 5.0 | LE 5.0 |
| Build Command | `just build` | `just build-c3` | `just build-s3` |

# Setup
```bash
Expand All @@ -58,6 +66,14 @@ ESP-IDF v5.4.1

## Build & Flash

### Rust Toolchain
Install the Espressif-patched toolchain (provides the `*-espidf` targets, including Xtensa) if you haven't already:
```bash
cargo install espup
espup install
```
This installs the `esp` toolchain that the project pins in `rust-toolchain.toml`.

### Wi-Fi Access Point (C6)
```bash
# Using justfile (recommended)
Expand All @@ -82,6 +98,18 @@ MCU=esp32c3 cargo build --release --target riscv32imc-esp-espidf --features esp3
espflash flash --monitor --chip esp32c3 target/riscv32imc-esp-espidf/release/esp-wifi-ap
```

### Wi-Fi Access Point (S3)
```bash
# Using justfile (recommended)
just build-s3 # Build for ESP32-S3
just flash-s3 # Flash to ESP32-S3
just run-s3 # Build, flash, and monitor ESP32-S3

# Or using cargo directly
MCU=esp32s3 cargo build --release --target xtensa-esp32s3-espidf --features esp32s3
espflash flash --monitor --chip esp32s3 target/xtensa-esp32s3-espidf/release/esp-wifi-ap
```

### Wi-Fi Station Client
```bash
# ESP32-C6 (default)
Expand All @@ -91,6 +119,10 @@ cargo espflash flash --release --bin esp-wifi-client
# ESP32-C3
MCU=esp32c3 cargo build --bin esp-wifi-client --release --target riscv32imc-esp-espidf --features esp32c3
espflash flash --monitor --chip esp32c3 target/riscv32imc-esp-espidf/release/esp-wifi-client

# ESP32-S3
MCU=esp32s3 cargo build --bin esp-wifi-client --release --target xtensa-esp32s3-espidf --features esp32s3
espflash flash --monitor --chip esp32s3 target/xtensa-esp32s3-espidf/release/esp-wifi-client
# OR using tasks
cargo run --bin esp-wifi-client
```
Expand All @@ -109,6 +141,12 @@ just flash-c3 # Flash ESP32-C3
just run-c3 # Build, flash, and monitor ESP32-C3 (AP mode)
just run-client-c3 # Build, flash, and monitor ESP32-C3 (Client mode)

# ESP32-S3 (Feature)
just build-s3 # Build for ESP32-S3
just flash-s3 # Flash ESP32-S3
just run-s3 # Build, flash, and monitor ESP32-S3 (AP mode)
just run-client-s3 # Build, flash, and monitor ESP32-S3 (Client mode)

# Utility commands
just where_my_esp_at # Find ESP device ports
```
Expand Down
7 changes: 6 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[toolchain]
channel = "nightly"
channel = "esp"
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from 'nightly' to 'esp' toolchain is undocumented in the PR. Users upgrading may need to install the esp toolchain first. While the readme.md adds installation instructions, consider documenting this breaking change or ensuring backward compatibility.

Copilot uses AI. Check for mistakes.
components = ["rust-src"]
targets = [
"riscv32imac-esp-espidf",
"riscv32imc-esp-espidf",
"xtensa-esp32s3-espidf",
]
7 changes: 7 additions & 0 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ CONFIG_LWIP_IP6_FRAG=y
CONFIG_LWIP_IP_REASS_MAX_PBUFS=10
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y

# Allow more simultaneous SoftAP clients (default is 10)
CONFIG_ESP_WIFI_SOFTAP_MAX_CONN=16
CONFIG_ESP_WIFI_MAX_CONN=16
CONFIG_LWIP_DHCPS_MAX_STATION_NUM=32
# ESP-NOW encrypted peers share HW key slots with SoftAP stations; keep at 0 unless needed
CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0
CONFIG_LWIP_IPV4_NAPT_PORTMAP=y
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
Expand Down
Loading