eculocate

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 3b66428e93cf1818da661935eb6fb5a91346b298
parent 68a564d3eb201f1b912b229a9fc381335d2223b3
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 20 Jan 2026 18:53:21 +0000

skip writing unchanged data

This makes less difference than I'd hoped as so little of the data
is unchanged. Perhaps there's some way to persuade the linker to
place libraries first and the app code later in the image

Diffstat:
Mvendor/esp-hal-ota/src/lib.rs | 28++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/vendor/esp-hal-ota/src/lib.rs b/vendor/esp-hal-ota/src/lib.rs @@ -193,15 +193,27 @@ where let write_size = chunk.len() as u32; let write_size = write_size.min(progress.remaining) as usize; - self.flash - .write(progress.flash_offset, &chunk[..write_size]) - .map_err(|_| OtaError::FlashRWError)?; - - debug!( - "[OTA] Wrote {} bytes to ota partition at 0x{:x}", - write_size, progress.flash_offset - ); + let unchanged = + write_size <= 8192 && { + let mut old_data = [0u8; 8192]; + let p = &mut old_data[..write_size]; + _ = self.flash.read(progress.flash_offset, p); + p == &chunk[..write_size] + }; + + if unchanged { + debug!("[OTA] skip writing {} unchanged bytes at 0z:{:x}", + write_size, progress.flash_offset); + } else { + self.flash + .write(progress.flash_offset, &chunk[..write_size]) + .map_err(|_| OtaError::FlashRWError)?; + debug!( + "[OTA] Wrote {} bytes to ota partition at 0x{:x}", + write_size, progress.flash_offset + ); + } progress.last_crc = crc32::calc_crc32(&chunk[..write_size], progress.last_crc); progress.flash_offset += write_size as u32;