Skip to content

Commit

Permalink
flasher: add write_bins_to_flash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio authored and SergioGasquez committed Nov 10, 2023
1 parent 3051241 commit 6bd7379
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions espflash/src/flasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 6bd7379

Please sign in to comment.