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.
This commit is contained in:
Ulf Lilleengen
2023-06-19 23:30:51 +02:00
parent 76659d9003
commit 161d3ce05c
19 changed files with 88 additions and 36 deletions

View File

@ -16,6 +16,7 @@ defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.4", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
embedded-storage = "0.3.0"
cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
cortex-m-rt = "0.7.0"
@ -26,3 +27,4 @@ defmt = [
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]
skip-include = []

View File

@ -2,6 +2,8 @@
#![no_main]
#![feature(type_alias_impl_trait)]
use core::cell::RefCell;
#[cfg(feature = "defmt-rtt")]
use defmt_rtt::*;
use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig};
@ -9,8 +11,13 @@ use embassy_executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::flash::{Flash, WRITE_SIZE};
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_sync::blocking_mutex::Mutex;
use embedded_storage::nor_flash::NorFlash;
use panic_reset as _;
#[cfg(feature = "skip-include")]
static APP_B: &[u8] = &[0, 1, 2, 3];
#[cfg(not(feature = "skip-include"))]
static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
@ -26,17 +33,17 @@ async fn main(_spawner: Spawner) {
led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = BlockingFirmwareUpdater::new(config);
let mut writer = updater.prepare_update().unwrap();
let writer = updater.prepare_update(magic.as_mut()).unwrap();
button.wait_for_rising_edge().await;
let mut offset = 0;
let mut buf = AlignedBuffer([0; 4096]);
for chunk in APP_B.chunks(4096) {
buf.as_mut()[..chunk.len()].copy_from_slice(chunk);
writer.write(offset, buf.as_ref()).unwrap();
offset += chunk.len();
offset += chunk.len() as u32;
}
let mut magic = AlignedBuffer([0; WRITE_SIZE]);
updater.mark_updated(magic.as_mut()).unwrap();
led.set_low();
cortex_m::peripheral::SCB::sys_reset();