aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application
diff options
context:
space:
mode:
Diffstat (limited to 'examples/boot/application')
-rw-r--r--examples/boot/application/nrf/Cargo.toml18
-rw-r--r--examples/boot/application/nrf/README.md2
-rw-r--r--examples/boot/application/nrf/src/bin/a.rs25
-rw-r--r--examples/boot/application/nrf/src/bin/b.rs4
-rw-r--r--examples/boot/application/rp/Cargo.toml6
-rw-r--r--examples/boot/application/stm32f3/Cargo.toml2
-rw-r--r--examples/boot/application/stm32f3/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32f7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32f7/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32h7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32h7/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32l0/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l0/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32l1/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l1/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32l4/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l4/src/bin/a.rs10
-rw-r--r--examples/boot/application/stm32wb-dfu/Cargo.toml2
-rw-r--r--examples/boot/application/stm32wb-dfu/src/main.rs4
-rw-r--r--examples/boot/application/stm32wba-dfu/Cargo.toml2
-rw-r--r--examples/boot/application/stm32wba-dfu/src/main.rs4
-rw-r--r--examples/boot/application/stm32wl/Cargo.toml2
-rw-r--r--examples/boot/application/stm32wl/src/bin/a.rs11
-rw-r--r--examples/boot/application/stm32wl/src/bin/b.rs2
24 files changed, 110 insertions, 44 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index f5f89ecb5..ccaa24e3e 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-nrf-examples" 3name = "embassy-boot-nrf-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
@@ -9,9 +9,9 @@ publish = false
9embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" } 9embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" }
10embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] } 10embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] }
11embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] } 11embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] }
12embassy-nrf = { version = "0.8.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } 12embassy-nrf = { version = "0.9.0", path = "../../../../embassy-nrf", features = ["gpiote", ] }
13embassy-boot = { version = "0.6.1", path = "../../../../embassy-boot", features = [] } 13embassy-boot = { version = "0.6.1", path = "../../../../embassy-boot", features = [] }
14embassy-boot-nrf = { version = "0.9.0", path = "../../../../embassy-boot-nrf", features = [] } 14embassy-boot-nrf = { version = "0.10.0", path = "../../../../embassy-boot-nrf", features = [] }
15embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" } 15embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" }
16 16
17defmt = { version = "1.0.1", optional = true } 17defmt = { version = "1.0.1", optional = true }
@@ -33,12 +33,14 @@ defmt = [
33 "embassy-boot-nrf/defmt", 33 "embassy-boot-nrf/defmt",
34 "embassy-sync/defmt", 34 "embassy-sync/defmt",
35] 35]
36nrf54 = ["embassy-nrf/time-driver-grtc"]
36 37
37[package.metadata.embassy] 38[package.metadata.embassy]
38build = [ 39build = [
39 { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840", "skip-include"], artifact-dir = "out/examples/boot/nrf52840" }, 40 { target = "thumbv7em-none-eabi", features = ["embassy-nrf/nrf52840", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf52840" },
40 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9160" }, 41 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9160-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9160" },
41 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9120" }, 42 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9120-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9120" },
42 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9151" }, 43 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9151-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9151" },
43 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns", "skip-include"], artifact-dir = "out/examples/boot/nrf9161" } 44 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf9161-ns", "embassy-nrf/time-driver-rtc1", "skip-include"], artifact-dir = "out/examples/boot/nrf9161" },
45 { target = "thumbv8m.main-none-eabihf", features = ["embassy-nrf/nrf54l15-app-s", "nrf54", "skip-include"], artifact-dir = "out/examples/boot/nrf54l15" }
44] 46]
diff --git a/examples/boot/application/nrf/README.md b/examples/boot/application/nrf/README.md
index 9d6d20336..c92ccb358 100644
--- a/examples/boot/application/nrf/README.md
+++ b/examples/boot/application/nrf/README.md
@@ -22,7 +22,7 @@ cp memory-bl.x ../../bootloader/nrf/memory.x
22# Flash bootloader 22# Flash bootloader
23cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --release --chip nRF52840_xxAA 23cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --release --chip nRF52840_xxAA
24# Build 'b' 24# Build 'b'
25cargo build --release --bin b --features embassy-nrf/nrf52840 25cargo build --release --bin b --features embassy-nrf/nrf52840,time-driver-rtc1
26# Generate binary for 'b' 26# Generate binary for 'b'
27cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin 27cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin
28``` 28```
diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs
index 2c1d1a7bb..035ffe214 100644
--- a/examples/boot/application/nrf/src/bin/a.rs
+++ b/examples/boot/application/nrf/src/bin/a.rs
@@ -23,10 +23,21 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
23async fn main(_spawner: Spawner) { 23async fn main(_spawner: Spawner) {
24 let p = embassy_nrf::init(Default::default()); 24 let p = embassy_nrf::init(Default::default());
25 25
26 #[cfg(not(feature = "nrf54"))]
26 let mut button = Input::new(p.P0_11, Pull::Up); 27 let mut button = Input::new(p.P0_11, Pull::Up);
28 #[cfg(not(feature = "nrf54"))]
27 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 29 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
30 #[cfg(not(feature = "nrf54"))]
28 let mut led_reverted = Output::new(p.P0_14, Level::High, OutputDrive::Standard); 31 let mut led_reverted = Output::new(p.P0_14, Level::High, OutputDrive::Standard);
29 32
33 // nRF54 DK
34 #[cfg(feature = "nrf54")]
35 let mut button = Input::new(p.P1_13, Pull::Up);
36 #[cfg(feature = "nrf54")]
37 let mut led = Output::new(p.P1_14, Level::Low, OutputDrive::Standard);
38 #[cfg(feature = "nrf54")]
39 let mut led_reverted = Output::new(p.P2_09, Level::High, OutputDrive::Standard);
40
30 //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); 41 //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
31 //let mut button = Input::new(p.P1_02, Pull::Up); 42 //let mut button = Input::new(p.P1_02, Pull::Up);
32 43
@@ -40,8 +51,12 @@ async fn main(_spawner: Spawner) {
40 // the watchdog will cause the device to reset as per its configured timeout in the bootloader. 51 // the watchdog will cause the device to reset as per its configured timeout in the bootloader.
41 // This helps is avoid a situation where new firmware might be bad and block our executor. 52 // This helps is avoid a situation where new firmware might be bad and block our executor.
42 // If firmware is bad in this way then the bootloader will revert to any previous version. 53 // If firmware is bad in this way then the bootloader will revert to any previous version.
43 let wdt_config = wdt::Config::try_new(&p.WDT).unwrap(); 54 #[cfg(feature = "nrf54")]
44 let (_wdt, [_wdt_handle]) = match Watchdog::try_new(p.WDT, wdt_config) { 55 let wdt = p.WDT0;
56 #[cfg(not(feature = "nrf54"))]
57 let wdt = p.WDT;
58 let wdt_config = wdt::Config::try_new(&wdt).unwrap();
59 let (_wdt, [_wdt_handle]) = match Watchdog::try_new(wdt, wdt_config) {
45 Ok(x) => x, 60 Ok(x) => x,
46 Err(_) => { 61 Err(_) => {
47 // Watchdog already active with the wrong number of handles, waiting for it to timeout... 62 // Watchdog already active with the wrong number of handles, waiting for it to timeout...
@@ -51,11 +66,15 @@ async fn main(_spawner: Spawner) {
51 } 66 }
52 }; 67 };
53 68
69 // RRAMC for nRF54
70 #[cfg(feature = "nrf54")]
71 let nvmc = Nvmc::new(p.RRAMC);
72 #[cfg(not(feature = "nrf54"))]
54 let nvmc = Nvmc::new(p.NVMC); 73 let nvmc = Nvmc::new(p.NVMC);
55 let nvmc = Mutex::new(BlockingAsync::new(nvmc)); 74 let nvmc = Mutex::new(BlockingAsync::new(nvmc));
56 75
57 let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc); 76 let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc);
58 let mut magic = [0; 4]; 77 let mut magic = [0; 16];
59 let mut updater = FirmwareUpdater::new(config, &mut magic); 78 let mut updater = FirmwareUpdater::new(config, &mut magic);
60 let state = updater.get_state().await.unwrap(); 79 let state = updater.get_state().await.unwrap();
61 if state == State::Revert { 80 if state == State::Revert {
diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs
index de97b6a22..6718df5a1 100644
--- a/examples/boot/application/nrf/src/bin/b.rs
+++ b/examples/boot/application/nrf/src/bin/b.rs
@@ -10,11 +10,15 @@ use panic_reset as _;
10#[embassy_executor::main] 10#[embassy_executor::main]
11async fn main(_spawner: Spawner) { 11async fn main(_spawner: Spawner) {
12 let p = embassy_nrf::init(Default::default()); 12 let p = embassy_nrf::init(Default::default());
13 #[cfg(not(feature = "nrf54"))]
13 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 14 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
14 // let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); 15 // let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
15 16
16 // nRF91 DK 17 // nRF91 DK
17 // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard); 18 // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard);
19 // nrf54l15 dk
20 #[cfg(feature = "nrf54")]
21 let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
18 22
19 loop { 23 loop {
20 led.set_high(); 24 led.set_high();
diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml
index d86386b00..292d1abec 100644
--- a/examples/boot/application/rp/Cargo.toml
+++ b/examples/boot/application/rp/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-rp-examples" 3name = "embassy-boot-rp-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
@@ -9,8 +9,8 @@ publish = false
9embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" } 9embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" }
10embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 10embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
11embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] } 11embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] }
12embassy-rp = { version = "0.8.0", path = "../../../../embassy-rp", features = ["time-driver", "rp2040"] } 12embassy-rp = { version = "0.9.0", path = "../../../../embassy-rp", features = ["time-driver", "rp2040"] }
13embassy-boot-rp = { version = "0.8.0", path = "../../../../embassy-boot-rp", features = [] } 13embassy-boot-rp = { version = "0.9.0", path = "../../../../embassy-boot-rp", features = [] }
14embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" } 14embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml
index cd5f422fc..2dc75d939 100644
--- a/examples/boot/application/stm32f3/Cargo.toml
+++ b/examples/boot/application/stm32f3/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32f3-examples" 3name = "embassy-boot-stm32f3-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs
index b608b2e01..da3cbf1e6 100644
--- a/examples/boot/application/stm32f3/src/bin/a.rs
+++ b/examples/boot/application/stm32f3/src/bin/a.rs
@@ -6,12 +6,18 @@ use defmt_rtt::*;
6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; 6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
7use embassy_embedded_hal::adapter::BlockingAsync; 7use embassy_embedded_hal::adapter::BlockingAsync;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 9use embassy_stm32::exti::{self, ExtiInput};
10use embassy_stm32::flash::{Flash, WRITE_SIZE}; 10use embassy_stm32::flash::{Flash, WRITE_SIZE};
11use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 11use embassy_stm32::gpio::{Level, Output, Pull, Speed};
12use embassy_stm32::{bind_interrupts, interrupt};
12use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
13use panic_reset as _; 14use panic_reset as _;
14 15
16bind_interrupts!(
17 pub struct Irqs{
18 EXTI15_10 => exti::InterruptHandler<interrupt::typelevel::EXTI15_10>;
19});
20
15#[cfg(feature = "skip-include")] 21#[cfg(feature = "skip-include")]
16static APP_B: &[u8] = &[0, 1, 2, 3]; 22static APP_B: &[u8] = &[0, 1, 2, 3];
17#[cfg(not(feature = "skip-include"))] 23#[cfg(not(feature = "skip-include"))]
@@ -23,7 +29,7 @@ async fn main(_spawner: Spawner) {
23 let flash = Flash::new_blocking(p.FLASH); 29 let flash = Flash::new_blocking(p.FLASH);
24 let flash = Mutex::new(BlockingAsync::new(flash)); 30 let flash = Mutex::new(BlockingAsync::new(flash));
25 31
26 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); 32 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up, Irqs);
27 33
28 let mut led = Output::new(p.PA5, Level::Low, Speed::Low); 34 let mut led = Output::new(p.PA5, Level::Low, Speed::Low);
29 led.set_high(); 35 led.set_high();
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml
index c3921a166..5c372fb19 100644
--- a/examples/boot/application/stm32f7/Cargo.toml
+++ b/examples/boot/application/stm32f7/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32f7-examples" 3name = "embassy-boot-stm32f7-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs
index 172b4c235..62f1da269 100644
--- a/examples/boot/application/stm32f7/src/bin/a.rs
+++ b/examples/boot/application/stm32f7/src/bin/a.rs
@@ -7,9 +7,10 @@ use core::cell::RefCell;
7use defmt_rtt::*; 7use defmt_rtt::*;
8use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; 8use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig};
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_stm32::exti::ExtiInput; 10use embassy_stm32::exti::{self, ExtiInput};
11use embassy_stm32::flash::{Flash, WRITE_SIZE}; 11use embassy_stm32::flash::{Flash, WRITE_SIZE};
12use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 12use embassy_stm32::gpio::{Level, Output, Pull, Speed};
13use embassy_stm32::{bind_interrupts, interrupt};
13use embassy_sync::blocking_mutex::Mutex; 14use embassy_sync::blocking_mutex::Mutex;
14use embedded_storage::nor_flash::NorFlash; 15use embedded_storage::nor_flash::NorFlash;
15use panic_reset as _; 16use panic_reset as _;
@@ -19,13 +20,18 @@ static APP_B: &[u8] = &[0, 1, 2, 3];
19#[cfg(not(feature = "skip-include"))] 20#[cfg(not(feature = "skip-include"))]
20static APP_B: &[u8] = include_bytes!("../../b.bin"); 21static APP_B: &[u8] = include_bytes!("../../b.bin");
21 22
23bind_interrupts!(
24 pub struct Irqs{
25 EXTI15_10 => exti::InterruptHandler<interrupt::typelevel::EXTI15_10>;
26});
27
22#[embassy_executor::main] 28#[embassy_executor::main]
23async fn main(_spawner: Spawner) { 29async fn main(_spawner: Spawner) {
24 let p = embassy_stm32::init(Default::default()); 30 let p = embassy_stm32::init(Default::default());
25 let flash = Flash::new_blocking(p.FLASH); 31 let flash = Flash::new_blocking(p.FLASH);
26 let flash = Mutex::new(RefCell::new(flash)); 32 let flash = Mutex::new(RefCell::new(flash));
27 33
28 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); 34 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down, Irqs);
29 35
30 let mut led = Output::new(p.PB7, Level::Low, Speed::Low); 36 let mut led = Output::new(p.PB7, Level::Low, Speed::Low);
31 led.set_high(); 37 led.set_high();
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml
index ca186d4d9..641a2ba96 100644
--- a/examples/boot/application/stm32h7/Cargo.toml
+++ b/examples/boot/application/stm32h7/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32h7-examples" 3name = "embassy-boot-stm32h7-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs
index c1b1a267a..226971e02 100644
--- a/examples/boot/application/stm32h7/src/bin/a.rs
+++ b/examples/boot/application/stm32h7/src/bin/a.rs
@@ -7,13 +7,19 @@ use core::cell::RefCell;
7use defmt_rtt::*; 7use defmt_rtt::*;
8use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; 8use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig};
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_stm32::exti::ExtiInput; 10use embassy_stm32::exti::{self, ExtiInput};
11use embassy_stm32::flash::{Flash, WRITE_SIZE}; 11use embassy_stm32::flash::{Flash, WRITE_SIZE};
12use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 12use embassy_stm32::gpio::{Level, Output, Pull, Speed};
13use embassy_stm32::{bind_interrupts, interrupt};
13use embassy_sync::blocking_mutex::Mutex; 14use embassy_sync::blocking_mutex::Mutex;
14use embedded_storage::nor_flash::NorFlash; 15use embedded_storage::nor_flash::NorFlash;
15use panic_reset as _; 16use panic_reset as _;
16 17
18bind_interrupts!(
19 pub struct Irqs{
20 EXTI15_10 => exti::InterruptHandler<interrupt::typelevel::EXTI15_10>;
21});
22
17#[cfg(feature = "skip-include")] 23#[cfg(feature = "skip-include")]
18static APP_B: &[u8] = &[0, 1, 2, 3]; 24static APP_B: &[u8] = &[0, 1, 2, 3];
19#[cfg(not(feature = "skip-include"))] 25#[cfg(not(feature = "skip-include"))]
@@ -25,7 +31,7 @@ async fn main(_spawner: Spawner) {
25 let flash = Flash::new_blocking(p.FLASH); 31 let flash = Flash::new_blocking(p.FLASH);
26 let flash = Mutex::new(RefCell::new(flash)); 32 let flash = Mutex::new(RefCell::new(flash));
27 33
28 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); 34 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down, Irqs);
29 35
30 let mut led = Output::new(p.PB14, Level::Low, Speed::Low); 36 let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
31 led.set_high(); 37 led.set_high();
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml
index be08956f1..4a168be15 100644
--- a/examples/boot/application/stm32l0/Cargo.toml
+++ b/examples/boot/application/stm32l0/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32l0-examples" 3name = "embassy-boot-stm32l0-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs
index dcc10e5c6..0aa723eaa 100644
--- a/examples/boot/application/stm32l0/src/bin/a.rs
+++ b/examples/boot/application/stm32l0/src/bin/a.rs
@@ -6,13 +6,19 @@ use defmt_rtt::*;
6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; 6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
7use embassy_embedded_hal::adapter::BlockingAsync; 7use embassy_embedded_hal::adapter::BlockingAsync;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 9use embassy_stm32::exti::{self, ExtiInput};
10use embassy_stm32::flash::{Flash, WRITE_SIZE}; 10use embassy_stm32::flash::{Flash, WRITE_SIZE};
11use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 11use embassy_stm32::gpio::{Level, Output, Pull, Speed};
12use embassy_stm32::{bind_interrupts, interrupt};
12use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
13use embassy_time::Timer; 14use embassy_time::Timer;
14use panic_reset as _; 15use panic_reset as _;
15 16
17bind_interrupts!(
18 pub struct Irqs{
19 EXTI2_3 => exti::InterruptHandler<interrupt::typelevel::EXTI2_3>;
20});
21
16#[cfg(feature = "skip-include")] 22#[cfg(feature = "skip-include")]
17static APP_B: &[u8] = &[0, 1, 2, 3]; 23static APP_B: &[u8] = &[0, 1, 2, 3];
18#[cfg(not(feature = "skip-include"))] 24#[cfg(not(feature = "skip-include"))]
@@ -24,7 +30,7 @@ async fn main(_spawner: Spawner) {
24 let flash = Flash::new_blocking(p.FLASH); 30 let flash = Flash::new_blocking(p.FLASH);
25 let flash = Mutex::new(BlockingAsync::new(flash)); 31 let flash = Mutex::new(BlockingAsync::new(flash));
26 32
27 let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); 33 let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up, Irqs);
28 34
29 let mut led = Output::new(p.PB5, Level::Low, Speed::Low); 35 let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
30 36
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml
index 207eed733..af2cb3881 100644
--- a/examples/boot/application/stm32l1/Cargo.toml
+++ b/examples/boot/application/stm32l1/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32l1-examples" 3name = "embassy-boot-stm32l1-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs
index dcc10e5c6..7ad7046fb 100644
--- a/examples/boot/application/stm32l1/src/bin/a.rs
+++ b/examples/boot/application/stm32l1/src/bin/a.rs
@@ -6,9 +6,10 @@ use defmt_rtt::*;
6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; 6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
7use embassy_embedded_hal::adapter::BlockingAsync; 7use embassy_embedded_hal::adapter::BlockingAsync;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 9use embassy_stm32::exti::{self, ExtiInput};
10use embassy_stm32::flash::{Flash, WRITE_SIZE}; 10use embassy_stm32::flash::{Flash, WRITE_SIZE};
11use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 11use embassy_stm32::gpio::{Level, Output, Pull, Speed};
12use embassy_stm32::{bind_interrupts, interrupt};
12use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
13use embassy_time::Timer; 14use embassy_time::Timer;
14use panic_reset as _; 15use panic_reset as _;
@@ -18,13 +19,18 @@ static APP_B: &[u8] = &[0, 1, 2, 3];
18#[cfg(not(feature = "skip-include"))] 19#[cfg(not(feature = "skip-include"))]
19static APP_B: &[u8] = include_bytes!("../../b.bin"); 20static APP_B: &[u8] = include_bytes!("../../b.bin");
20 21
22bind_interrupts!(
23 pub struct Irqs{
24 EXTI2 => exti::InterruptHandler<interrupt::typelevel::EXTI2>;
25});
26
21#[embassy_executor::main] 27#[embassy_executor::main]
22async fn main(_spawner: Spawner) { 28async fn main(_spawner: Spawner) {
23 let p = embassy_stm32::init(Default::default()); 29 let p = embassy_stm32::init(Default::default());
24 let flash = Flash::new_blocking(p.FLASH); 30 let flash = Flash::new_blocking(p.FLASH);
25 let flash = Mutex::new(BlockingAsync::new(flash)); 31 let flash = Mutex::new(BlockingAsync::new(flash));
26 32
27 let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); 33 let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up, Irqs);
28 34
29 let mut led = Output::new(p.PB5, Level::Low, Speed::Low); 35 let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
30 36
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml
index 22b9642d8..032e934aa 100644
--- a/examples/boot/application/stm32l4/Cargo.toml
+++ b/examples/boot/application/stm32l4/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32l4-examples" 3name = "embassy-boot-stm32l4-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs
index 7f8015c04..4edd338c5 100644
--- a/examples/boot/application/stm32l4/src/bin/a.rs
+++ b/examples/boot/application/stm32l4/src/bin/a.rs
@@ -6,9 +6,10 @@ use defmt_rtt::*;
6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; 6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
7use embassy_embedded_hal::adapter::BlockingAsync; 7use embassy_embedded_hal::adapter::BlockingAsync;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 9use embassy_stm32::exti::{self, ExtiInput};
10use embassy_stm32::flash::{Flash, WRITE_SIZE}; 10use embassy_stm32::flash::{Flash, WRITE_SIZE};
11use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 11use embassy_stm32::gpio::{Level, Output, Pull, Speed};
12use embassy_stm32::{bind_interrupts, interrupt};
12use embassy_sync::mutex::Mutex; 13use embassy_sync::mutex::Mutex;
13use panic_reset as _; 14use panic_reset as _;
14 15
@@ -17,13 +18,18 @@ static APP_B: &[u8] = &[0, 1, 2, 3];
17#[cfg(not(feature = "skip-include"))] 18#[cfg(not(feature = "skip-include"))]
18static APP_B: &[u8] = include_bytes!("../../b.bin"); 19static APP_B: &[u8] = include_bytes!("../../b.bin");
19 20
21bind_interrupts!(
22 pub struct Irqs{
23 EXTI15_10 => exti::InterruptHandler<interrupt::typelevel::EXTI15_10>;
24});
25
20#[embassy_executor::main] 26#[embassy_executor::main]
21async fn main(_spawner: Spawner) { 27async fn main(_spawner: Spawner) {
22 let p = embassy_stm32::init(Default::default()); 28 let p = embassy_stm32::init(Default::default());
23 let flash = Flash::new_blocking(p.FLASH); 29 let flash = Flash::new_blocking(p.FLASH);
24 let flash = Mutex::new(BlockingAsync::new(flash)); 30 let flash = Mutex::new(BlockingAsync::new(flash));
25 31
26 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); 32 let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up, Irqs);
27 33
28 let mut led = Output::new(p.PB14, Level::Low, Speed::Low); 34 let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
29 led.set_high(); 35 led.set_high();
diff --git a/examples/boot/application/stm32wb-dfu/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml
index e2be4f470..ea4c26681 100644
--- a/examples/boot/application/stm32wb-dfu/Cargo.toml
+++ b/examples/boot/application/stm32wb-dfu/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32wb-dfu-examples" 3name = "embassy-boot-stm32wb-dfu-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32wb-dfu/src/main.rs b/examples/boot/application/stm32wb-dfu/src/main.rs
index 5e7b71f5a..1ae28bf3a 100644
--- a/examples/boot/application/stm32wb-dfu/src/main.rs
+++ b/examples/boot/application/stm32wb-dfu/src/main.rs
@@ -13,9 +13,9 @@ use embassy_stm32::usb::{self, Driver};
13use embassy_stm32::{bind_interrupts, peripherals}; 13use embassy_stm32::{bind_interrupts, peripherals};
14use embassy_sync::blocking_mutex::Mutex; 14use embassy_sync::blocking_mutex::Mutex;
15use embassy_time::Duration; 15use embassy_time::Duration;
16use embassy_usb::{msos, Builder}; 16use embassy_usb::{Builder, msos};
17use embassy_usb_dfu::consts::DfuAttributes; 17use embassy_usb_dfu::consts::DfuAttributes;
18use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; 18use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu};
19use panic_reset as _; 19use panic_reset as _;
20 20
21bind_interrupts!(struct Irqs { 21bind_interrupts!(struct Irqs {
diff --git a/examples/boot/application/stm32wba-dfu/Cargo.toml b/examples/boot/application/stm32wba-dfu/Cargo.toml
index 6f4213b2c..d6f7dc3b6 100644
--- a/examples/boot/application/stm32wba-dfu/Cargo.toml
+++ b/examples/boot/application/stm32wba-dfu/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32wba-dfu-examples" 3name = "embassy-boot-stm32wba-dfu-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32wba-dfu/src/main.rs b/examples/boot/application/stm32wba-dfu/src/main.rs
index bf17a7150..8adb2e7c0 100644
--- a/examples/boot/application/stm32wba-dfu/src/main.rs
+++ b/examples/boot/application/stm32wba-dfu/src/main.rs
@@ -12,9 +12,9 @@ use embassy_stm32::usb::{self, Driver};
12use embassy_stm32::{bind_interrupts, peripherals}; 12use embassy_stm32::{bind_interrupts, peripherals};
13use embassy_sync::blocking_mutex::Mutex; 13use embassy_sync::blocking_mutex::Mutex;
14use embassy_time::Duration; 14use embassy_time::Duration;
15use embassy_usb::{msos, Builder}; 15use embassy_usb::{Builder, msos};
16use embassy_usb_dfu::consts::DfuAttributes; 16use embassy_usb_dfu::consts::DfuAttributes;
17use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; 17use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu};
18use panic_reset as _; 18use panic_reset as _;
19 19
20bind_interrupts!(struct Irqs { 20bind_interrupts!(struct Irqs {
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml
index 8d1446ba9..c7fa811c9 100644
--- a/examples/boot/application/stm32wl/Cargo.toml
+++ b/examples/boot/application/stm32wl/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2edition = "2021" 2edition = "2024"
3name = "embassy-boot-stm32wl-examples" 3name = "embassy-boot-stm32wl-examples"
4version = "0.1.0" 4version = "0.1.0"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs
index e4526927f..58063eb50 100644
--- a/examples/boot/application/stm32wl/src/bin/a.rs
+++ b/examples/boot/application/stm32wl/src/bin/a.rs
@@ -8,10 +8,10 @@ use defmt_rtt::*;
8use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; 8use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
9use embassy_embedded_hal::adapter::BlockingAsync; 9use embassy_embedded_hal::adapter::BlockingAsync;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_stm32::exti::ExtiInput; 11use embassy_stm32::exti::{self, ExtiInput};
12use embassy_stm32::flash::{Flash, WRITE_SIZE}; 12use embassy_stm32::flash::{Flash, WRITE_SIZE};
13use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 13use embassy_stm32::gpio::{Level, Output, Pull, Speed};
14use embassy_stm32::SharedData; 14use embassy_stm32::{SharedData, bind_interrupts, interrupt};
15use embassy_sync::mutex::Mutex; 15use embassy_sync::mutex::Mutex;
16use panic_reset as _; 16use panic_reset as _;
17 17
@@ -20,6 +20,11 @@ static APP_B: &[u8] = &[0, 1, 2, 3];
20#[cfg(not(feature = "skip-include"))] 20#[cfg(not(feature = "skip-include"))]
21static APP_B: &[u8] = include_bytes!("../../b.bin"); 21static APP_B: &[u8] = include_bytes!("../../b.bin");
22 22
23bind_interrupts!(
24 pub struct Irqs{
25 EXTI0 => exti::InterruptHandler<interrupt::typelevel::EXTI0>;
26});
27
23#[unsafe(link_section = ".shared_data")] 28#[unsafe(link_section = ".shared_data")]
24static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); 29static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
25 30
@@ -29,7 +34,7 @@ async fn main(_spawner: Spawner) {
29 let flash = Flash::new_blocking(p.FLASH); 34 let flash = Flash::new_blocking(p.FLASH);
30 let flash = Mutex::new(BlockingAsync::new(flash)); 35 let flash = Mutex::new(BlockingAsync::new(flash));
31 36
32 let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); 37 let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up, Irqs);
33 38
34 let mut led = Output::new(p.PB9, Level::Low, Speed::Low); 39 let mut led = Output::new(p.PB9, Level::Low, Speed::Low);
35 led.set_high(); 40 led.set_high();
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs
index 6016a9555..952e94a58 100644
--- a/examples/boot/application/stm32wl/src/bin/b.rs
+++ b/examples/boot/application/stm32wl/src/bin/b.rs
@@ -6,8 +6,8 @@ use core::mem::MaybeUninit;
6#[cfg(feature = "defmt")] 6#[cfg(feature = "defmt")]
7use defmt_rtt::*; 7use defmt_rtt::*;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_stm32::gpio::{Level, Output, Speed};
10use embassy_stm32::SharedData; 9use embassy_stm32::SharedData;
10use embassy_stm32::gpio::{Level, Output, Speed};
11use embassy_time::Timer; 11use embassy_time::Timer;
12use panic_reset as _; 12use panic_reset as _;
13 13