Skip to content

perf(deploy): replace esptool subprocess with espflash native crate #66

@zackees

Description

@zackees

Split out from #18 item 5.

Problem

verify-flash and write-flash currently shell out to Python esptool. Cost breakdown for verifying a 2.4 MB ESP32-S3 image (~5.9 s total):

Phase Estimated cost
Python interpreter startup ~1 s
Subprocess spawn + esptool init ~0.5 s
Connect + reset chip into bootloader ~1 s
SYNC handshake + stub flasher upload ~1 s
Baud rate change ~0.5 s
FLASH_MD5SUM execution (3 regions, 2.4 MB) ~1 s
Cleanup + reset back to app ~0.5 s

Actual MD5 work is ~1 s; the rest is process/Python overhead.

Proposed fix

Use the espflash crate — Rust-native ESP32 flasher protocol maintained by ESP-RS. Exposes SLIP protocol, stub flasher loading, and FLASH_MD5SUM natively.

espflash = { version = "4", default-features = false, features = ["serialport"] }

Reuse the daemon's existing serial port lease instead of spawning a subprocess.

Estimated win

  • First verify in a session: ~5.9 s → ~1.5–2 s
  • Subsequent verifies reusing the loaded stub flasher: <1 s

Effort

Medium. The espflash library API is less stable than the CLI — may need an adapter layer between fbuild's Esp32Deployer and espflash's Flasher type. Worth a spike to confirm feasibility before committing.

Context

Filed during the issue consolidation that closed tracker #18. See #18 for the original framing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions