From 6bd7379d960be1db0974c58234fc717d2a92bc11 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 9 Nov 2023 21:37:53 +0100 Subject: [PATCH] flasher: add write_bins_to_flash. --- espflash/src/flasher/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/espflash/src/flasher/mod.rs b/espflash/src/flasher/mod.rs index f918ae77..67cc98c9 100644 --- a/espflash/src/flasher/mod.rs +++ b/espflash/src/flasher/mod.rs @@ -825,16 +825,26 @@ impl Flasher { &mut self, addr: u32, data: &[u8], - mut progress: Option<&mut dyn ProgressCallbacks>, + progress: Option<&mut dyn ProgressCallbacks>, ) -> Result<(), Error> { let segment = RomSegment { addr, data: Cow::from(data), }; + self.write_bins_to_flash(&[segment], progress) + } + /// Load multiple bin images to flash at specific addresses + pub fn write_bins_to_flash( + &mut self, + segments: &[RomSegment], + mut progress: Option<&mut dyn ProgressCallbacks>, + ) -> Result<(), Error> { let mut target = self.chip.flash_target(self.spi_params, self.use_stub); target.begin(&mut self.connection).flashing()?; - target.write_segment(&mut self.connection, segment, &mut progress)?; + for segment in segments { + target.write_segment(&mut self.connection, segment.borrow(), &mut progress)?; + } target.finish(&mut self.connection, true).flashing()?; Ok(())