diff options
| author | Badr Bouslikhin <[email protected]> | 2024-02-06 16:25:45 +0100 |
|---|---|---|
| committer | Badr Bouslikhin <[email protected]> | 2024-02-06 16:25:45 +0100 |
| commit | c267cb9ab764176bc8514535f4db8ac2331e30ce (patch) | |
| tree | c997f07d290e0c30f1a583a15ee1557368569ce2 /embassy-boot/src/boot_loader.rs | |
| parent | ad7d4494fad12f98c7e8e2b776bc12453a66be9a (diff) | |
feat: enhance bootloader for multiple flash support
Diffstat (limited to 'embassy-boot/src/boot_loader.rs')
| -rw-r--r-- | embassy-boot/src/boot_loader.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/embassy-boot/src/boot_loader.rs b/embassy-boot/src/boot_loader.rs index e568001bc..54ae8a34b 100644 --- a/embassy-boot/src/boot_loader.rs +++ b/embassy-boot/src/boot_loader.rs | |||
| @@ -49,16 +49,20 @@ pub struct BootLoaderConfig<ACTIVE, DFU, STATE> { | |||
| 49 | pub state: STATE, | 49 | pub state: STATE, |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | impl<'a, FLASH: NorFlash> | 52 | impl<'a, ActiveFlash: NorFlash, DFUFlash: NorFlash, StateFlash: NorFlash> |
| 53 | BootLoaderConfig< | 53 | BootLoaderConfig< |
| 54 | BlockingPartition<'a, NoopRawMutex, FLASH>, | 54 | BlockingPartition<'a, NoopRawMutex, ActiveFlash>, |
| 55 | BlockingPartition<'a, NoopRawMutex, FLASH>, | 55 | BlockingPartition<'a, NoopRawMutex, DFUFlash>, |
| 56 | BlockingPartition<'a, NoopRawMutex, FLASH>, | 56 | BlockingPartition<'a, NoopRawMutex, StateFlash>, |
| 57 | > | 57 | > |
| 58 | { | 58 | { |
| 59 | /// Create a bootloader config from the flash and address symbols defined in the linkerfile | 59 | /// Create a bootloader config from the flash and address symbols defined in the linkerfile |
| 60 | // #[cfg(target_os = "none")] | 60 | // #[cfg(target_os = "none")] |
| 61 | pub fn from_linkerfile_blocking(flash: &'a Mutex<NoopRawMutex, RefCell<FLASH>>) -> Self { | 61 | pub fn from_linkerfile_blocking( |
| 62 | active_flash: &'a Mutex<NoopRawMutex, RefCell<ActiveFlash>>, | ||
| 63 | dfu_flash: &'a Mutex<NoopRawMutex, RefCell<DFUFlash>>, | ||
| 64 | state_flash: &'a Mutex<NoopRawMutex, RefCell<StateFlash>>, | ||
| 65 | ) -> Self { | ||
| 62 | extern "C" { | 66 | extern "C" { |
| 63 | static __bootloader_state_start: u32; | 67 | static __bootloader_state_start: u32; |
| 64 | static __bootloader_state_end: u32; | 68 | static __bootloader_state_end: u32; |
| @@ -73,21 +77,21 @@ impl<'a, FLASH: NorFlash> | |||
| 73 | let end = &__bootloader_active_end as *const u32 as u32; | 77 | let end = &__bootloader_active_end as *const u32 as u32; |
| 74 | trace!("ACTIVE: 0x{:x} - 0x{:x}", start, end); | 78 | trace!("ACTIVE: 0x{:x} - 0x{:x}", start, end); |
| 75 | 79 | ||
| 76 | BlockingPartition::new(flash, start, end - start) | 80 | BlockingPartition::new(active_flash, start, end - start) |
| 77 | }; | 81 | }; |
| 78 | let dfu = unsafe { | 82 | let dfu = unsafe { |
| 79 | let start = &__bootloader_dfu_start as *const u32 as u32; | 83 | let start = &__bootloader_dfu_start as *const u32 as u32; |
| 80 | let end = &__bootloader_dfu_end as *const u32 as u32; | 84 | let end = &__bootloader_dfu_end as *const u32 as u32; |
| 81 | trace!("DFU: 0x{:x} - 0x{:x}", start, end); | 85 | trace!("DFU: 0x{:x} - 0x{:x}", start, end); |
| 82 | 86 | ||
| 83 | BlockingPartition::new(flash, start, end - start) | 87 | BlockingPartition::new(dfu_flash, start, end - start) |
| 84 | }; | 88 | }; |
| 85 | let state = unsafe { | 89 | let state = unsafe { |
| 86 | let start = &__bootloader_state_start as *const u32 as u32; | 90 | let start = &__bootloader_state_start as *const u32 as u32; |
| 87 | let end = &__bootloader_state_end as *const u32 as u32; | 91 | let end = &__bootloader_state_end as *const u32 as u32; |
| 88 | trace!("STATE: 0x{:x} - 0x{:x}", start, end); | 92 | trace!("STATE: 0x{:x} - 0x{:x}", start, end); |
| 89 | 93 | ||
| 90 | BlockingPartition::new(flash, start, end - start) | 94 | BlockingPartition::new(state_flash, start, end - start) |
| 91 | }; | 95 | }; |
| 92 | 96 | ||
| 93 | Self { active, dfu, state } | 97 | Self { active, dfu, state } |
