Skip to content

Harden USB firmware-flash: md5-verify settle/retry, pacing, end-to-end on-device validation #99

Description

@millsmillsymills

Context

Follow-up from #98 (multi-firmware support). The firmware-flash core works — the chunked storage_write transfers data correctly (md5 verified on-device for files up to 1.58 MB) — but the full end-to-end official↔Momentum flash does not yet complete reliably over USB. This issue tracks the robustness hardening needed to make a complete flash reliable, plus the on-device end-to-end validation.

No firmware update was ever executed during validation; every attempt aborted safely before the reboot-into-updater step.

Findings from hardware validation (Momentum mntm-012, USB)

  1. Fixed in Multi-firmware support + firmware-flash tooling #98storage_write timeout floor was 3 s, which failed a 117 KB write whose data had actually transferred (md5 matched). Now flush-aware (max(15, len/40000)).
  2. storage_md5sum returns None immediately after a large write. The device is still flushing to SD; the verify reads None and the installer treats it as a mismatch and aborts. The same 1.58 MB file md5-matched once the device had settled. Evidence:
    • 768 KB write → md5 matched.
    • 1.0 MB and 1.58 MB writes → write_ok=True but immediate storage_md5sum returned None; a later read of the same file returned the correct hash.
  3. RPC session can wedge after aggressive back-to-back large writesstart_rpc_session negotiation fails, get_device_info returns empty, SD reads unavailable. Recovered only by a physical power-cycle. Suggests the post-write/inter-command sequence needs settle/drain and possibly host-side pacing.

Proposed work

  • In the installer's per-file verify, add a short settle delay + bounded storage_md5sum retry (treat None as "not ready, retry" rather than "mismatch"). Distinguish a real digest mismatch from an unreadable digest.
  • Investigate host-side pacing / inter-chunk drain in (or around) storage_write for multi-MB files to avoid the session wedge; consider a brief settle between files in install_bundle.
  • Consider a session-health check / re-sync (drain + re-start_rpc_session) between large operations, and surface a clear recovery message (power-cycle / DFU) if the session wedges mid-flash.
  • On-device end-to-end validation: real flipperzero_firmware_install official→capture official golden fixtures→back to Momentum (Task 12/13 from the plan), then the integration+usb flash round-trip test.
  • Reorganize golden fixtures to tests/golden/fixtures/{momentum,official}/ and parametrize the golden suite (depends on the official capture above).
  • Clean up leftover /ext/update/diag and /ext/update/mcp-update folders left on the test device's SD card.

Notes

  • The per-file md5 verify means a failed/corrupted push aborts before any reboot, so this is a reliability problem, not a bricking risk.
  • Diagnosis scripts used during validation were ad-hoc (/tmp), not committed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions