Align chip specific boot projects with new prepare_boot() signature
This commit is contained in:
@ -7,26 +7,24 @@ mod fmt;
|
||||
pub use embassy_boot::{AlignedBuffer, BootFlash, FirmwareUpdater, FlashConfig, Partition, SingleFlashConfig, State};
|
||||
|
||||
/// A bootloader for STM32 devices.
|
||||
pub struct BootLoader<const PAGE_SIZE: usize, const WRITE_SIZE: usize> {
|
||||
pub struct BootLoader<const BUFFER_SIZE: usize> {
|
||||
boot: embassy_boot::BootLoader,
|
||||
magic: AlignedBuffer<WRITE_SIZE>,
|
||||
page: AlignedBuffer<PAGE_SIZE>,
|
||||
aligned_buf: AlignedBuffer<BUFFER_SIZE>,
|
||||
}
|
||||
|
||||
impl<const PAGE_SIZE: usize, const WRITE_SIZE: usize> BootLoader<PAGE_SIZE, WRITE_SIZE> {
|
||||
impl<const BUFFER_SIZE: usize> BootLoader<BUFFER_SIZE> {
|
||||
/// Create a new bootloader instance using the supplied partitions for active, dfu and state.
|
||||
pub fn new(active: Partition, dfu: Partition, state: Partition) -> Self {
|
||||
Self {
|
||||
boot: embassy_boot::BootLoader::new(active, dfu, state),
|
||||
magic: AlignedBuffer([0; WRITE_SIZE]),
|
||||
page: AlignedBuffer([0; PAGE_SIZE]),
|
||||
aligned_buf: AlignedBuffer([0; BUFFER_SIZE]),
|
||||
}
|
||||
}
|
||||
|
||||
/// Inspect the bootloader state and perform actions required before booting, such as swapping
|
||||
/// firmware.
|
||||
pub fn prepare<F: FlashConfig>(&mut self, flash: &mut F) -> usize {
|
||||
match self.boot.prepare_boot(flash, self.magic.as_mut(), self.page.as_mut()) {
|
||||
match self.boot.prepare_boot(flash, self.aligned_buf.as_mut()) {
|
||||
Ok(_) => embassy_stm32::flash::FLASH_BASE + self.boot.boot_address(),
|
||||
Err(_) => panic!("boot prepare error!"),
|
||||
}
|
||||
@ -49,7 +47,7 @@ impl<const PAGE_SIZE: usize, const WRITE_SIZE: usize> BootLoader<PAGE_SIZE, WRIT
|
||||
}
|
||||
}
|
||||
|
||||
impl<const PAGE_SIZE: usize, const WRITE_SIZE: usize> Default for BootLoader<PAGE_SIZE, WRITE_SIZE> {
|
||||
impl<const BUFFER_SIZE: usize> Default for BootLoader<BUFFER_SIZE> {
|
||||
/// Create a new bootloader instance using parameters from linker script
|
||||
fn default() -> Self {
|
||||
extern "C" {
|
||||
|
Reference in New Issue
Block a user