diff options
| author | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-30 14:03:31 +0200 |
|---|---|---|
| committer | Rasmus Melchior Jacobsen <[email protected]> | 2023-05-30 14:03:31 +0200 |
| commit | 36e00caf4dc70905b735531c0d5634addd026954 (patch) | |
| tree | 01d3bbb3b7f1ab522f9a1fc651f48197ce355927 /examples/boot/application/stm32l4/src/bin/a.rs | |
| parent | c2aca45b8d3785007da20ce007d6a6e352fac1a0 (diff) | |
Align examples
Diffstat (limited to 'examples/boot/application/stm32l4/src/bin/a.rs')
| -rw-r--r-- | examples/boot/application/stm32l4/src/bin/a.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index 141d82afd..54579e4ac 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #[cfg(feature = "defmt-rtt")] | 5 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater}; | 7 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 8 | use embassy_embedded_hal::adapter::BlockingAsync; | 8 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| @@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::new_blocking(p.FLASH); | 20 | let flash = Flash::new_blocking(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PC13, Pull::Up); | 23 | let button = Input::new(p.PC13, Pull::Up); |
| 24 | let mut button = ExtiInput::new(button, p.EXTI13); | 24 | let mut button = ExtiInput::new(button, p.EXTI13); |
| @@ -26,13 +26,14 @@ async fn main(_spawner: Spawner) { | |||
| 26 | let mut led = Output::new(p.PB14, Level::Low, Speed::Low); | 26 | let mut led = Output::new(p.PB14, Level::Low, Speed::Low); |
| 27 | led.set_high(); | 27 | led.set_high(); |
| 28 | 28 | ||
| 29 | let mut updater = FirmwareUpdater::default(); | 29 | let config = FirmwareUpdaterConfig::from_linkerfile(&flash); |
| 30 | let mut updater = FirmwareUpdater::new(config); | ||
| 30 | button.wait_for_falling_edge().await; | 31 | button.wait_for_falling_edge().await; |
| 31 | let mut offset = 0; | 32 | let mut offset = 0; |
| 32 | for chunk in APP_B.chunks(2048) { | 33 | for chunk in APP_B.chunks(2048) { |
| 33 | let mut buf: [u8; 2048] = [0; 2048]; | 34 | let mut buf: [u8; 2048] = [0; 2048]; |
| 34 | buf[..chunk.len()].copy_from_slice(chunk); | 35 | buf[..chunk.len()].copy_from_slice(chunk); |
| 35 | updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); | 36 | updater.write_firmware(offset, &buf).await.unwrap(); |
| 36 | offset += chunk.len(); | 37 | offset += chunk.len(); |
| 37 | } | 38 | } |
| 38 | let mut magic = AlignedBuffer([0; WRITE_SIZE]); | 39 | let mut magic = AlignedBuffer([0; WRITE_SIZE]); |
