diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-05-30 20:08:01 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-30 20:08:01 +0000 |
| commit | f5d0d28ac3cfcb74eaa59bbe984b7969a0743724 (patch) | |
| tree | 9b156e69b39cd79f4b977dbd59f6ae1d5cbfc902 /examples/boot/bootloader/stm32/src/main.rs | |
| parent | 05688934a131b023e147e7c4c24afd1d7b01582a (diff) | |
| parent | c22d2b5b5bbc5e3c7d3a039e90b50d39809a10f2 (diff) | |
Merge pull request #1498 from rmja/remove-bootloader-partitions
Remove bootloader partitions
Diffstat (limited to 'examples/boot/bootloader/stm32/src/main.rs')
| -rw-r--r-- | examples/boot/bootloader/stm32/src/main.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index f81fdbc5f..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; | 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,12 +22,16 @@ fn main() -> ! { | |||
| 19 | } | 22 | } |
| 20 | */ | 23 | */ |
| 21 | 24 | ||
| 22 | let mut bl: BootLoader<2048> = BootLoader::default(); | ||
| 23 | let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); | 25 | let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); |
| 24 | let mut flash = BootFlash::new(layout.bank1_region); | 26 | let flash = Mutex::new(RefCell::new(layout.bank1_region)); |
| 25 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); | 27 | |
| 26 | core::mem::drop(flash); | 28 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); |
| 27 | 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) } | ||
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | #[no_mangle] | 37 | #[no_mangle] |
