feat: flash phase tracking, erase checkbox, flash_model config

Step 2 UI now shows real-time flash operation phases parsed from program_flash output:
- Erase: "Performing Erase Operation..." → sf erase → Erased: OK
- Program: "Performing Program Operation..." → write blocks 0%→100%
- Verify: "Performing Verify Operation..." → read+cmp 0%→100%

Configuration additions:
- erase_before_program checkbox: controls whether to pre-erase before programming
- flash_model: chip type for capacity reference (s25fl256s1 = 32 MiB)

subprocess_utils.py now emits 'phase' callbacks (erase/program/verify/done)
detected from program_flash output transitions.
This commit is contained in:
Jeremy Shen
2026-06-10 13:39:11 +08:00
parent 2c48224aea
commit ea3e3b8ac7
6 changed files with 101 additions and 17 deletions
+16 -5
View File
@@ -279,7 +279,11 @@ def full_flash_program(
bin_path: str | Path,
callback: ProgressCallback = None,
) -> list[FlashResult]:
"""Execute full flash workflow: wipe → program → verify.
"""Execute full flash workflow: (optional wipe) → program → verify.
If config.erase_before_program is True, erases flash sectors before
programming. Otherwise, program_flash handles sector erase during
programming (per-sector, not full chip).
Args:
config: Application configuration.
@@ -291,10 +295,17 @@ def full_flash_program(
"""
results: list[FlashResult] = []
# Step 1: Erase the entire flash
results.append(wipe_flash(config, callback))
if not results[-1].success:
return results
# Step 1: Erase (optional — controlled by config.erase_before_program)
if getattr(config, 'erase_before_program', True):
results.append(wipe_flash(config, callback))
if not results[-1].success:
return results
else:
results.append(FlashResult(
step="wipe",
success=True,
message="Erase skipped (handled by program_flash)",
))
# Step 2: Program and verify (program_flash -verify)
results.append(program_flash_bin(config, bin_path, callback))