aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/stm32h7/src
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2022-08-30 13:07:35 +0200
committerUlf Lilleengen <[email protected]>2022-09-02 08:25:36 +0200
commit3ca73144765411994759194a2279b567f4508be5 (patch)
tree7c2466e14eb91321d35f831384c633f9936e8977 /examples/boot/application/stm32h7/src
parent7542505cf903930520773f5b6b5ff239b78a8f9c (diff)
Remove generic const expressions from embassy-boot
* Remove the need for generic const expressions and use buffers provided in the flash config. * Extend embedded-storage traits to simplify generics. * Document all public APIs * Add toplevel README * Expose AlignedBuffer type for convenience. * Update examples
Diffstat (limited to 'examples/boot/application/stm32h7/src')
-rw-r--r--examples/boot/application/stm32h7/src/bin/a.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs
index 0ecf60348..f5a8fdb61 100644
--- a/examples/boot/application/stm32h7/src/bin/a.rs
+++ b/examples/boot/application/stm32h7/src/bin/a.rs
@@ -4,11 +4,11 @@
4 4
5#[cfg(feature = "defmt-rtt")] 5#[cfg(feature = "defmt-rtt")]
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_boot_stm32::FirmwareUpdater; 7use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater};
8use embassy_embedded_hal::adapter::BlockingAsync; 8use embassy_embedded_hal::adapter::BlockingAsync;
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_stm32::exti::ExtiInput; 10use embassy_stm32::exti::ExtiInput;
11use embassy_stm32::flash::Flash; 11use embassy_stm32::flash::{Flash, WRITE_SIZE};
12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 12use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
13use panic_reset as _; 13use panic_reset as _;
14 14
@@ -29,13 +29,17 @@ async fn main(_spawner: Spawner) {
29 let mut updater = FirmwareUpdater::default(); 29 let mut updater = FirmwareUpdater::default();
30 button.wait_for_rising_edge().await; 30 button.wait_for_rising_edge().await;
31 let mut offset = 0; 31 let mut offset = 0;
32 let mut buf: [u8; 128 * 1024] = [0; 128 * 1024]; 32 let mut buf = AlignedBuffer([0; 128 * 1024]);
33 for chunk in APP_B.chunks(128 * 1024) { 33 for chunk in APP_B.chunks(128 * 1024) {
34 buf[..chunk.len()].copy_from_slice(chunk); 34 buf.as_mut()[..chunk.len()].copy_from_slice(chunk);
35 updater.write_firmware(offset, &buf, &mut flash, 2048).await.unwrap(); 35 updater
36 .write_firmware(offset, buf.as_ref(), &mut flash, 2048)
37 .await
38 .unwrap();
36 offset += chunk.len(); 39 offset += chunk.len();
37 } 40 }
38 updater.update(&mut flash).await.unwrap(); 41 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
42 updater.mark_updated(&mut flash, magic.as_mut()).await.unwrap();
39 led.set_low(); 43 led.set_low();
40 cortex_m::peripheral::SCB::sys_reset(); 44 cortex_m::peripheral::SCB::sys_reset();
41} 45}