pub struct BootLoader {
pub state: State,
}Expand description
A bootloader for CH32 devices.
Fields§
§state: StateThe reported state of the bootloader after preparing for boot
Implementations§
Source§impl BootLoader
impl BootLoader
Sourcepub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>(
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
) -> Self
pub fn prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>( config: BootLoaderConfig<ACTIVE, DFU, STATE>, ) -> Self
Inspect the bootloader state and perform actions required before booting, such as swapping firmware.
Panics if the swap can not be performed, see BootLoader::try_prepare for the fallible version.
Sourcepub fn try_prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>(
config: BootLoaderConfig<ACTIVE, DFU, STATE>,
) -> Result<Self, BootError>
pub fn try_prepare<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash, const BUFFER_SIZE: usize>( config: BootLoaderConfig<ACTIVE, DFU, STATE>, ) -> Result<Self, BootError>
Inspect the bootloader state and perform actions required before booting, such as swapping firmware.
Sourcepub unsafe fn load(self, start: u32) -> !
pub unsafe fn load(self, start: u32) -> !
Boots the application.
start is an offset from the start of internal flash (the same numbering
as the __bootloader_* symbols), not a bus address, so
loader.load(active_start()) jumps to FLASH_BASE + active_start().
All interrupts are masked before jumping. The application startup code of
qingke-rt sets up the stack pointer, the global pointer, mtvec and the
interrupt controller itself, so nothing else has to be done.
§Safety
This jumps to the code (and uses the stack) placed in the active partition. The caller must make sure a valid application has been programmed there.