aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/stm32l4/src/bin
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/stm32l4/src/bin
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/stm32l4/src/bin')
-rw-r--r--examples/boot/application/stm32l4/src/bin/a.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs
index 54579e4ac..a514ab5be 100644
--- a/examples/boot/application/stm32l4/src/bin/a.rs
+++ b/examples/boot/application/stm32l4/src/bin/a.rs
@@ -10,8 +10,12 @@ use embassy_executor::Spawner;
10use embassy_stm32::exti::ExtiInput; 10use embassy_stm32::exti::ExtiInput;
11use embassy_stm32::flash::{Flash, WRITE_SIZE}; 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 embassy_sync::mutex::Mutex;
13use panic_reset as _; 14use panic_reset as _;
14 15
16#[cfg(feature = "skip-include")]
17static APP_B: &[u8] = &[0, 1, 2, 3];
18#[cfg(not(feature = "skip-include"))]
15static APP_B: &[u8] = include_bytes!("../../b.bin"); 19static APP_B: &[u8] = include_bytes!("../../b.bin");
16 20
17#[embassy_executor::main] 21#[embassy_executor::main]
@@ -29,15 +33,15 @@ async fn main(_spawner: Spawner) {
29 let config = FirmwareUpdaterConfig::from_linkerfile(&flash); 33 let config = FirmwareUpdaterConfig::from_linkerfile(&flash);
30 let mut updater = FirmwareUpdater::new(config); 34 let mut updater = FirmwareUpdater::new(config);
31 button.wait_for_falling_edge().await; 35 button.wait_for_falling_edge().await;
36 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
32 let mut offset = 0; 37 let mut offset = 0;
33 for chunk in APP_B.chunks(2048) { 38 for chunk in APP_B.chunks(2048) {
34 let mut buf: [u8; 2048] = [0; 2048]; 39 let mut buf: [u8; 2048] = [0; 2048];
35 buf[..chunk.len()].copy_from_slice(chunk); 40 buf[..chunk.len()].copy_from_slice(chunk);
36 updater.write_firmware(offset, &buf).await.unwrap(); 41 updater.write_firmware(magic.as_mut(), offset, &buf).await.unwrap();
37 offset += chunk.len(); 42 offset += chunk.len();
38 } 43 }
39 let mut magic = AlignedBuffer([0; WRITE_SIZE]); 44 updater.mark_updated(magic.as_mut()).await.unwrap();
40 updater.mark_updated(&mut flash, magic.as_mut()).await.unwrap();
41 led.set_low(); 45 led.set_low();
42 cortex_m::peripheral::SCB::sys_reset(); 46 cortex_m::peripheral::SCB::sys_reset();
43} 47}