diff options
| author | Quentin Smith <[email protected]> | 2023-07-17 21:31:43 -0400 |
|---|---|---|
| committer | Quentin Smith <[email protected]> | 2023-07-17 21:31:43 -0400 |
| commit | 6f02403184eb7fb7990fb88fc9df9c4328a690a3 (patch) | |
| tree | 748f510e190bb2724750507a6e69ed1a8e08cb20 /examples/boot/bootloader/stm32 | |
| parent | d896f80405aa8963877049ed999e4aba25d6e2bb (diff) | |
| parent | 6b5df4523aa1c4902f02e803450ae4b418e0e3ca (diff) | |
Merge remote-tracking branch 'origin/main' into nrf-pdm
Diffstat (limited to 'examples/boot/bootloader/stm32')
| -rw-r--r-- | examples/boot/bootloader/stm32/Cargo.toml | 12 | ||||
| -rw-r--r-- | examples/boot/bootloader/stm32/src/main.rs | 20 |
2 files changed, 21 insertions, 11 deletions
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 491777103..6436f2fee 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml | |||
| @@ -3,17 +3,19 @@ edition = "2021" | |||
| 3 | name = "stm32-bootloader-example" | 3 | name = "stm32-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Example bootloader for STM32 chips" | 5 | description = "Example bootloader for STM32 chips" |
| 6 | license = "MIT OR Apache-2.0" | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
| 8 | defmt = { version = "0.3", optional = true } | 9 | defmt = { version = "0.3", optional = true } |
| 9 | defmt-rtt = { version = "0.3", optional = true } | 10 | defmt-rtt = { version = "0.4", optional = true } |
| 10 | 11 | ||
| 11 | embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] } | 12 | embassy-stm32 = { path = "../../../../embassy-stm32", features = ["nightly"] } |
| 12 | embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false } | 13 | embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32" } |
| 13 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 14 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 15 | embassy-sync = { path = "../../../../embassy-sync" } | ||
| 14 | cortex-m-rt = { version = "0.7" } | 16 | cortex-m-rt = { version = "0.7" } |
| 15 | embedded-storage = "0.3.0" | 17 | embedded-storage = "0.3.0" |
| 16 | embedded-storage-async = "0.3.0" | 18 | embedded-storage-async = "0.4.0" |
| 17 | cfg-if = "1.0.0" | 19 | cfg-if = "1.0.0" |
| 18 | 20 | ||
| 19 | [features] | 21 | [features] |
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index 45c511ced..262eed200 100644 --- a/examples/boot/bootloader/stm32/src/main.rs +++ b/examples/boot/bootloader/stm32/src/main.rs | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::cell::RefCell; | ||
| 5 | |||
| 4 | use cortex_m_rt::{entry, exception}; | 6 | use cortex_m_rt::{entry, exception}; |
| 5 | #[cfg(feature = "defmt")] | 7 | #[cfg(feature = "defmt")] |
| 6 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 7 | use embassy_boot_stm32::*; | 9 | use embassy_boot_stm32::*; |
| 8 | use embassy_stm32::flash::{Flash, ERASE_SIZE}; | 10 | use embassy_stm32::flash::{Flash, BANK1_REGION}; |
| 11 | use embassy_sync::blocking_mutex::Mutex; | ||
| 9 | 12 | ||
| 10 | #[entry] | 13 | #[entry] |
| 11 | fn main() -> ! { | 14 | fn main() -> ! { |
| @@ -19,11 +22,16 @@ fn main() -> ! { | |||
| 19 | } | 22 | } |
| 20 | */ | 23 | */ |
| 21 | 24 | ||
| 22 | let mut bl: BootLoader<ERASE_SIZE> = BootLoader::default(); | 25 | let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); |
| 23 | let mut flash = Flash::unlock(p.FLASH); | 26 | let flash = Mutex::new(RefCell::new(layout.bank1_region)); |
| 24 | let start = bl.prepare(&mut SingleFlashProvider::new(&mut flash)); | 27 | |
| 25 | core::mem::drop(flash); | 28 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); |
| 26 | unsafe { bl.load(start) } | 29 | let active_offset = config.active.offset(); |
| 30 | let mut bl: BootLoader<_, _, _, 2048> = BootLoader::new(config); | ||
| 31 | |||
| 32 | bl.prepare(); | ||
| 33 | |||
| 34 | unsafe { bl.load(BANK1_REGION.base + active_offset) } | ||
| 27 | } | 35 | } |
| 28 | 36 | ||
| 29 | #[no_mangle] | 37 | #[no_mangle] |
