Skip to content

perf(deploy): sector-selective write-flash on verify mismatch #67

@zackees

Description

@zackees

Split out from #18 item 6 — now unblocked since item 1 (ledger removal, PR #62) is merged.

Problem

When verify-flash reports a mismatch, the daemon currently falls through to write-flash and writes all three regions (bootloader + partitions + firmware), even if only one differs. For the common case "only firmware changed", ~1 s is wasted rewriting bootloader.bin and partitions.bin.

Proposed fix

Parse the verify-flash output (or run three separate verify calls with --diff) to determine which regions matched, then call write-flash with only the offset/file pairs for the mismatched regions. Saves ~1 s on the typical firmware-only deploy.

Flow: device tells us what differs → we write only what differs → device verifies the write.

Implementation notes

  • try_verify_deployment in crates/fbuild-deploy/src/esp32.rs already runs a single verify-flash covering all three regions; extend its VerifyOutcome::Mismatch variant with per-region diff info, or parse the esptool stdout for "Verification OK"/"Verification failed" lines per region.
  • Add a write_regions(regions: &[(offset, path)]) method on Esp32Deployer that builds a write-flash argv with only the specified offset/file pairs.
  • Keep a fallback to full write-flash when parsing fails — never block a deploy on parser output.

Dependency

Closed by the espflash native migration if that lands first, since espflash exposes per-region write natively. Otherwise, esptool stdout parsing is the route.

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

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions