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 = 512§Example
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
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]);Fields
CheckNonsecureFirmwareVersion
CheckSecureFirmwareVersion
Trait Implementations§
Source§impl Clone for SingleBootCommandDescription
impl Clone for SingleBootCommandDescription
Source§fn clone(&self) -> SingleBootCommandDescription
fn clone(&self) -> SingleBootCommandDescription
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SingleBootCommandDescription
impl Debug for SingleBootCommandDescription
Source§impl<'de> Deserialize<'de> for SingleBootCommandDescription
impl<'de> Deserialize<'de> for SingleBootCommandDescription
Source§fn 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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for SingleBootCommandDescription
impl PartialEq for SingleBootCommandDescription
Source§fn eq(&self, other: &SingleBootCommandDescription) -> bool
fn eq(&self, other: &SingleBootCommandDescription) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<'a> TryFrom<&'a SingleBootCommandDescription> for BootCommand
impl<'a> TryFrom<&'a SingleBootCommandDescription> for BootCommand
Source§fn try_from(cmd: &'a SingleBootCommandDescription) -> Result<BootCommand>
fn try_from(cmd: &'a SingleBootCommandDescription) -> Result<BootCommand>
Performs the conversion.
impl Eq for SingleBootCommandDescription
impl StructuralPartialEq for SingleBootCommandDescription
Auto Trait Implementations§
impl Freeze for SingleBootCommandDescription
impl RefUnwindSafe for SingleBootCommandDescription
impl Send for SingleBootCommandDescription
impl Sync for SingleBootCommandDescription
impl Unpin for SingleBootCommandDescription
impl UnwindSafe for SingleBootCommandDescription
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more