aboutsummaryrefslogtreecommitdiff
path: root/examples/boot
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2022-04-19 14:42:38 +0200
committerUlf Lilleengen <[email protected]>2022-04-19 20:07:06 +0200
commit2afff617f652d0fdcfa9ffcfd49062e3d2c996a3 (patch)
treebc531122365086cd24a12a9331c94f9f042cad3a /examples/boot
parente2ed41b3832db17633ae8ae1ee9391639c3a9229 (diff)
Support multiple flash instances in embassy-boot
* Add FlashProvider and FlashConfig traits to define flash characteristics * Use traits in bootloader to retrieve flash handles and for copying data between flash instances * Add convenience implementations for using a single flash instance.
Diffstat (limited to 'examples/boot')
-rw-r--r--examples/boot/.cargo/config.toml1
-rw-r--r--examples/boot/Cargo.toml4
-rw-r--r--examples/boot/src/bin/a.rs5
3 files changed, 4 insertions, 6 deletions
diff --git a/examples/boot/.cargo/config.toml b/examples/boot/.cargo/config.toml
index d044e9b4c..bbe06fd03 100644
--- a/examples/boot/.cargo/config.toml
+++ b/examples/boot/.cargo/config.toml
@@ -1,5 +1,4 @@
1[unstable] 1[unstable]
2namespaced-features = true
3build-std = ["core"] 2build-std = ["core"]
4build-std-features = ["panic_immediate_abort"] 3build-std-features = ["panic_immediate_abort"]
5 4
diff --git a/examples/boot/Cargo.toml b/examples/boot/Cargo.toml
index 36e2e169d..2da659478 100644
--- a/examples/boot/Cargo.toml
+++ b/examples/boot/Cargo.toml
@@ -5,8 +5,8 @@ name = "embassy-boot-examples"
5version = "0.1.0" 5version = "0.1.0"
6 6
7[dependencies] 7[dependencies]
8embassy = { version = "0.1.0", path = "../../embassy" } 8embassy = { version = "0.1.0", path = "../../embassy", features = ["nightly"] }
9embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["time-driver-rtc1", "gpiote"] } 9embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] }
10embassy-boot-nrf = { version = "0.1.0", path = "../../embassy-boot/nrf" } 10embassy-boot-nrf = { version = "0.1.0", path = "../../embassy-boot/nrf" }
11embassy-traits = { version = "0.1.0", path = "../../embassy-traits" } 11embassy-traits = { version = "0.1.0", path = "../../embassy-traits" }
12 12
diff --git a/examples/boot/src/bin/a.rs b/examples/boot/src/bin/a.rs
index 88880e688..d18b508cc 100644
--- a/examples/boot/src/bin/a.rs
+++ b/examples/boot/src/bin/a.rs
@@ -12,7 +12,6 @@ use embassy_nrf::{
12 Peripherals, 12 Peripherals,
13}; 13};
14use embassy_traits::adapter::BlockingAsync; 14use embassy_traits::adapter::BlockingAsync;
15use embedded_hal::digital::v2::InputPin;
16use panic_reset as _; 15use panic_reset as _;
17 16
18static APP_B: &[u8] = include_bytes!("../../b.bin"); 17static APP_B: &[u8] = include_bytes!("../../b.bin");
@@ -29,14 +28,14 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) {
29 28
30 loop { 29 loop {
31 button.wait_for_any_edge().await; 30 button.wait_for_any_edge().await;
32 if button.is_low().unwrap() { 31 if button.is_low() {
33 let mut updater = updater::new(); 32 let mut updater = updater::new();
34 let mut offset = 0; 33 let mut offset = 0;
35 for chunk in APP_B.chunks(4096) { 34 for chunk in APP_B.chunks(4096) {
36 let mut buf: [u8; 4096] = [0; 4096]; 35 let mut buf: [u8; 4096] = [0; 4096];
37 buf[..chunk.len()].copy_from_slice(chunk); 36 buf[..chunk.len()].copy_from_slice(chunk);
38 updater 37 updater
39 .write_firmware(offset, &buf, &mut nvmc) 38 .write_firmware(offset, &buf, &mut nvmc, 4096)
40 .await 39 .await
41 .unwrap(); 40 .unwrap();
42 offset += chunk.len(); 41 offset += chunk.len();