diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-04-05 11:12:40 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-05 11:12:40 +0000 |
| commit | eed2b123253380d67f76bf1d0272688e8053bc9a (patch) | |
| tree | d5d415fd27d7507107fc89a6d45ec46b49dc4f6c /examples/boot | |
| parent | 064ec9581e33fdd42f89ff75984254ccfec3f6c2 (diff) | |
| parent | 2a49e11cb0ffd3e0d9a0cc94444f293de523b47f (diff) | |
Merge #1297
1297: feat(stm32): Support multiple flash regions r=Dirbaio a=rmja
This depends on https://github.com/embassy-rs/stm32-data/pull/176
This is a general overhaul of the flash module to support multiple erase sizes.
Overall this PR contains:
* Move complex sector computation to embassy-hal-common to allow for tests
* Implement `FlashRegion` trait for each available flash region
* Add Flash::into_regions() to get each region.
* Implement embedded-storage traits for each region to support different erase sizes
* Split family write operations into begin/do/end
* Protection against simultaneous writes/erases for each split region is done through a global mutex
Co-authored-by: Rasmus Melchior Jacobsen <[email protected]>
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples/boot')
| -rw-r--r-- | examples/boot/bootloader/stm32/src/main.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index b8027d19a..49c21920b 100644 --- a/examples/boot/bootloader/stm32/src/main.rs +++ b/examples/boot/bootloader/stm32/src/main.rs | |||
| @@ -5,7 +5,7 @@ use cortex_m_rt::{entry, exception}; | |||
| 5 | #[cfg(feature = "defmt")] | 5 | #[cfg(feature = "defmt")] |
| 6 | use defmt_rtt as _; | 6 | use defmt_rtt as _; |
| 7 | use embassy_boot_stm32::*; | 7 | use embassy_boot_stm32::*; |
| 8 | use embassy_stm32::flash::{Flash, ERASE_SIZE}; | 8 | use embassy_stm32::flash::Flash; |
| 9 | 9 | ||
| 10 | #[entry] | 10 | #[entry] |
| 11 | fn main() -> ! { | 11 | fn main() -> ! { |
| @@ -19,9 +19,10 @@ fn main() -> ! { | |||
| 19 | } | 19 | } |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | let mut bl: BootLoader<ERASE_SIZE> = BootLoader::default(); | 22 | let mut bl: BootLoader<2048> = BootLoader::default(); |
| 23 | let flash = Flash::new(p.FLASH); | 23 | let flash = Flash::new(p.FLASH); |
| 24 | let mut flash = BootFlash::new(flash); | 24 | let layout = flash.into_regions(); |
| 25 | let mut flash = BootFlash::new(layout.bank1_region); | ||
| 25 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); | 26 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); |
| 26 | core::mem::drop(flash); | 27 | core::mem::drop(flash); |
| 27 | unsafe { bl.load(start) } | 28 | unsafe { bl.load(start) } |
