diff options
| author | Ulf Lilleengen <[email protected]> | 2023-08-11 19:47:24 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2023-08-11 20:58:31 +0200 |
| commit | 55ff397c0cde8a04c41cfc228645c3fd33383cd1 (patch) | |
| tree | b73e5fee9027422cb121b892e6d467fd0f73cfe7 /examples/boot | |
| parent | c1da2c0219667085124c47d8059ffbf077adaf9d (diff) | |
boot: release flash after prepare and refactor api
This refactoring of the chip specific bootloader creates the internal boot instance and aligned
buffer in the prepare stage, so that they are automatically dropped after. This unlocks a use
case where peripherals owning the flash need to be Drop'ed before load() happens.
Diffstat (limited to 'examples/boot')
| -rw-r--r-- | examples/boot/bootloader/nrf/src/main.rs | 4 | ||||
| -rw-r--r-- | examples/boot/bootloader/rp/src/main.rs | 4 | ||||
| -rw-r--r-- | examples/boot/bootloader/stm32/src/main.rs | 4 |
3 files changed, 3 insertions, 9 deletions
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs index 72c95c02a..74e2e293f 100644 --- a/examples/boot/bootloader/nrf/src/main.rs +++ b/examples/boot/bootloader/nrf/src/main.rs | |||
| @@ -33,9 +33,7 @@ fn main() -> ! { | |||
| 33 | 33 | ||
| 34 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); | 34 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); |
| 35 | let active_offset = config.active.offset(); | 35 | let active_offset = config.active.offset(); |
| 36 | let mut bl: BootLoader<_, _, _> = BootLoader::new(config); | 36 | let bl: BootLoader = BootLoader::prepare(config); |
| 37 | |||
| 38 | bl.prepare(); | ||
| 39 | 37 | ||
| 40 | unsafe { bl.load(active_offset) } | 38 | unsafe { bl.load(active_offset) } |
| 41 | } | 39 | } |
diff --git a/examples/boot/bootloader/rp/src/main.rs b/examples/boot/bootloader/rp/src/main.rs index 6a81db804..c0e75d1ea 100644 --- a/examples/boot/bootloader/rp/src/main.rs +++ b/examples/boot/bootloader/rp/src/main.rs | |||
| @@ -29,9 +29,7 @@ fn main() -> ! { | |||
| 29 | 29 | ||
| 30 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); | 30 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); |
| 31 | let active_offset = config.active.offset(); | 31 | let active_offset = config.active.offset(); |
| 32 | let mut bl: BootLoader<_, _, _> = BootLoader::new(config); | 32 | let bl: BootLoader = BootLoader::prepare(config); |
| 33 | |||
| 34 | bl.prepare(); | ||
| 35 | 33 | ||
| 36 | unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) } | 34 | unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) } |
| 37 | } | 35 | } |
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index 262eed200..5fd9ea588 100644 --- a/examples/boot/bootloader/stm32/src/main.rs +++ b/examples/boot/bootloader/stm32/src/main.rs | |||
| @@ -27,9 +27,7 @@ fn main() -> ! { | |||
| 27 | 27 | ||
| 28 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); | 28 | let config = BootLoaderConfig::from_linkerfile_blocking(&flash); |
| 29 | let active_offset = config.active.offset(); | 29 | let active_offset = config.active.offset(); |
| 30 | let mut bl: BootLoader<_, _, _, 2048> = BootLoader::new(config); | 30 | let bl = BootLoader::prepare::<_, _, _, 2048>(config); |
| 31 | |||
| 32 | bl.prepare(); | ||
| 33 | 31 | ||
| 34 | unsafe { bl.load(BANK1_REGION.base + active_offset) } | 32 | unsafe { bl.load(BANK1_REGION.base + active_offset) } |
| 35 | } | 33 | } |
