diff options
| author | Ulf Lilleengen <[email protected]> | 2023-08-03 20:56:04 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2023-08-06 19:46:53 +0200 |
| commit | a34331ae5fbf76a61bb2f65dbb13af4d34fcb176 (patch) | |
| tree | eddfa2b200b206923a91b9aae1474156c04e40fa /examples/boot/application/stm32l4/src | |
| parent | a40daa923ba031b543ce402f8bd83c2ec41329d8 (diff) | |
Refactor firmware updater
* Allow manipulating state without accessing DFU partition.
* Provide aligned buffer when creating updater to reduce potential wrong parameters passed.
Diffstat (limited to 'examples/boot/application/stm32l4/src')
| -rw-r--r-- | examples/boot/application/stm32l4/src/bin/a.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index a514ab5be..eefa25f75 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs | |||
| @@ -31,17 +31,17 @@ async fn main(_spawner: Spawner) { | |||
| 31 | led.set_high(); | 31 | led.set_high(); |
| 32 | 32 | ||
| 33 | let config = FirmwareUpdaterConfig::from_linkerfile(&flash); | 33 | let config = FirmwareUpdaterConfig::from_linkerfile(&flash); |
| 34 | let mut updater = FirmwareUpdater::new(config); | ||
| 35 | button.wait_for_falling_edge().await; | ||
| 36 | let mut magic = AlignedBuffer([0; WRITE_SIZE]); | 34 | let mut magic = AlignedBuffer([0; WRITE_SIZE]); |
| 35 | let mut updater = FirmwareUpdater::new(config, &mut magic.0); | ||
| 36 | button.wait_for_falling_edge().await; | ||
| 37 | let mut offset = 0; | 37 | let mut offset = 0; |
| 38 | for chunk in APP_B.chunks(2048) { | 38 | for chunk in APP_B.chunks(2048) { |
| 39 | let mut buf: [u8; 2048] = [0; 2048]; | 39 | let mut buf: [u8; 2048] = [0; 2048]; |
| 40 | buf[..chunk.len()].copy_from_slice(chunk); | 40 | buf[..chunk.len()].copy_from_slice(chunk); |
| 41 | updater.write_firmware(magic.as_mut(), offset, &buf).await.unwrap(); | 41 | updater.write_firmware(offset, &buf).await.unwrap(); |
| 42 | offset += chunk.len(); | 42 | offset += chunk.len(); |
| 43 | } | 43 | } |
| 44 | updater.mark_updated(magic.as_mut()).await.unwrap(); | 44 | updater.mark_updated().await.unwrap(); |
| 45 | led.set_low(); | 45 | led.set_low(); |
| 46 | cortex_m::peripheral::SCB::sys_reset(); | 46 | cortex_m::peripheral::SCB::sys_reset(); |
| 47 | } | 47 | } |
