diff options
| author | William Yager <[email protected]> | 2024-03-03 18:43:44 -0500 |
|---|---|---|
| committer | William Yager <[email protected]> | 2024-03-03 18:43:44 -0500 |
| commit | 873934aae5dd320133c383891b7b334d34d6454d (patch) | |
| tree | 4f765ba50e172aa6acf4afe287b8fb73bc65a67a | |
| parent | 02a0a15976ca815924a3780f80a7f28b90717a2b (diff) | |
ok
| -rw-r--r-- | embassy-boot-stm32/src/lib.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/embassy-boot-stm32/src/lib.rs b/embassy-boot-stm32/src/lib.rs index 4b4091ac9..708441835 100644 --- a/embassy-boot-stm32/src/lib.rs +++ b/embassy-boot-stm32/src/lib.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | mod fmt; | 4 | mod fmt; |
| 5 | 5 | ||
| 6 | pub use embassy_boot::{ | 6 | pub use embassy_boot::{ |
| 7 | AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater, | 7 | AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootError, BootLoaderConfig, FirmwareState, |
| 8 | FirmwareUpdaterConfig, State, | 8 | FirmwareUpdater, FirmwareUpdaterConfig, State, |
| 9 | }; | 9 | }; |
| 10 | use embedded_storage::nor_flash::NorFlash; | 10 | use embedded_storage::nor_flash::NorFlash; |
| 11 | 11 | ||
| @@ -20,10 +20,17 @@ impl BootLoader { | |||
| 20 | pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>( | 20 | pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>( |
| 21 | config: BootLoaderConfig<ACTIVE, DFU, STATE>, | 21 | config: BootLoaderConfig<ACTIVE, DFU, STATE>, |
| 22 | ) -> Self { | 22 | ) -> Self { |
| 23 | Self::try_prepare::<ACTIVE, DFU, STATE, BUFFER_SIZE>(config).expect("Boot prepare error") | ||
| 24 | } | ||
| 25 | |||
| 26 | /// Inspect the bootloader state and perform actions required before booting, such as swapping firmware | ||
| 27 | pub fn try_prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>( | ||
| 28 | config: BootLoaderConfig<ACTIVE, DFU, STATE>, | ||
| 29 | ) -> Result<Self, BootError> { | ||
| 23 | let mut aligned_buf = AlignedBuffer([0; BUFFER_SIZE]); | 30 | let mut aligned_buf = AlignedBuffer([0; BUFFER_SIZE]); |
| 24 | let mut boot = embassy_boot::BootLoader::new(config); | 31 | let mut boot = embassy_boot::BootLoader::new(config); |
| 25 | let state = boot.prepare_boot(aligned_buf.as_mut()).expect("Boot prepare error"); | 32 | let state = boot.prepare_boot(aligned_buf.as_mut())?; |
| 26 | Self { state } | 33 | Ok(Self { state }) |
| 27 | } | 34 | } |
| 28 | 35 | ||
| 29 | /// Boots the application. | 36 | /// Boots the application. |
