diff options
| author | Ulf Lilleengen <[email protected]> | 2023-06-19 23:30:51 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2023-06-19 23:34:07 +0200 |
| commit | 161d3ce05c812f7ee951b6265735187b4994037a (patch) | |
| tree | c9e82c062ac089cf37cc175810a8a2041bddea0e /examples/boot/application/stm32f7/src/bin | |
| parent | 76659d9003104f8edd2472a36149565e4a55c0e6 (diff) | |
Add firmware updater examples to CI
CI was not building the a.rs application due to the requirement of b.bin
having been built first. Add a feature flag to examples so that CI can
build them including a dummy application.
Update a.rs application examples so that they compile again.
Diffstat (limited to 'examples/boot/application/stm32f7/src/bin')
| -rw-r--r-- | examples/boot/application/stm32f7/src/bin/a.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index fc2702c91..dea682a96 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use core::cell::RefCell; | ||
| 6 | |||
| 5 | #[cfg(feature = "defmt-rtt")] | 7 | #[cfg(feature = "defmt-rtt")] |
| 6 | use defmt_rtt::*; | 8 | use defmt_rtt::*; |
| 7 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; | 9 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; |
| @@ -9,8 +11,13 @@ use embassy_executor::Spawner; | |||
| 9 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 12 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 13 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 14 | use embassy_sync::blocking_mutex::Mutex; | ||
| 15 | use embedded_storage::nor_flash::NorFlash; | ||
| 12 | use panic_reset as _; | 16 | use panic_reset as _; |
| 13 | 17 | ||
| 18 | #[cfg(feature = "skip-include")] | ||
| 19 | static APP_B: &[u8] = &[0, 1, 2, 3]; | ||
| 20 | #[cfg(not(feature = "skip-include"))] | ||
| 14 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 21 | static APP_B: &[u8] = include_bytes!("../../b.bin"); |
| 15 | 22 | ||
| 16 | #[embassy_executor::main] | 23 | #[embassy_executor::main] |
| @@ -27,16 +34,16 @@ async fn main(_spawner: Spawner) { | |||
| 27 | 34 | ||
| 28 | let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); | 35 | let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); |
| 29 | let mut updater = BlockingFirmwareUpdater::new(config); | 36 | let mut updater = BlockingFirmwareUpdater::new(config); |
| 30 | let mut writer = updater.prepare_update().unwrap(); | 37 | let mut magic = AlignedBuffer([0; WRITE_SIZE]); |
| 38 | let writer = updater.prepare_update(magic.as_mut()).unwrap(); | ||
| 31 | button.wait_for_rising_edge().await; | 39 | button.wait_for_rising_edge().await; |
| 32 | let mut offset = 0; | 40 | let mut offset = 0; |
| 33 | let mut buf = AlignedBuffer([0; 4096]); | 41 | let mut buf = AlignedBuffer([0; 4096]); |
| 34 | for chunk in APP_B.chunks(4096) { | 42 | for chunk in APP_B.chunks(4096) { |
| 35 | buf.as_mut()[..chunk.len()].copy_from_slice(chunk); | 43 | buf.as_mut()[..chunk.len()].copy_from_slice(chunk); |
| 36 | writer.write(offset, buf.as_ref()).unwrap(); | 44 | writer.write(offset, buf.as_ref()).unwrap(); |
| 37 | offset += chunk.len(); | 45 | offset += chunk.len() as u32; |
| 38 | } | 46 | } |
| 39 | let mut magic = AlignedBuffer([0; WRITE_SIZE]); | ||
| 40 | updater.mark_updated(magic.as_mut()).unwrap(); | 47 | updater.mark_updated(magic.as_mut()).unwrap(); |
| 41 | led.set_low(); | 48 | led.set_low(); |
| 42 | cortex_m::peripheral::SCB::sys_reset(); | 49 | cortex_m::peripheral::SCB::sys_reset(); |
