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/stm32l1/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/stm32l1/src/bin')
| -rw-r--r-- | examples/boot/application/stm32l1/src/bin/a.rs | 8 |
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; | |||
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 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 embassy_sync::mutex::Mutex; | ||
| 13 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 14 | use panic_reset as _; | 15 | use panic_reset as _; |
| 15 | 16 | ||
| 17 | #[cfg(feature = "skip-include")] | ||
| 18 | static APP_B: &[u8] = &[0, 1, 2, 3]; | ||
| 19 | #[cfg(not(feature = "skip-include"))] | ||
| 16 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | 20 | static 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; |
