Skip to content

Add native ESP32 C5 RuFANN inference - #213

Merged
ruvnet merged 1 commit into
mainfrom
codex/esp32-c5-inference
Nov 10, 2026
Merged

ruvnet merged 1 commit into
mainfrom
codex/esp32-c5-inference

Conversation

@ruvnet

@ruvnet ruvnet commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Implementation

  1. Add a standalone ESP32 C5 firmware example and a fixed point Rust scorer with no heap allocation during inference.
  2. Compile a supported RuFANN dense JSON checkpoint into two Q10 constants at build time. Reject unsupported weights, topology, or precision.
  3. Document the host test, C5 build, flash command, and emulator command in the repository README.

Verification

  1. Host parity matched the RuFANN Rust core exactly on 1,089 input pairs. A second checkpoint with an edited margin also matched all cases. Boundary and invalid input tests passed.
  2. The compiler rejected a changed hidden weight and a hinge that Q10 could not represent.
  3. Rust 1.90 linked the release firmware for riscv32imac-unknown-none-elf. Espflash 4.7.0 packaged a 37,200 byte C5 application image.
  4. Espressif emulator 0.51.0 booted the merged image and printed ruvfann-c5 PASS cases=1089 margin_q10=128 cap_q10=768.

Physical timing and CSI packet loss remain to be measured on a C5 board. The emulator duration covers the full self test and is separate from live scoring latency.

@ruvnet

ruvnet commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

Physical ESP32-C5 validation

Ran this branch on real silicon (ESP32-C5 revision v1.2, 48 MHz crystal, 8 MB flash, ROM esp32c5-eco3-20250704).

  • cargo test --locked on the host: 2 tests pass.
  • cargo build --locked --release --features firmware --target riscv32imac-unknown-none-elf with rustc 1.95.0: image is 37,104 bytes.
  • Flashed with espflash 4.3.0 and reset. Boot log ends with:
ruvfann-c5 PASS cases=1089 margin_q10=128 cap_q10=768 self_test_us=1072

MEASURED: all 1,089 self-test cases pass on hardware. The whole loop, including the reference calculation and the assertion for each case, took 1,072 µs, which is under 1 µs per case on average and bounds every single call far below the 1 ms target.

Not covered: the example has no WiFi in it, so "scoring under 1 ms p95 with CSI capture active" and "no measurable increase in CSI packet drops" are still untested. That needs the scorer called from a firmware that is capturing CSI, and stays open as a follow-up.

@ruvnet
ruvnet marked this pull request as ready for review November 10, 2026 19:48
@ruvnet
ruvnet merged commit 83f4f8b into main Nov 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant