diff options
| author | Ulf Lilleengen <[email protected]> | 2022-08-30 13:07:35 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-09-02 08:25:36 +0200 |
| commit | 3ca73144765411994759194a2279b567f4508be5 (patch) | |
| tree | 7c2466e14eb91321d35f831384c633f9936e8977 /examples/boot/application/stm32h7/src/bin | |
| parent | 7542505cf903930520773f5b6b5ff239b78a8f9c (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/bin')
| -rw-r--r-- | examples/boot/application/stm32h7/src/bin/a.rs | 16 |
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")] |
| 6 | use defmt_rtt::*; | 6 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::FirmwareUpdater; | 7 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater}; |
| 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; |
| 11 | use embassy_stm32::flash::Flash; | 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 13 | use panic_reset as _; | 13 | use 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 | } |
