diff options
| author | Ulf Lilleengen <[email protected]> | 2022-04-20 13:49:59 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2022-04-27 15:17:18 +0200 |
| commit | 484e0acc638c27366e19275c32db9c8487ea8fba (patch) | |
| tree | 5649591dad34cadcb28503f94c1bbca0bf5578a1 /examples/boot/src/bin | |
| parent | 9c283cd44504d6d9d6f9e352e4c7a8d043bd673f (diff) | |
Add stm32 flash + bootloader support
* Add flash drivers for L0, L1, L4, WB and WL. Not tested for WB, but
should be similar to WL.
* Add embassy-boot-stm32 for bootloading on STM32.
* Add flash examples and bootloader examples
* Update stm32-data
Diffstat (limited to 'examples/boot/src/bin')
| -rw-r--r-- | examples/boot/src/bin/a.rs | 48 | ||||
| -rw-r--r-- | examples/boot/src/bin/b.rs | 26 |
2 files changed, 0 insertions, 74 deletions
diff --git a/examples/boot/src/bin/a.rs b/examples/boot/src/bin/a.rs deleted file mode 100644 index d18b508cc..000000000 --- a/examples/boot/src/bin/a.rs +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![macro_use] | ||
| 4 | #![feature(generic_associated_types)] | ||
| 5 | #![feature(type_alias_impl_trait)] | ||
| 6 | |||
| 7 | use embassy_boot_nrf::updater; | ||
| 8 | use embassy_nrf::{ | ||
| 9 | gpio::{Input, Pull}, | ||
| 10 | gpio::{Level, Output, OutputDrive}, | ||
| 11 | nvmc::Nvmc, | ||
| 12 | Peripherals, | ||
| 13 | }; | ||
| 14 | use embassy_traits::adapter::BlockingAsync; | ||
| 15 | use panic_reset as _; | ||
| 16 | |||
| 17 | static APP_B: &[u8] = include_bytes!("../../b.bin"); | ||
| 18 | |||
| 19 | #[embassy::main] | ||
| 20 | async fn main(_s: embassy::executor::Spawner, p: Peripherals) { | ||
| 21 | let mut button = Input::new(p.P0_11, Pull::Up); | ||
| 22 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 23 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); | ||
| 24 | //let mut button = Input::new(p.P1_02, Pull::Up); | ||
| 25 | |||
| 26 | let nvmc = Nvmc::new(p.NVMC); | ||
| 27 | let mut nvmc = BlockingAsync::new(nvmc); | ||
| 28 | |||
| 29 | loop { | ||
| 30 | button.wait_for_any_edge().await; | ||
| 31 | if button.is_low() { | ||
| 32 | let mut updater = updater::new(); | ||
| 33 | let mut offset = 0; | ||
| 34 | for chunk in APP_B.chunks(4096) { | ||
| 35 | let mut buf: [u8; 4096] = [0; 4096]; | ||
| 36 | buf[..chunk.len()].copy_from_slice(chunk); | ||
| 37 | updater | ||
| 38 | .write_firmware(offset, &buf, &mut nvmc, 4096) | ||
| 39 | .await | ||
| 40 | .unwrap(); | ||
| 41 | offset += chunk.len(); | ||
| 42 | } | ||
| 43 | updater.mark_update(&mut nvmc).await.unwrap(); | ||
| 44 | led.set_high(); | ||
| 45 | cortex_m::peripheral::SCB::sys_reset(); | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
diff --git a/examples/boot/src/bin/b.rs b/examples/boot/src/bin/b.rs deleted file mode 100644 index 18bb6330c..000000000 --- a/examples/boot/src/bin/b.rs +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![macro_use] | ||
| 4 | #![feature(generic_associated_types)] | ||
| 5 | #![feature(type_alias_impl_trait)] | ||
| 6 | |||
| 7 | use embassy::time::{Duration, Timer}; | ||
| 8 | use embassy_nrf::{ | ||
| 9 | gpio::{Level, Output, OutputDrive}, | ||
| 10 | Peripherals, | ||
| 11 | }; | ||
| 12 | |||
| 13 | use panic_reset as _; | ||
| 14 | |||
| 15 | #[embassy::main] | ||
| 16 | async fn main(_s: embassy::executor::Spawner, p: Peripherals) { | ||
| 17 | let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); | ||
| 18 | //let mut led = Output::new(p.P1_10, Level::Low, OutputDrive::Standard); | ||
| 19 | |||
| 20 | loop { | ||
| 21 | led.set_high(); | ||
| 22 | Timer::after(Duration::from_millis(300)).await; | ||
| 23 | led.set_low(); | ||
| 24 | Timer::after(Duration::from_millis(300)).await; | ||
| 25 | } | ||
| 26 | } | ||
