aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/stm32l1/src/bin
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2023-08-03 20:56:04 +0200
committerUlf Lilleengen <[email protected]>2023-08-06 19:46:53 +0200
commita34331ae5fbf76a61bb2f65dbb13af4d34fcb176 (patch)
treeeddfa2b200b206923a91b9aae1474156c04e40fa /examples/boot/application/stm32l1/src/bin
parenta40daa923ba031b543ce402f8bd83c2ec41329d8 (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/stm32l1/src/bin')
-rw-r--r--examples/boot/application/stm32l1/src/bin/a.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs
index 1e9bf3cb9..b4cdcd44d 100644
--- a/examples/boot/application/stm32l1/src/bin/a.rs
+++ b/examples/boot/application/stm32l1/src/bin/a.rs
@@ -33,18 +33,18 @@ async fn main(_spawner: Spawner) {
33 led.set_high(); 33 led.set_high();
34 34
35 let config = FirmwareUpdaterConfig::from_linkerfile(&flash); 35 let config = FirmwareUpdaterConfig::from_linkerfile(&flash);
36 let mut updater = FirmwareUpdater::new(config);
37 button.wait_for_falling_edge().await;
38 let mut magic = AlignedBuffer([0; WRITE_SIZE]); 36 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
37 let mut updater = FirmwareUpdater::new(config, &mut magic.0);
38 button.wait_for_falling_edge().await;
39 let mut offset = 0; 39 let mut offset = 0;
40 for chunk in APP_B.chunks(128) { 40 for chunk in APP_B.chunks(128) {
41 let mut buf: [u8; 128] = [0; 128]; 41 let mut buf: [u8; 128] = [0; 128];
42 buf[..chunk.len()].copy_from_slice(chunk); 42 buf[..chunk.len()].copy_from_slice(chunk);
43 updater.write_firmware(magic.as_mut(), offset, &buf).await.unwrap(); 43 updater.write_firmware(offset, &buf).await.unwrap();
44 offset += chunk.len(); 44 offset += chunk.len();
45 } 45 }
46 46
47 updater.mark_updated(magic.as_mut()).await.unwrap(); 47 updater.mark_updated().await.unwrap();
48 led.set_low(); 48 led.set_low();
49 Timer::after(Duration::from_secs(1)).await; 49 Timer::after(Duration::from_secs(1)).await;
50 cortex_m::peripheral::SCB::sys_reset(); 50 cortex_m::peripheral::SCB::sys_reset();