pub enum SingleBootCommandDescription {
Erase {
start: u32,
end: u32,
},
Load {
file: String,
src: u32,
dst: u32,
len: Option<u32>,
},
CheckNonsecureFirmwareVersion {
version: u32,
},
CheckSecureFirmwareVersion {
version: u32,
},
}Expand description
Commands used to define SB2.1 files
Currently, we only need to erase and load (partial) files.
Example
Since there does not seem to exit a command to enter the bootloader, but a corrupt / missing firmware makes the MCU enter the bootloader, one way to do so is the following specification, which erases the first flash page.
[[commands]]
cmd = "Erase"
start = 0
end = 512Example
To securely flash firmware, it is advised to write the first page last, so that if flashing goes wrong or is interrupted, the MCU stays in the bootloader on next boot.
[[commands]]
cmd = "Erase"
start = 0
end = 0x8_9800
[[commands]]
# write firmware, skipping first flash page
cmd = "Load"
file = "example.sb2"
src = 512
dst = 512
[[commands]]
# write first flash page of firmware
cmd = "Load"
file = "example.sb2"
len = 512Variants
Erase
Maps to BootCommand::EraseRegion, but start and end are given in bytes.
Load
Fields
file: Stringsrc: u32source offset in bytes (default 0)
dst: u32destination offset in bytes (default 0)
Load (part) of the data reference in source to flash.
The syntax is such that if source data and destination flash were slices
src: &[u8] and dst: &mut [u8], this command would do:
let src_len = src.len() - cmd.src;
let len = cmd.len.unwrap_or(src_len);
dst[cmd.dst..][..len].copy_from_slice(&src[cmd.src..][..len]);CheckNonsecureFirmwareVersion
Fields
version: u32CheckSecureFirmwareVersion
Fields
version: u32Trait Implementations
sourceimpl Clone for SingleBootCommandDescription
impl Clone for SingleBootCommandDescription
sourcefn clone(&self) -> SingleBootCommandDescription
fn clone(&self) -> SingleBootCommandDescription
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for SingleBootCommandDescription
impl Debug for SingleBootCommandDescription
sourceimpl<'de> Deserialize<'de> for SingleBootCommandDescription
impl<'de> Deserialize<'de> for SingleBootCommandDescription
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl PartialEq<SingleBootCommandDescription> for SingleBootCommandDescription
impl PartialEq<SingleBootCommandDescription> for SingleBootCommandDescription
sourcefn eq(&self, other: &SingleBootCommandDescription) -> bool
fn eq(&self, other: &SingleBootCommandDescription) -> bool
sourceimpl<'a> TryFrom<&'a SingleBootCommandDescription> for BootCommand
impl<'a> TryFrom<&'a SingleBootCommandDescription> for BootCommand
sourcefn try_from(cmd: &'a SingleBootCommandDescription) -> Result<BootCommand>
fn try_from(cmd: &'a SingleBootCommandDescription) -> Result<BootCommand>
impl Eq for SingleBootCommandDescription
impl StructuralEq for SingleBootCommandDescription
impl StructuralPartialEq for SingleBootCommandDescription
Auto Trait Implementations
impl RefUnwindSafe for SingleBootCommandDescription
impl Send for SingleBootCommandDescription
impl Sync for SingleBootCommandDescription
impl Unpin for SingleBootCommandDescription
impl UnwindSafe for SingleBootCommandDescription
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.