diff options
| author | William Yager <[email protected]> | 2024-03-03 18:50:27 -0500 |
|---|---|---|
| committer | William Yager <[email protected]> | 2024-03-03 18:50:27 -0500 |
| commit | cde6e2b58be4910c73b3738bb3b0e264c8ac6049 (patch) | |
| tree | 4b59eba00c939b84f49701e88fb08d658e930a1e /embassy-boot-rp/src | |
| parent | 873934aae5dd320133c383891b7b334d34d6454d (diff) | |
ok
Diffstat (limited to 'embassy-boot-rp/src')
| -rw-r--r-- | embassy-boot-rp/src/lib.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/embassy-boot-rp/src/lib.rs b/embassy-boot-rp/src/lib.rs index 07a5b3f4d..d88e6dfc6 100644 --- a/embassy-boot-rp/src/lib.rs +++ b/embassy-boot-rp/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 embassy_rp::flash::{Blocking, Flash, ERASE_SIZE}; | 10 | use embassy_rp::flash::{Blocking, Flash, ERASE_SIZE}; |
| 11 | use embassy_rp::peripherals::{FLASH, WATCHDOG}; | 11 | use embassy_rp::peripherals::{FLASH, WATCHDOG}; |
| @@ -21,10 +21,17 @@ impl<const BUFFER_SIZE: usize> BootLoader<BUFFER_SIZE> { | |||
| 21 | pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>( | 21 | pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>( |
| 22 | config: BootLoaderConfig<ACTIVE, DFU, STATE>, | 22 | config: BootLoaderConfig<ACTIVE, DFU, STATE>, |
| 23 | ) -> Self { | 23 | ) -> Self { |
| 24 | Self::try_prepare::<ACTIVE, DFU, STATE>(config).expect("Boot prepare error") | ||
| 25 | } | ||
| 26 | |||
| 27 | /// Inspect the bootloader state and perform actions required before booting, such as swapping firmware | ||
| 28 | pub fn try_prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>( | ||
| 29 | config: BootLoaderConfig<ACTIVE, DFU, STATE>, | ||
| 30 | ) -> Result<Self, BootError> { | ||
| 24 | let mut aligned_buf = AlignedBuffer([0; BUFFER_SIZE]); | 31 | let mut aligned_buf = AlignedBuffer([0; BUFFER_SIZE]); |
| 25 | let mut boot = embassy_boot::BootLoader::new(config); | 32 | let mut boot = embassy_boot::BootLoader::new(config); |
| 26 | boot.prepare_boot(aligned_buf.as_mut()).expect("Boot prepare error"); | 33 | let state = boot.prepare_boot(aligned_buf.as_mut())?; |
| 27 | Self | 34 | Ok(Self { state }) |
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | /// Boots the application. | 37 | /// Boots the application. |
