aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/stm32h7/src/bin/a.rs
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2023-06-19 23:30:51 +0200
committerUlf Lilleengen <[email protected]>2023-06-19 23:34:07 +0200
commit161d3ce05c812f7ee951b6265735187b4994037a (patch)
treec9e82c062ac089cf37cc175810a8a2041bddea0e /examples/boot/application/stm32h7/src/bin/a.rs
parent76659d9003104f8edd2472a36149565e4a55c0e6 (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/stm32h7/src/bin/a.rs')
-rw-r--r--examples/boot/application/stm32h7/src/bin/a.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs
index 1a54464d0..719176692 100644
--- a/examples/boot/application/stm32h7/src/bin/a.rs
+++ b/examples/boot/application/stm32h7/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
5use core::cell::RefCell;
6
5#[cfg(feature = "defmt-rtt")] 7#[cfg(feature = "defmt-rtt")]
6use defmt_rtt::*; 8use defmt_rtt::*;
7use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; 9use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig};
@@ -9,8 +11,13 @@ use embassy_executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 11use embassy_stm32::exti::ExtiInput;
10use embassy_stm32::flash::{Flash, WRITE_SIZE}; 12use embassy_stm32::flash::{Flash, WRITE_SIZE};
11use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 13use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
14use embassy_sync::blocking_mutex::Mutex;
15use embedded_storage::nor_flash::NorFlash;
12use panic_reset as _; 16use panic_reset as _;
13 17
18#[cfg(feature = "skip-include")]
19static APP_B: &[u8] = &[0, 1, 2, 3];
20#[cfg(not(feature = "skip-include"))]
14static APP_B: &[u8] = include_bytes!("../../b.bin"); 21static APP_B: &[u8] = include_bytes!("../../b.bin");
15 22
16#[embassy_executor::main] 23#[embassy_executor::main]
@@ -26,17 +33,17 @@ async fn main(_spawner: Spawner) {
26 led.set_high(); 33 led.set_high();
27 34
28 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); 35 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
36 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
29 let mut updater = BlockingFirmwareUpdater::new(config); 37 let mut updater = BlockingFirmwareUpdater::new(config);
30 let mut writer = updater.prepare_update().unwrap(); 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();