aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/bootloader/rp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/boot/bootloader/rp')
-rw-r--r--examples/boot/bootloader/rp/Cargo.toml1
-rw-r--r--examples/boot/bootloader/rp/src/main.rs16
2 files changed, 12 insertions, 5 deletions
diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml
index bf9226993..8d60f18be 100644
--- a/examples/boot/bootloader/rp/Cargo.toml
+++ b/examples/boot/bootloader/rp/Cargo.toml
@@ -11,6 +11,7 @@ defmt-rtt = { version = "0.4", optional = true }
11 11
12embassy-rp = { path = "../../../../embassy-rp", features = ["nightly"] } 12embassy-rp = { path = "../../../../embassy-rp", features = ["nightly"] }
13embassy-boot-rp = { path = "../../../../embassy-boot/rp" } 13embassy-boot-rp = { path = "../../../../embassy-boot/rp" }
14embassy-sync = { path = "../../../../embassy-sync" }
14embassy-time = { path = "../../../../embassy-time", features = ["nightly"] } 15embassy-time = { path = "../../../../embassy-time", features = ["nightly"] }
15 16
16cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 17cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
diff --git a/examples/boot/bootloader/rp/src/main.rs b/examples/boot/bootloader/rp/src/main.rs
index 8129591fa..6a81db804 100644
--- a/examples/boot/bootloader/rp/src/main.rs
+++ b/examples/boot/bootloader/rp/src/main.rs
@@ -1,10 +1,13 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::cell::RefCell;
5
4use cortex_m_rt::{entry, exception}; 6use cortex_m_rt::{entry, exception};
5#[cfg(feature = "defmt")] 7#[cfg(feature = "defmt")]
6use defmt_rtt as _; 8use defmt_rtt as _;
7use embassy_boot_rp::*; 9use embassy_boot_rp::*;
10use embassy_sync::blocking_mutex::Mutex;
8use embassy_time::Duration; 11use embassy_time::Duration;
9 12
10const FLASH_SIZE: usize = 2 * 1024 * 1024; 13const FLASH_SIZE: usize = 2 * 1024 * 1024;
@@ -21,13 +24,16 @@ fn main() -> ! {
21 } 24 }
22 */ 25 */
23 26
24 let mut bl: BootLoader = BootLoader::default();
25 let flash = WatchdogFlash::<FLASH_SIZE>::start(p.FLASH, p.WATCHDOG, Duration::from_secs(8)); 27 let flash = WatchdogFlash::<FLASH_SIZE>::start(p.FLASH, p.WATCHDOG, Duration::from_secs(8));
26 let mut flash = BootFlash::new(flash); 28 let flash = Mutex::new(RefCell::new(flash));
27 let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); 29
28 core::mem::drop(flash); 30 let config = BootLoaderConfig::from_linkerfile_blocking(&flash);
31 let active_offset = config.active.offset();
32 let mut bl: BootLoader<_, _, _> = BootLoader::new(config);
33
34 bl.prepare();
29 35
30 unsafe { bl.load(start) } 36 unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) }
31} 37}
32 38
33#[no_mangle] 39#[no_mangle]