From 1420bbcc744ad6049d5535f3780c635d8f685076 Mon Sep 17 00:00:00 2001 From: Mae PUGIN <48982737+mornepousse@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:38:29 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20Flasher=20otadata=20erase=20timeout=20?= =?UTF-8?q?=E2=80=94=20skip=20flash=5Fend=20between=20sequences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ROM accepts consecutive flash_begin calls without an intervening flash_end, so we no longer end+re-sync between the firmware write and the otadata erase. Single flash_end after both sequences. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/protocol/flasher.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/protocol/flasher.rs b/src/protocol/flasher.rs index 606902c..5454e16 100644 --- a/src/protocol/flasher.rs +++ b/src/protocol/flasher.rs @@ -643,23 +643,17 @@ pub fn flash_firmware( } // ------------------------------------------------------------------ // - // Step 8: FLASH_END // - // // - // We pass reboot=false here so the chip stays in bootloader mode for // - // the MD5 verification step that follows. A hard reset is done after. // - // ------------------------------------------------------------------ // - send_progress(0.92, "Finalizing write...".into()); - flash_end(&mut port, false)?; - - // ------------------------------------------------------------------ // - // Step 8b: Erase otadata partition (0xF000, 8KB) when flashing factory // + // Step 8: Erase otadata when flashing factory // // // // If we just wrote to the factory partition, the bootloader might // // still have otadata pointing to ota_0. We erase otadata to force // // the bootloader to fall back to factory on next boot. // + // // + // The ROM accepts consecutive flash_begin calls without flash_end in // + // between — no need to end+re-sync between the two flash sequences. // // ------------------------------------------------------------------ // if offset == 0x20000 { - send_progress(0.93, "Erasing otadata (force factory boot)...".into()); + send_progress(0.92, "Erasing otadata (force factory boot)...".into()); const OTADATA_OFFSET: u32 = 0xF000; const OTADATA_SIZE: u32 = 0x2000; // 8 KB flash_begin(&mut port, OTADATA_OFFSET, OTADATA_SIZE, FLASH_BLOCK_SIZE)?; @@ -668,9 +662,14 @@ pub fn flash_firmware( for i in 0..otadata_blocks { flash_data(&mut port, i, &empty_block)?; } - flash_end(&mut port, false)?; } + // ------------------------------------------------------------------ // + // Step 9: FLASH_END — stay in bootloader for MD5 verification // + // ------------------------------------------------------------------ // + send_progress(0.93, "Finalizing write...".into()); + flash_end(&mut port, false)?; + // ------------------------------------------------------------------ // // Step 9: MD5 post-write verification // // //