aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application
diff options
context:
space:
mode:
authorMathias <[email protected]>2023-02-13 14:55:15 +0100
committerMathias <[email protected]>2023-02-13 14:55:15 +0100
commit218b44652c149f895919b606a660b6eff30e8177 (patch)
tree5f985f6edd12926a6f374c17a3a0c3a4226088e7 /examples/boot/application
parent86113e199f37fe0888979608a08bfdaf21bff19a (diff)
parent41a563aae3e474955892b27487e185f5f486f525 (diff)
Rebase on master
Diffstat (limited to 'examples/boot/application')
-rw-r--r--examples/boot/application/nrf/Cargo.toml9
-rw-r--r--examples/boot/application/nrf/README.md14
-rw-r--r--examples/boot/application/nrf/memory-bl-nrf91.x19
-rw-r--r--examples/boot/application/nrf/memory-bl.x2
-rw-r--r--examples/boot/application/nrf/memory-nrf91.x16
-rw-r--r--examples/boot/application/nrf/memory.x2
-rw-r--r--examples/boot/application/nrf/src/bin/a.rs24
-rw-r--r--examples/boot/application/nrf/src/bin/b.rs5
-rw-r--r--examples/boot/application/rp/.cargo/config.toml12
-rw-r--r--examples/boot/application/rp/Cargo.toml33
-rw-r--r--examples/boot/application/rp/README.md28
-rw-r--r--examples/boot/application/rp/build.rs35
-rw-r--r--examples/boot/application/rp/memory.x15
-rw-r--r--examples/boot/application/rp/src/bin/a.rs59
-rw-r--r--examples/boot/application/rp/src/bin/b.rs23
-rw-r--r--examples/boot/application/stm32f3/Cargo.toml2
-rw-r--r--examples/boot/application/stm32f7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32h7/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l0/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l1/Cargo.toml2
-rw-r--r--examples/boot/application/stm32l4/Cargo.toml2
-rw-r--r--examples/boot/application/stm32wl/Cargo.toml2
22 files changed, 293 insertions, 17 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index a5d82b601..888993255 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -8,14 +8,19 @@ license = "MIT OR Apache-2.0"
8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] } 9embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] } 10embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] }
11embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } 11embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] }
12embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot" }
12embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" } 13embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 14embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 15
15defmt = { version = "0.3", optional = true } 16defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", optional = true } 17defmt-rtt = { version = "0.4", optional = true }
17panic-reset = { version = "0.1.1" } 18panic-reset = { version = "0.1.1" }
18embedded-hal = { version = "0.2.6" } 19embedded-hal = { version = "0.2.6" }
19 20
20cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } 21cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
21cortex-m-rt = "0.7.0" 22cortex-m-rt = "0.7.0"
23
24[features]
25ed25519-dalek = ["embassy-boot/ed25519-dalek"]
26ed25519-salty = ["embassy-boot/ed25519-salty"] \ No newline at end of file
diff --git a/examples/boot/application/nrf/README.md b/examples/boot/application/nrf/README.md
index 703377a20..9d6d20336 100644
--- a/examples/boot/application/nrf/README.md
+++ b/examples/boot/application/nrf/README.md
@@ -1,6 +1,6 @@
1# Examples using bootloader 1# Examples using bootloader
2 2
3Example for nRF52 demonstrating the bootloader. The example consists of application binaries, 'a' 3Example for nRF demonstrating the bootloader. The example consists of application binaries, 'a'
4which allows you to press a button to start the DFU process, and 'b' which is the updated 4which allows you to press a button to start the DFU process, and 'b' which is the updated
5application. 5application.
6 6
@@ -20,15 +20,19 @@ application.
20cp memory-bl.x ../../bootloader/nrf/memory.x 20cp memory-bl.x ../../bootloader/nrf/memory.x
21 21
22# Flash bootloader 22# Flash bootloader
23cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --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 25cargo build --release --bin b --features embassy-nrf/nrf52840
26# Generate binary for 'b' 26# Generate binary for 'b'
27cargo objcopy --release --bin b -- -O binary b.bin 27cargo objcopy --release --bin b --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi -- -O binary b.bin
28``` 28```
29 29
30# Flash `a` (which includes b.bin) 30# Flash `a` (which includes b.bin)
31 31
32``` 32```
33cargo flash --release --bin a --chip nRF52840_xxAA 33cargo flash --release --bin a --features embassy-nrf/nrf52840 --target thumbv7em-none-eabi --chip nRF52840_xxAA
34``` 34```
35
36You should then see a solid LED. Pressing button 1 will cause the DFU to be loaded by the bootloader. Upon
37successfully loading, you'll see the LED flash. After 5 seconds, because there is no petting of the watchdog,
38you'll see the LED go solid again. This indicates that the bootloader has reverted the update.
diff --git a/examples/boot/application/nrf/memory-bl-nrf91.x b/examples/boot/application/nrf/memory-bl-nrf91.x
new file mode 100644
index 000000000..14ceffa73
--- /dev/null
+++ b/examples/boot/application/nrf/memory-bl-nrf91.x
@@ -0,0 +1,19 @@
1MEMORY
2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 /* Assumes Secure Partition Manager (SPM) flashed at the start */
5 FLASH : ORIGIN = 0x00050000, LENGTH = 24K
6 BOOTLOADER_STATE : ORIGIN = 0x00056000, LENGTH = 4K
7 ACTIVE : ORIGIN = 0x00057000, LENGTH = 64K
8 DFU : ORIGIN = 0x00067000, LENGTH = 68K
9 RAM (rwx) : ORIGIN = 0x20018000, LENGTH = 32K
10}
11
12__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
13__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE);
14
15__bootloader_active_start = ORIGIN(ACTIVE);
16__bootloader_active_end = ORIGIN(ACTIVE) + LENGTH(ACTIVE);
17
18__bootloader_dfu_start = ORIGIN(DFU);
19__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU);
diff --git a/examples/boot/application/nrf/memory-bl.x b/examples/boot/application/nrf/memory-bl.x
index 8a32b905f..257d65644 100644
--- a/examples/boot/application/nrf/memory-bl.x
+++ b/examples/boot/application/nrf/memory-bl.x
@@ -5,7 +5,7 @@ MEMORY
5 BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K 5 BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K
6 ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K 6 ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K
7 DFU : ORIGIN = 0x00017000, LENGTH = 68K 7 DFU : ORIGIN = 0x00017000, LENGTH = 68K
8 RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K 8 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
9} 9}
10 10
11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); 11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
diff --git a/examples/boot/application/nrf/memory-nrf91.x b/examples/boot/application/nrf/memory-nrf91.x
new file mode 100644
index 000000000..2bc13c0d6
--- /dev/null
+++ b/examples/boot/application/nrf/memory-nrf91.x
@@ -0,0 +1,16 @@
1MEMORY
2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 /* Assumes Secure Partition Manager (SPM) flashed at the start */
5 BOOTLOADER : ORIGIN = 0x00050000, LENGTH = 24K
6 BOOTLOADER_STATE : ORIGIN = 0x00056000, LENGTH = 4K
7 FLASH : ORIGIN = 0x00057000, LENGTH = 64K
8 DFU : ORIGIN = 0x00067000, LENGTH = 68K
9 RAM (rwx) : ORIGIN = 0x20018000, LENGTH = 32K
10}
11
12__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
13__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE);
14
15__bootloader_dfu_start = ORIGIN(DFU);
16__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU);
diff --git a/examples/boot/application/nrf/memory.x b/examples/boot/application/nrf/memory.x
index 3a54ca460..c6926e422 100644
--- a/examples/boot/application/nrf/memory.x
+++ b/examples/boot/application/nrf/memory.x
@@ -5,7 +5,7 @@ MEMORY
5 BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K 5 BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K
6 FLASH : ORIGIN = 0x00007000, LENGTH = 64K 6 FLASH : ORIGIN = 0x00007000, LENGTH = 64K
7 DFU : ORIGIN = 0x00017000, LENGTH = 68K 7 DFU : ORIGIN = 0x00017000, LENGTH = 68K
8 RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K 8 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
9} 9}
10 10
11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); 11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
diff --git a/examples/boot/application/nrf/src/bin/a.rs b/examples/boot/application/nrf/src/bin/a.rs
index 7a404a914..090a05b23 100644
--- a/examples/boot/application/nrf/src/bin/a.rs
+++ b/examples/boot/application/nrf/src/bin/a.rs
@@ -8,6 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
8use embassy_executor::Spawner; 8use embassy_executor::Spawner;
9use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; 9use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
10use embassy_nrf::nvmc::Nvmc; 10use embassy_nrf::nvmc::Nvmc;
11use embassy_nrf::wdt::{self, Watchdog};
11use panic_reset as _; 12use panic_reset as _;
12 13
13static APP_B: &[u8] = include_bytes!("../../b.bin"); 14static APP_B: &[u8] = include_bytes!("../../b.bin");
@@ -15,11 +16,34 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
15#[embassy_executor::main] 16#[embassy_executor::main]
16async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
17 let p = embassy_nrf::init(Default::default()); 18 let p = embassy_nrf::init(Default::default());
19
18 let mut button = Input::new(p.P0_11, Pull::Up); 20 let mut button = Input::new(p.P0_11, Pull::Up);
19 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 21 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
22
20 //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); 23 //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard);
21 //let mut button = Input::new(p.P1_02, Pull::Up); 24 //let mut button = Input::new(p.P1_02, Pull::Up);
22 25
26 // nRF91 DK
27 // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard);
28 // let mut button = Input::new(p.P0_06, Pull::Up);
29
30 // The following code block illustrates how to obtain a watchdog that is configured
31 // as per the existing watchdog. Ordinarily, we'd use the handle returned to "pet" the
32 // watchdog periodically. If we don't, and we're not going to for this example, then
33 // the watchdog will cause the device to reset as per its configured timeout in the bootloader.
34 // This helps is avoid a situation where new firmware might be bad and block our executor.
35 // If firmware is bad in this way then the bootloader will revert to any previous version.
36 let wdt_config = wdt::Config::try_new(&p.WDT).unwrap();
37 let (_wdt, [_wdt_handle]) = match Watchdog::try_new(p.WDT, wdt_config) {
38 Ok(x) => x,
39 Err(_) => {
40 // Watchdog already active with the wrong number of handles, waiting for it to timeout...
41 loop {
42 cortex_m::asm::wfe();
43 }
44 }
45 };
46
23 let nvmc = Nvmc::new(p.NVMC); 47 let nvmc = Nvmc::new(p.NVMC);
24 let mut nvmc = BlockingAsync::new(nvmc); 48 let mut nvmc = BlockingAsync::new(nvmc);
25 49
diff --git a/examples/boot/application/nrf/src/bin/b.rs b/examples/boot/application/nrf/src/bin/b.rs
index 1373f277d..15ebce5fa 100644
--- a/examples/boot/application/nrf/src/bin/b.rs
+++ b/examples/boot/application/nrf/src/bin/b.rs
@@ -12,7 +12,10 @@ use panic_reset as _;
12async fn main(_spawner: Spawner) { 12async fn main(_spawner: Spawner) {
13 let p = embassy_nrf::init(Default::default()); 13 let p = embassy_nrf::init(Default::default());
14 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);
15 //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);
16
17 // nRF91 DK
18 // let mut led = Output::new(p.P0_02, Level::Low, OutputDrive::Standard);
16 19
17 loop { 20 loop {
18 led.set_high(); 21 led.set_high();
diff --git a/examples/boot/application/rp/.cargo/config.toml b/examples/boot/application/rp/.cargo/config.toml
new file mode 100644
index 000000000..edbd0a867
--- /dev/null
+++ b/examples/boot/application/rp/.cargo/config.toml
@@ -0,0 +1,12 @@
1[unstable]
2build-std = ["core"]
3build-std-features = ["panic_immediate_abort"]
4
5[target.'cfg(all(target_arch = "arm", target_os = "none"))']
6runner = "probe-run --chip RP2040"
7
8[build]
9target = "thumbv6m-none-eabi"
10
11[env]
12DEFMT_LOG = "trace"
diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml
new file mode 100644
index 000000000..8d826790b
--- /dev/null
+++ b/examples/boot/application/rp/Cargo.toml
@@ -0,0 +1,33 @@
1[package]
2edition = "2021"
3name = "embassy-boot-rp-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.1.0", path = "../../../../embassy-executor", features = ["nightly", "integrated-timers"] }
10embassy-time = { version = "0.1.0", path = "../../../../embassy-time", features = ["nightly"] }
11embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", "unstable-traits", "nightly"] }
12embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp" }
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14
15defmt = "0.3"
16defmt-rtt = "0.4"
17panic-probe = { version = "0.3", features = ["print-defmt"], optional = true }
18panic-reset = { version = "0.1.1", optional = true }
19embedded-hal = { version = "0.2.6" }
20
21cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
22cortex-m-rt = "0.7.0"
23
24[features]
25default = ["panic-reset"]
26debug = [
27 "embassy-rp/defmt",
28 "embassy-boot-rp/defmt",
29 "panic-probe"
30]
31
32[profile.release]
33debug = true
diff --git a/examples/boot/application/rp/README.md b/examples/boot/application/rp/README.md
new file mode 100644
index 000000000..41304c526
--- /dev/null
+++ b/examples/boot/application/rp/README.md
@@ -0,0 +1,28 @@
1# Examples using bootloader
2
3Example for Raspberry Pi Pico demonstrating the bootloader. The example consists of application binaries, 'a'
4which waits for 5 seconds before flashing the 'b' binary, which blinks the LED.
5
6NOTE: The 'b' binary does not mark the new binary as active, so if you reset the device, it will roll back to the 'a' binary before automatically updating it again.
7
8## Prerequisites
9
10* `cargo-binutils`
11* `cargo-flash`
12* `embassy-boot-rp`
13
14## Usage
15
16```
17# Flash bootloader
18cargo flash --manifest-path ../../bootloader/rp/Cargo.toml --release --chip RP2040
19
20# Build 'b'
21cargo build --release --bin b
22
23# Generate binary for 'b'
24cargo objcopy --release --bin b -- -O binary b.bin
25
26# Flash `a` (which includes b.bin)
27cargo flash --release --bin a --chip RP2040
28```
diff --git a/examples/boot/application/rp/build.rs b/examples/boot/application/rp/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/boot/application/rp/build.rs
@@ -0,0 +1,35 @@
1//! This build script copies the `memory.x` file from the crate root into
2//! a directory where the linker can always find it at build time.
3//! For many projects this is optional, as the linker always searches the
4//! project root directory -- wherever `Cargo.toml` is. However, if you
5//! are using a workspace or have a more complicated build setup, this
6//! build script becomes required. Additionally, by requesting that
7//! Cargo re-run the build script whenever `memory.x` is changed,
8//! updating `memory.x` ensures a rebuild of the application with the
9//! new memory settings.
10
11use std::env;
12use std::fs::File;
13use std::io::Write;
14use std::path::PathBuf;
15
16fn main() {
17 // Put `memory.x` in our output directory and ensure it's
18 // on the linker search path.
19 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
20 File::create(out.join("memory.x"))
21 .unwrap()
22 .write_all(include_bytes!("memory.x"))
23 .unwrap();
24 println!("cargo:rustc-link-search={}", out.display());
25
26 // By default, Cargo will re-run a build script whenever
27 // any file in the project changes. By specifying `memory.x`
28 // here, we ensure the build script is only re-run when
29 // `memory.x` is changed.
30 println!("cargo:rerun-if-changed=memory.x");
31
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
35}
diff --git a/examples/boot/application/rp/memory.x b/examples/boot/application/rp/memory.x
new file mode 100644
index 000000000..c19473114
--- /dev/null
+++ b/examples/boot/application/rp/memory.x
@@ -0,0 +1,15 @@
1MEMORY
2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
5 BOOTLOADER_STATE : ORIGIN = 0x10006000, LENGTH = 4K
6 FLASH : ORIGIN = 0x10007000, LENGTH = 512K
7 DFU : ORIGIN = 0x10087000, LENGTH = 516K
8 RAM : ORIGIN = 0x20000000, LENGTH = 256K
9}
10
11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOT2);
12__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOT2);
13
14__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOT2);
15__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOT2);
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs
new file mode 100644
index 000000000..e3ac634c2
--- /dev/null
+++ b/examples/boot/application/rp/src/bin/a.rs
@@ -0,0 +1,59 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt_rtt as _;
6use embassy_boot_rp::*;
7use embassy_executor::Spawner;
8use embassy_rp::flash::Flash;
9use embassy_rp::gpio::{Level, Output};
10use embassy_rp::watchdog::Watchdog;
11use embassy_time::{Duration, Timer};
12#[cfg(feature = "panic-probe")]
13use panic_probe as _;
14#[cfg(feature = "panic-reset")]
15use panic_reset as _;
16
17static APP_B: &[u8] = include_bytes!("../../b.bin");
18const FLASH_SIZE: usize = 2 * 1024 * 1024;
19
20#[embassy_executor::main]
21async fn main(_s: Spawner) {
22 let p = embassy_rp::init(Default::default());
23 let mut led = Output::new(p.PIN_25, Level::Low);
24
25 // Override bootloader watchdog
26 let mut watchdog = Watchdog::new(p.WATCHDOG);
27 watchdog.start(Duration::from_secs(8));
28
29 let mut flash: Flash<_, FLASH_SIZE> = Flash::new(p.FLASH);
30
31 let mut updater = FirmwareUpdater::default();
32
33 Timer::after(Duration::from_secs(5)).await;
34 watchdog.feed();
35 led.set_high();
36 let mut offset = 0;
37 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]);
38 defmt::info!("preparing update");
39 let mut writer = updater
40 .prepare_update_blocking(&mut flash)
41 .map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e)))
42 .unwrap();
43 defmt::info!("writer created, starting write");
44 for chunk in APP_B.chunks(4096) {
45 buf.0[..chunk.len()].copy_from_slice(chunk);
46 defmt::info!("writing block at offset {}", offset);
47 writer
48 .write_block_blocking(offset, &buf.0[..], &mut flash, 256)
49 .unwrap();
50 offset += chunk.len();
51 }
52 watchdog.feed();
53 defmt::info!("firmware written, marking update");
54 updater.mark_updated_blocking(&mut flash, &mut buf.0[..1]).unwrap();
55 Timer::after(Duration::from_secs(2)).await;
56 led.set_low();
57 defmt::info!("update marked, resetting");
58 cortex_m::peripheral::SCB::sys_reset();
59}
diff --git a/examples/boot/application/rp/src/bin/b.rs b/examples/boot/application/rp/src/bin/b.rs
new file mode 100644
index 000000000..47dec329c
--- /dev/null
+++ b/examples/boot/application/rp/src/bin/b.rs
@@ -0,0 +1,23 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use embassy_executor::Spawner;
6use embassy_rp::gpio;
7use embassy_time::{Duration, Timer};
8use gpio::{Level, Output};
9use {defmt_rtt as _, panic_reset as _};
10
11#[embassy_executor::main]
12async fn main(_s: Spawner) {
13 let p = embassy_rp::init(Default::default());
14 let mut led = Output::new(p.PIN_25, Level::Low);
15
16 loop {
17 led.set_high();
18 Timer::after(Duration::from_millis(100)).await;
19
20 led.set_low();
21 Timer::after(Duration::from_millis(100)).await;
22 }
23}
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml
index 3a1843562..aa279fb76 100644
--- a/examples/boot/application/stm32f3/Cargo.toml
+++ b/examples/boot/application/stm32f3/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml
index 8d9c4490e..1ec0643a6 100644
--- a/examples/boot/application/stm32f7/Cargo.toml
+++ b/examples/boot/application/stm32f7/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml
index b4314aa72..a4eefe2a5 100644
--- a/examples/boot/application/stm32h7/Cargo.toml
+++ b/examples/boot/application/stm32h7/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml
index a17d336a6..36eada29b 100644
--- a/examples/boot/application/stm32l0/Cargo.toml
+++ b/examples/boot/application/stm32l0/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml
index 683f2c860..67efda748 100644
--- a/examples/boot/application/stm32l1/Cargo.toml
+++ b/examples/boot/application/stm32l1/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml
index b879c0d76..4b2e02dd2 100644
--- a/examples/boot/application/stm32l4/Cargo.toml
+++ b/examples/boot/application/stm32l4/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml
index e3bc0e49c..fecbfc51d 100644
--- a/examples/boot/application/stm32wl/Cargo.toml
+++ b/examples/boot/application/stm32wl/Cargo.toml
@@ -13,7 +13,7 @@ embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32
13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "0.3", optional = true } 15defmt = { version = "0.3", optional = true }
16defmt-rtt = { version = "0.3", 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" }
19 19