feat(usb-dfu): change usb dfu chunks write mechanism
This commit is contained in:
parent
2e8b7d2590
commit
c95bf6895a
1 changed files with 16 additions and 1 deletions
|
@ -60,6 +60,21 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Ha
|
|||
}
|
||||
Ok(Request::Dnload) if self.attrs.contains(DfuAttributes::CAN_DOWNLOAD) => {
|
||||
if req.value == 0 {
|
||||
match self.updater.prepare_update() {
|
||||
Ok(_) => {
|
||||
self.status = Status::Ok;
|
||||
}
|
||||
Err(e) => {
|
||||
self.state = State::Error;
|
||||
match e {
|
||||
embassy_boot::FirmwareUpdaterError::Flash(e) => match e {
|
||||
NorFlashErrorKind::NotAligned => self.status = Status::ErrErase,
|
||||
_ => self.status = Status::ErrUnknown,
|
||||
},
|
||||
_ => self.status = Status::ErrUnknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
self.state = State::Download;
|
||||
self.offset = 0;
|
||||
}
|
||||
|
@ -93,7 +108,7 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Ha
|
|||
self.state = State::Error;
|
||||
return Some(OutResponse::Rejected);
|
||||
}
|
||||
match self.updater.write_firmware(self.offset, buf.as_ref()) {
|
||||
match self.updater.write_firmware_without_erase(self.offset, buf.as_ref()) {
|
||||
Ok(_) => {
|
||||
self.status = Status::Ok;
|
||||
self.state = State::DlSync;
|
||||
|
|
Loading…
Reference in a new issue