erase once. write multiple

This commit is contained in:
Max Känner 2023-12-21 17:38:54 +01:00
parent 87c03037e3
commit ab18ba6d90

View File

@ -184,10 +184,12 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> BlockingFirmwareUpdater<'d, DFU, STATE>
///
/// Failing to meet alignment and size requirements may result in a panic.
pub fn write_firmware(&mut self, offset: usize, data: &[u8]) -> Result<(), FirmwareUpdaterError> {
assert!(data.len() >= DFU::ERASE_SIZE);
//assert!(data.len() >= DFU::ERASE_SIZE);
self.state.verify_booted()?;
self.dfu.erase(offset as u32, (offset + data.len()) as u32)?;
if offset == 0 {
self.dfu.erase(offset as u32, (offset + DFU::ERASE_SIZE) as u32)?;
}
self.dfu.write(offset as u32, data)?;