Refactor firmware updater

* Allow manipulating state without accessing DFU partition.
* Provide aligned buffer when creating updater to reduce potential wrong parameters passed.
This commit is contained in:
Ulf Lilleengen
2023-08-03 20:56:04 +02:00
parent a40daa923b
commit a34331ae5f
16 changed files with 307 additions and 255 deletions

View File

@ -34,8 +34,8 @@ async fn main(_spawner: Spawner) {
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = BlockingFirmwareUpdater::new(config);
let writer = updater.prepare_update(magic.as_mut()).unwrap();
let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0);
let writer = updater.prepare_update().unwrap();
button.wait_for_rising_edge().await;
let mut offset = 0;
let mut buf = AlignedBuffer([0; 4096]);
@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) {
writer.write(offset, buf.as_ref()).unwrap();
offset += chunk.len() as u32;
}
updater.mark_updated(magic.as_mut()).unwrap();
updater.mark_updated().unwrap();
led.set_low();
cortex_m::peripheral::SCB::sys_reset();
}