Skip to content

Commit 6bd7379

Browse files
DirbaioSergioGasquez
authored andcommitted
flasher: add write_bins_to_flash.
1 parent 3051241 commit 6bd7379

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

espflash/src/flasher/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,16 +825,26 @@ impl Flasher {
825825
&mut self,
826826
addr: u32,
827827
data: &[u8],
828-
mut progress: Option<&mut dyn ProgressCallbacks>,
828+
progress: Option<&mut dyn ProgressCallbacks>,
829829
) -> Result<(), Error> {
830830
let segment = RomSegment {
831831
addr,
832832
data: Cow::from(data),
833833
};
834+
self.write_bins_to_flash(&[segment], progress)
835+
}
834836

837+
/// Load multiple bin images to flash at specific addresses
838+
pub fn write_bins_to_flash(
839+
&mut self,
840+
segments: &[RomSegment],
841+
mut progress: Option<&mut dyn ProgressCallbacks>,
842+
) -> Result<(), Error> {
835843
let mut target = self.chip.flash_target(self.spi_params, self.use_stub);
836844
target.begin(&mut self.connection).flashing()?;
837-
target.write_segment(&mut self.connection, segment, &mut progress)?;
845+
for segment in segments {
846+
target.write_segment(&mut self.connection, segment.borrow(), &mut progress)?;
847+
}
838848
target.finish(&mut self.connection, true).flashing()?;
839849

840850
Ok(())

0 commit comments

Comments
 (0)