aboutsummaryrefslogtreecommitdiff
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
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.
-rwxr-xr-xci.sh20
-rw-r--r--examples/boot/application/nrf/Cargo.toml1
-rw-r--r--examples/boot/application/nrf/src/bin/a.rs7
-rw-r--r--examples/boot/application/rp/Cargo.toml1
-rw-r--r--examples/boot/application/rp/src/bin/a.rs6
-rw-r--r--examples/boot/application/stm32f3/Cargo.toml1
-rw-r--r--examples/boot/application/stm32f3/src/bin/a.rs7
-rw-r--r--examples/boot/application/stm32f7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32f7/src/bin/a.rs13
-rw-r--r--examples/boot/application/stm32h7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32h7/src/bin/a.rs13
-rw-r--r--examples/boot/application/stm32l0/Cargo.toml1
-rw-r--r--examples/boot/application/stm32l0/src/bin/a.rs17
-rw-r--r--examples/boot/application/stm32l1/Cargo.toml1
-rw-r--r--examples/boot/application/stm32l1/src/bin/a.rs8
-rw-r--r--examples/boot/application/stm32l4/Cargo.toml1
-rw-r--r--examples/boot/application/stm32l4/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32wl/Cargo.toml1
-rw-r--r--examples/boot/application/stm32wl/src/bin/a.rs12
19 files changed, 88 insertions, 36 deletions
diff --git a/ci.sh b/ci.sh
index 760d6fbfb..3fe1b1ce8 100755
--- a/ci.sh
+++ b/ci.sh
@@ -133,16 +133,16 @@ cargo batch \
133 --- build --release --manifest-path examples/stm32u5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32u5 \ 133 --- build --release --manifest-path examples/stm32u5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32u5 \
134 --- build --release --manifest-path examples/stm32wb/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb \ 134 --- build --release --manifest-path examples/stm32wb/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb \
135 --- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl \ 135 --- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl \
136 --- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 --out-dir out/examples/boot/nrf --bin b \ 136 --- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840,skip-include --out-dir out/examples/boot/nrf \
137 --- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns --out-dir out/examples/boot/nrf --bin b \ 137 --- build --release --manifest-path examples/boot/application/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns,skip-include --out-dir out/examples/boot/nrf \
138 --- build --release --manifest-path examples/boot/application/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/boot/rp --bin b \ 138 --- build --release --manifest-path examples/boot/application/rp/Cargo.toml --target thumbv6m-none-eabi --features skip-include --out-dir out/examples/boot/rp \
139 --- build --release --manifest-path examples/boot/application/stm32f3/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/boot/stm32f3 --bin b \ 139 --- build --release --manifest-path examples/boot/application/stm32f3/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32f3 \
140 --- build --release --manifest-path examples/boot/application/stm32f7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/boot/stm32f7 --bin b \ 140 --- build --release --manifest-path examples/boot/application/stm32f7/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32f7 \
141 --- build --release --manifest-path examples/boot/application/stm32h7/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/boot/stm32h7 --bin b \ 141 --- build --release --manifest-path examples/boot/application/stm32h7/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32h7 \
142 --- build --release --manifest-path examples/boot/application/stm32l0/Cargo.toml --target thumbv6m-none-eabi --out-dir out/examples/boot/stm32l0 --bin b \ 142 --- build --release --manifest-path examples/boot/application/stm32l0/Cargo.toml --target thumbv6m-none-eabi --features skip-include --out-dir out/examples/boot/stm32l0 \
143 --- build --release --manifest-path examples/boot/application/stm32l1/Cargo.toml --target thumbv7m-none-eabi --out-dir out/examples/boot/stm32l1 --bin b \ 143 --- build --release --manifest-path examples/boot/application/stm32l1/Cargo.toml --target thumbv7m-none-eabi --features skip-include --out-dir out/examples/boot/stm32l1 \
144 --- build --release --manifest-path examples/boot/application/stm32l4/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/boot/stm32l4 --bin b \ 144 --- build --release --manifest-path examples/boot/application/stm32l4/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32l4 \
145 --- build --release --manifest-path examples/boot/application/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/boot/stm32wl --bin b \ 145 --- build --release --manifest-path examples/boot/application/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --features skip-include --out-dir out/examples/boot/stm32wl \
146 --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ 146 --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
147 --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ 147 --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \
148 --- build --release --manifest-path examples/boot/bootloader/rp/Cargo.toml --target thumbv6m-none-eabi \ 148 --- build --release --manifest-path examples/boot/bootloader/rp/Cargo.toml --target thumbv6m-none-eabi \
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index 5939a43b1..b98f73f39 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -24,3 +24,4 @@ cortex-m-rt = "0.7.0"
24[features] 24[features]
25ed25519-dalek = ["embassy-boot/ed25519-dalek"] 25ed25519-dalek = ["embassy-boot/ed25519-dalek"]
26ed25519-salty = ["embassy-boot/ed25519-salty"] 26ed25519-salty = ["embassy-boot/ed25519-salty"]
27skip-include = []
diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs
index 06c237781..021d77f3b 100644
--- a/examples/boot/application/nrf/src/bin/a.rs
+++ b/examples/boot/application/nrf/src/bin/a.rs
@@ -12,6 +12,9 @@ use embassy_nrf::wdt::{self, Watchdog};
12use embassy_sync::mutex::Mutex; 12use embassy_sync::mutex::Mutex;
13use panic_reset as _; 13use panic_reset as _;
14 14
15#[cfg(feature = "skip-include")]
16static APP_B: &[u8] = &[0, 1, 2, 3];
17#[cfg(not(feature = "skip-include"))]
15static APP_B: &[u8] = include_bytes!("../../b.bin"); 18static APP_B: &[u8] = include_bytes!("../../b.bin");
16 19
17#[embassy_executor::main] 20#[embassy_executor::main]
@@ -55,13 +58,13 @@ async fn main(_spawner: Spawner) {
55 button.wait_for_any_edge().await; 58 button.wait_for_any_edge().await;
56 if button.is_low() { 59 if button.is_low() {
57 let mut offset = 0; 60 let mut offset = 0;
61 let mut magic = [0; 4];
58 for chunk in APP_B.chunks(4096) { 62 for chunk in APP_B.chunks(4096) {
59 let mut buf: [u8; 4096] = [0; 4096]; 63 let mut buf: [u8; 4096] = [0; 4096];
60 buf[..chunk.len()].copy_from_slice(chunk); 64 buf[..chunk.len()].copy_from_slice(chunk);
61 updater.write_firmware(offset, &buf).await.unwrap(); 65 updater.write_firmware(&mut magic, offset, &buf).await.unwrap();
62 offset += chunk.len(); 66 offset += chunk.len();
63 } 67 }
64 let mut magic = [0; 4];
65 updater.mark_updated(&mut magic).await.unwrap(); 68 updater.mark_updated(&mut magic).await.unwrap();
66 led.set_high(); 69 led.set_high();
67 cortex_m::peripheral::SCB::sys_reset(); 70 cortex_m::peripheral::SCB::sys_reset();
diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml
index 4a2c5dd8f..007b6839c 100644
--- a/examples/boot/application/rp/Cargo.toml
+++ b/examples/boot/application/rp/Cargo.toml
@@ -29,6 +29,7 @@ debug = [
29 "embassy-boot-rp/defmt", 29 "embassy-boot-rp/defmt",
30 "panic-probe" 30 "panic-probe"
31] 31]
32skip-include = []
32 33
33[profile.release] 34[profile.release]
34debug = true 35debug = true
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs
index 69850069b..c8497494c 100644
--- a/examples/boot/application/rp/src/bin/a.rs
+++ b/examples/boot/application/rp/src/bin/a.rs
@@ -18,7 +18,11 @@ use panic_probe as _;
18#[cfg(feature = "panic-reset")] 18#[cfg(feature = "panic-reset")]
19use panic_reset as _; 19use panic_reset as _;
20 20
21#[cfg(feature = "skip-include")]
22static APP_B: &[u8] = &[0, 1, 2, 3];
23#[cfg(not(feature = "skip-include"))]
21static APP_B: &[u8] = include_bytes!("../../b.bin"); 24static APP_B: &[u8] = include_bytes!("../../b.bin");
25
22const FLASH_SIZE: usize = 2 * 1024 * 1024; 26const FLASH_SIZE: usize = 2 * 1024 * 1024;
23 27
24#[embassy_executor::main] 28#[embassy_executor::main]
@@ -43,7 +47,7 @@ async fn main(_s: Spawner) {
43 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]); 47 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]);
44 defmt::info!("preparing update"); 48 defmt::info!("preparing update");
45 let writer = updater 49 let writer = updater
46 .prepare_update() 50 .prepare_update(&mut buf.0[..1])
47 .map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e))) 51 .map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e)))
48 .unwrap(); 52 .unwrap();
49 defmt::info!("writer created, starting write"); 53 defmt::info!("writer created, starting write");
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml
index 24abd90d4..5b3faf8f8 100644
--- a/examples/boot/application/stm32f3/Cargo.toml
+++ b/examples/boot/application/stm32f3/Cargo.toml
@@ -26,3 +26,4 @@ defmt = [
26 "embassy-stm32/defmt", 26 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 27 "embassy-boot-stm32/defmt",
28] 28]
29skip-include = []
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs
index c94676f09..c0a11d699 100644
--- a/examples/boot/application/stm32f3/src/bin/a.rs
+++ b/examples/boot/application/stm32f3/src/bin/a.rs
@@ -13,6 +13,9 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
13use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
14use panic_reset as _; 14use panic_reset as _;
15 15
16#[cfg(feature = "skip-include")]
17static APP_B: &[u8] = &[0, 1, 2, 3];
18#[cfg(not(feature = "skip-include"))]
16static APP_B: &[u8] = include_bytes!("../../b.bin"); 19static APP_B: &[u8] = include_bytes!("../../b.bin");
17 20
18#[embassy_executor::main] 21#[embassy_executor::main]
@@ -31,13 +34,13 @@ async fn main(_spawner: Spawner) {
31 let mut updater = FirmwareUpdater::new(config); 34 let mut updater = FirmwareUpdater::new(config);
32 button.wait_for_falling_edge().await; 35 button.wait_for_falling_edge().await;
33 let mut offset = 0; 36 let mut offset = 0;
37 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
34 for chunk in APP_B.chunks(2048) { 38 for chunk in APP_B.chunks(2048) {
35 let mut buf: [u8; 2048] = [0; 2048]; 39 let mut buf: [u8; 2048] = [0; 2048];
36 buf[..chunk.len()].copy_from_slice(chunk); 40 buf[..chunk.len()].copy_from_slice(chunk);
37 updater.write_firmware(offset, &buf).await.unwrap(); 41 updater.write_firmware(magic.as_mut(), offset, &buf).await.unwrap();
38 offset += chunk.len(); 42 offset += chunk.len();
39 } 43 }
40 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
41 updater.mark_updated(magic.as_mut()).await.unwrap(); 44 updater.mark_updated(magic.as_mut()).await.unwrap();
42 led.set_low(); 45 led.set_low();
43 cortex_m::peripheral::SCB::sys_reset(); 46 cortex_m::peripheral::SCB::sys_reset();
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml
index 529a01aad..b6a6f9cd8 100644
--- a/examples/boot/application/stm32f7/Cargo.toml
+++ b/examples/boot/application/stm32f7/Cargo.toml
@@ -16,6 +16,7 @@ defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.4", optional = true } 16defmt-rtt = { version = "0.4", optional = true }
17panic-reset = { version = "0.1.1" } 17panic-reset = { version = "0.1.1" }
18embedded-hal = { version = "0.2.6" } 18embedded-hal = { version = "0.2.6" }
19embedded-storage = "0.3.0"
19 20
20cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 21cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
21cortex-m-rt = "0.7.0" 22cortex-m-rt = "0.7.0"
@@ -26,3 +27,4 @@ defmt = [
26 "embassy-stm32/defmt", 27 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 28 "embassy-boot-stm32/defmt",
28] 29]
30skip-include = []
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs
index fc2702c91..dea682a96 100644
--- a/examples/boot/application/stm32f7/src/bin/a.rs
+++ b/examples/boot/application/stm32f7/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]
@@ -27,16 +34,16 @@ async fn main(_spawner: Spawner) {
27 34
28 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); 35 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
29 let mut updater = BlockingFirmwareUpdater::new(config); 36 let mut updater = BlockingFirmwareUpdater::new(config);
30 let mut writer = updater.prepare_update().unwrap(); 37 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
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();
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml
index d7539a53f..0a7e19b1d 100644
--- a/examples/boot/application/stm32h7/Cargo.toml
+++ b/examples/boot/application/stm32h7/Cargo.toml
@@ -16,6 +16,7 @@ defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.4", optional = true } 16defmt-rtt = { version = "0.4", optional = true }
17panic-reset = { version = "0.1.1" } 17panic-reset = { version = "0.1.1" }
18embedded-hal = { version = "0.2.6" } 18embedded-hal = { version = "0.2.6" }
19embedded-storage = "0.3.0"
19 20
20cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 21cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
21cortex-m-rt = "0.7.0" 22cortex-m-rt = "0.7.0"
@@ -26,3 +27,4 @@ defmt = [
26 "embassy-stm32/defmt", 27 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 28 "embassy-boot-stm32/defmt",
28] 29]
30skip-include = []
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();
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml
index e90da259b..998df4dc0 100644
--- a/examples/boot/application/stm32l0/Cargo.toml
+++ b/examples/boot/application/stm32l0/Cargo.toml
@@ -26,3 +26,4 @@ defmt = [
26 "embassy-stm32/defmt", 26 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 27 "embassy-boot-stm32/defmt",
28] 28]
29skip-include = []
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs
index 4033ac590..ce80056e6 100644
--- a/examples/boot/application/stm32l0/src/bin/a.rs
+++ b/examples/boot/application/stm32l0/src/bin/a.rs
@@ -4,22 +4,26 @@
4 4
5#[cfg(feature = "defmt-rtt")] 5#[cfg(feature = "defmt-rtt")]
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater}; 7use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
8use embassy_embedded_hal::adapter::BlockingAsync; 8use embassy_embedded_hal::adapter::BlockingAsync;
9use embassy_executor::Spawner; 9use 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]
19async fn main(_spawner: Spawner) { 23async fn main(_spawner: Spawner) {
20 let p = embassy_stm32::init(Default::default()); 24 let p = embassy_stm32::init(Default::default());
21 let flash = Flash::new_blocking(p.FLASH); 25 let flash = Flash::new_blocking(p.FLASH);
22 let mut flash = BlockingAsync::new(flash); 26 let flash = Mutex::new(BlockingAsync::new(flash));
23 27
24 let button = Input::new(p.PB2, Pull::Up); 28 let button = Input::new(p.PB2, Pull::Up);
25 let mut button = ExtiInput::new(button, p.EXTI2); 29 let mut button = ExtiInput::new(button, p.EXTI2);
@@ -28,18 +32,19 @@ async fn main(_spawner: Spawner) {
28 32
29 led.set_high(); 33 led.set_high();
30 34
31 let mut updater = FirmwareUpdater::default(); 35 let config = FirmwareUpdaterConfig::from_linkerfile(&flash);
36 let mut updater = FirmwareUpdater::new(config);
32 button.wait_for_falling_edge().await; 37 button.wait_for_falling_edge().await;
33 let mut offset = 0; 38 let mut offset = 0;
39 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
34 for chunk in APP_B.chunks(128) { 40 for chunk in APP_B.chunks(128) {
35 let mut buf: [u8; 128] = [0; 128]; 41 let mut buf: [u8; 128] = [0; 128];
36 buf[..chunk.len()].copy_from_slice(chunk); 42 buf[..chunk.len()].copy_from_slice(chunk);
37 updater.write_firmware(offset, &buf, &mut flash, 128).await.unwrap(); 43 updater.write_firmware(magic.as_mut(), offset, &buf).await.unwrap();
38 offset += chunk.len(); 44 offset += chunk.len();
39 } 45 }
40 46
41 let mut magic = AlignedBuffer([0; WRITE_SIZE]); 47 updater.mark_updated(magic.as_mut()).await.unwrap();
42 updater.mark_updated(&mut flash, magic.as_mut()).await.unwrap();
43 led.set_low(); 48 led.set_low();
44 Timer::after(Duration::from_secs(1)).await; 49 Timer::after(Duration::from_secs(1)).await;
45 cortex_m::peripheral::SCB::sys_reset(); 50 cortex_m::peripheral::SCB::sys_reset();
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml
index 8ac0fac85..10b58c172 100644
--- a/examples/boot/application/stm32l1/Cargo.toml
+++ b/examples/boot/application/stm32l1/Cargo.toml
@@ -26,3 +26,4 @@ defmt = [
26 "embassy-stm32/defmt", 26 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 27 "embassy-boot-stm32/defmt",
28] 28]
29skip-include = []
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;
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml
index ec79acdeb..713a6527e 100644
--- a/examples/boot/application/stm32l4/Cargo.toml
+++ b/examples/boot/application/stm32l4/Cargo.toml
@@ -26,3 +26,4 @@ defmt = [
26 "embassy-stm32/defmt", 26 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 27 "embassy-boot-stm32/defmt",
28] 28]
29skip-include = []
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}
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml
index dfaece6cf..4c8bbd73f 100644
--- a/examples/boot/application/stm32wl/Cargo.toml
+++ b/examples/boot/application/stm32wl/Cargo.toml
@@ -26,3 +26,4 @@ defmt = [
26 "embassy-stm32/defmt", 26 "embassy-stm32/defmt",
27 "embassy-boot-stm32/defmt", 27 "embassy-boot-stm32/defmt",
28] 28]
29skip-include = []
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs
index 0c6fa05f9..52a197a5c 100644
--- a/examples/boot/application/stm32wl/src/bin/a.rs
+++ b/examples/boot/application/stm32wl/src/bin/a.rs
@@ -4,21 +4,25 @@
4 4
5#[cfg(feature = "defmt-rtt")] 5#[cfg(feature = "defmt-rtt")]
6use defmt_rtt::*; 6use defmt_rtt::*;
7use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater}; 7use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
8use embassy_embedded_hal::adapter::BlockingAsync; 8use embassy_embedded_hal::adapter::BlockingAsync;
9use embassy_executor::Spawner; 9use 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]
18async fn main(_spawner: Spawner) { 22async fn main(_spawner: Spawner) {
19 let p = embassy_stm32::init(Default::default()); 23 let p = embassy_stm32::init(Default::default());
20 let flash = Flash::new_blocking(p.FLASH); 24 let flash = Flash::new_blocking(p.FLASH);
21 let mut flash = Mutex::new(BlockingAsync::new(flash)); 25 let flash = Mutex::new(BlockingAsync::new(flash));
22 26
23 let button = Input::new(p.PA0, Pull::Up); 27 let button = Input::new(p.PA0, Pull::Up);
24 let mut button = ExtiInput::new(button, p.EXTI0); 28 let mut button = ExtiInput::new(button, p.EXTI0);
@@ -30,15 +34,15 @@ async fn main(_spawner: Spawner) {
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;
32 //defmt::info!("Starting update"); 36 //defmt::info!("Starting update");
37 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
33 let mut offset = 0; 38 let mut offset = 0;
34 for chunk in APP_B.chunks(2048) { 39 for chunk in APP_B.chunks(2048) {
35 let mut buf: [u8; 2048] = [0; 2048]; 40 let mut buf: [u8; 2048] = [0; 2048];
36 buf[..chunk.len()].copy_from_slice(chunk); 41 buf[..chunk.len()].copy_from_slice(chunk);
37 // defmt::info!("Writing chunk at 0x{:x}", offset); 42 // defmt::info!("Writing chunk at 0x{:x}", offset);
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 let mut magic = AlignedBuffer([0; WRITE_SIZE]);
42 updater.mark_updated(magic.as_mut()).await.unwrap(); 46 updater.mark_updated(magic.as_mut()).await.unwrap();
43 //defmt::info!("Marked as updated"); 47 //defmt::info!("Marked as updated");
44 led.set_low(); 48 led.set_low();