aboutsummaryrefslogtreecommitdiff
path: root/examples/boot/application/rp/src
diff options
context:
space:
mode:
authorkalkyl <[email protected]>2023-01-03 22:58:56 +0100
committerkalkyl <[email protected]>2023-01-03 22:58:56 +0100
commit9428c40c8de1285271a5e6ba9ad2a7fed8a9475e (patch)
tree30d672bdc0d80f714dfbb5338c9dd41f5ae82061 /examples/boot/application/rp/src
parent0aa2a9ac2705ead5186d4c1d53bba55064c33db7 (diff)
embassy-boot (rp): Add WatchdogFlash
Diffstat (limited to 'examples/boot/application/rp/src')
-rw-r--r--examples/boot/application/rp/src/bin/a.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs
index 3736c9141..e3ac634c2 100644
--- a/examples/boot/application/rp/src/bin/a.rs
+++ b/examples/boot/application/rp/src/bin/a.rs
@@ -7,6 +7,7 @@ use embassy_boot_rp::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::flash::Flash; 8use embassy_rp::flash::Flash;
9use embassy_rp::gpio::{Level, Output}; 9use embassy_rp::gpio::{Level, Output};
10use embassy_rp::watchdog::Watchdog;
10use embassy_time::{Duration, Timer}; 11use embassy_time::{Duration, Timer};
11#[cfg(feature = "panic-probe")] 12#[cfg(feature = "panic-probe")]
12use panic_probe as _; 13use panic_probe as _;
@@ -21,11 +22,16 @@ async fn main(_s: Spawner) {
21 let p = embassy_rp::init(Default::default()); 22 let p = embassy_rp::init(Default::default());
22 let mut led = Output::new(p.PIN_25, Level::Low); 23 let mut led = Output::new(p.PIN_25, Level::Low);
23 24
25 // Override bootloader watchdog
26 let mut watchdog = Watchdog::new(p.WATCHDOG);
27 watchdog.start(Duration::from_secs(8));
28
24 let mut flash: Flash<_, FLASH_SIZE> = Flash::new(p.FLASH); 29 let mut flash: Flash<_, FLASH_SIZE> = Flash::new(p.FLASH);
25 30
26 let mut updater = FirmwareUpdater::default(); 31 let mut updater = FirmwareUpdater::default();
27 32
28 Timer::after(Duration::from_secs(5)).await; 33 Timer::after(Duration::from_secs(5)).await;
34 watchdog.feed();
29 led.set_high(); 35 led.set_high();
30 let mut offset = 0; 36 let mut offset = 0;
31 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]); 37 let mut buf: AlignedBuffer<4096> = AlignedBuffer([0; 4096]);
@@ -43,6 +49,7 @@ async fn main(_s: Spawner) {
43 .unwrap(); 49 .unwrap();
44 offset += chunk.len(); 50 offset += chunk.len();
45 } 51 }
52 watchdog.feed();
46 defmt::info!("firmware written, marking update"); 53 defmt::info!("firmware written, marking update");
47 updater.mark_updated_blocking(&mut flash, &mut buf.0[..1]).unwrap(); 54 updater.mark_updated_blocking(&mut flash, &mut buf.0[..1]).unwrap();
48 Timer::after(Duration::from_secs(2)).await; 55 Timer::after(Duration::from_secs(2)).await;