aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/stm32l1/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/stm32l1/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/stm32l1/src/bin')
-rw-r--r--examples/boot/application/stm32l1/src/bin/a.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs
index 00ddda636..1e9bf3cb9 100644
--- a/examples/boot/application/stm32l1/src/bin/a.rs
+++ b/examples/boot/application/stm32l1/src/bin/a.rs
@@ -10,9 +10,13 @@ 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 embassy_time::{Duration, Timer}; 14use embassy_time::{Duration, Timer};
14use panic_reset as _; 15use panic_reset as _;
15 16
17#[cfg(feature = "skip-include")]
18static APP_B: &[u8] = &[0, 1, 2, 3];
19#[cfg(not(feature = "skip-include"))]
16static APP_B: &[u8] = include_bytes!("../../b.bin"); 20static APP_B: &[u8] = include_bytes!("../../b.bin");
17 21
18#[embassy_executor::main] 22#[embassy_executor::main]
@@ -31,15 +35,15 @@ async fn main(_spawner: Spawner) {
31 let config = FirmwareUpdaterConfig::from_linkerfile(&flash); 35 let config = FirmwareUpdaterConfig::from_linkerfile(&flash);
32 let mut updater = FirmwareUpdater::new(config); 36 let mut updater = FirmwareUpdater::new(config);
33 button.wait_for_falling_edge().await; 37 button.wait_for_falling_edge().await;
38 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
34 let mut offset = 0; 39 let mut offset = 0;
35 for chunk in APP_B.chunks(128) { 40 for chunk in APP_B.chunks(128) {
36 let mut buf: [u8; 128] = [0; 128]; 41 let mut buf: [u8; 128] = [0; 128];
37 buf[..chunk.len()].copy_from_slice(chunk); 42 buf[..chunk.len()].copy_from_slice(chunk);
38 updater.write_firmware(offset, &buf).await.unwrap(); 43 updater.write_firmware(magic.as_mut(), offset, &buf).await.unwrap();
39 offset += chunk.len(); 44 offset += chunk.len();
40 } 45 }
41 46
42 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
43 updater.mark_updated(magic.as_mut()).await.unwrap(); 47 updater.mark_updated(magic.as_mut()).await.unwrap();
44 led.set_low(); 48 led.set_low();
45 Timer::after(Duration::from_secs(1)).await; 49 Timer::after(Duration::from_secs(1)).await;