aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/rp/src
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-05-30 14:03:31 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-05-30 14:03:31 +0200
commit36e00caf4dc70905b735531c0d5634addd026954 (patch)
tree01d3bbb3b7f1ab522f9a1fc651f48197ce355927 /examples/boot/application/rp/src
parentc2aca45b8d3785007da20ce007d6a6e352fac1a0 (diff)
Align examples
Diffstat (limited to 'examples/boot/application/rp/src')
-rw-r--r--examples/boot/application/rp/src/bin/a.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs
index 47f1d16d8..3fa908b63 100644
--- a/examples/boot/application/rp/src/bin/a.rs
+++ b/examples/boot/application/rp/src/bin/a.rs
@@ -9,6 +9,9 @@ use embassy_rp::flash::Flash;
9use embassy_rp::gpio::{Level, Output}; 9use embassy_rp::gpio::{Level, Output};
10use embassy_rp::watchdog::Watchdog; 10use embassy_rp::watchdog::Watchdog;
11use embassy_time::{Duration, Timer}; 11use embassy_time::{Duration, Timer};
12use embassy_sync::blocking_mutex::Mutex;
13use core::cell::RefCell;
14use embedded_storage::nor_flash::NorFlash;
12#[cfg(feature = "panic-probe")] 15#[cfg(feature = "panic-probe")]
13use panic_probe as _; 16use panic_probe as _;
14#[cfg(feature = "panic-reset")] 17#[cfg(feature = "panic-reset")]
@@ -26,9 +29,11 @@ async fn main(_s: Spawner) {
26 let mut watchdog = Watchdog::new(p.WATCHDOG); 29 let mut watchdog = Watchdog::new(p.WATCHDOG);
27 watchdog.start(Duration::from_secs(8)); 30 watchdog.start(Duration::from_secs(8));
28 31
29 let mut flash: Flash<_, FLASH_SIZE> = Flash::new_blocking(p.FLASH); 32 let flash: Flash<_, FLASH_SIZE> = Flash::new(p.FLASH);
33 let flash = Mutex::new(RefCell::new(flash));
30 34
31 let mut updater = FirmwareUpdater::default(); 35 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
36 let mut updater = BlockingFirmwareUpdater::new(config);
32 37
33 Timer::after(Duration::from_secs(5)).await; 38 Timer::after(Duration::from_secs(5)).await;
34 watchdog.feed(); 39 watchdog.feed();
@@ -36,8 +41,8 @@ async fn main(_s: Spawner) {
36 let mut offset = 0; 41 let mut offset = 0;
37 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]); 42 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]);
38 defmt::info!("preparing update"); 43 defmt::info!("preparing update");
39 let mut writer = updater 44 let writer = updater
40 .prepare_update_blocking(&mut flash) 45 .prepare_update()
41 .map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e))) 46 .map_err(|e| defmt::warn!("E: {:?}", defmt::Debug2Format(&e)))
42 .unwrap(); 47 .unwrap();
43 defmt::info!("writer created, starting write"); 48 defmt::info!("writer created, starting write");
@@ -45,13 +50,13 @@ async fn main(_s: Spawner) {
45 buf.0[..chunk.len()].copy_from_slice(chunk); 50 buf.0[..chunk.len()].copy_from_slice(chunk);
46 defmt::info!("writing block at offset {}", offset); 51 defmt::info!("writing block at offset {}", offset);
47 writer 52 writer
48 .write_block_blocking(offset, &buf.0[..], &mut flash, 256) 53 .write(offset, &buf.0[..])
49 .unwrap(); 54 .unwrap();
50 offset += chunk.len(); 55 offset += chunk.len() as u32;
51 } 56 }
52 watchdog.feed(); 57 watchdog.feed();
53 defmt::info!("firmware written, marking update"); 58 defmt::info!("firmware written, marking update");
54 updater.mark_updated_blocking(&mut flash, &mut buf.0[..1]).unwrap(); 59 updater.mark_updated(&mut buf.0[..1]).unwrap();
55 Timer::after(Duration::from_secs(2)).await; 60 Timer::after(Duration::from_secs(2)).await;
56 led.set_low(); 61 led.set_low();
57 defmt::info!("update marked, resetting"); 62 defmt::info!("update marked, resetting");