Struct Bootloader

Source
pub struct Bootloader {
    pub protocol: Protocol,
    pub vid: u16,
    pub pid: u16,
    pub uuid: u128,
}

Fields§

§protocol: Protocol§vid: u16§pid: u16§uuid: u128

Implementations§

Source§

impl Bootloader

Source

pub fn try_new(vid: Option<u16>, pid: Option<u16>) -> Result<Self>

Select a unique ROM bootloader with the given VID and PID.

Source

pub fn try_find( vid: Option<u16>, pid: Option<u16>, uuid: Option<Uuid>, ) -> Result<Self>

Attempt to find a unique ROM bootloader with the given VID, PID and UUID.

Source

pub fn find(vid: Option<u16>, pid: Option<u16>, uuid: Option<Uuid>) -> Vec<Self>

Finds all ROM bootloader with the given VID, PID and UUID.

Source

pub fn info(&self)

Source

pub fn reboot(&self)

Source

pub fn enroll_puf(&self)

Source

pub fn read_memory(&self, address: usize, length: usize) -> Vec<u8>

The reason for this wrapper is that the device aborts early if more than 512 bytes are requested. Unclear why it does this…

This is a traffic trace (requesting all of PFR in one go), removing the “surplus junk”

–> 01002000 03000002 00DE0900 000E0000 00000000 00000000 00000000 00000000 00000000 <– 03000C00 A3010002 00000000 000E0000 <– 04003800 00000000 02000000 02000000 02000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 02000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <– 04003800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ECE6A668 2922E9CC F462A95F DF81E180 E1528642 7C520098 <– 04000000 <– 03000C00 A0000002 65000000 03000000

The error is 101 = 100 + 1 = (supposedly) a flash driver “alignment” error (?!)

The interesting thing is that at the point where the device aborts, there are 8 bytes remaining, which it otherwise produces in a final

<– 04000800 2C80BA51 B067AF3C <– 03000C00 A0000002 00000000 03000000

TODO: should we just enter our desired length anyway, and handle such situations? As in retry at the new index, with the reduced length? Instead of using a fixed 512B chunking?

TODO: Need to expect errors such as: Response status = 139 (0x8b) kStatus_FLASH_NmpaUpdateNotAllowed This happens with read-memory $((0x0009_FC70)) 16, which would be the UUID

TODO: Need to expect errors such as: Response status = 10200 (0x27d8) kStatusMemoryRangeInvalid This happens with read-memory $((0x5000_0FFC)) 1, which would be the DIEID (for chip rev)

Source

pub fn read_memory_at_most_512(&self, address: usize, length: usize) -> Vec<u8>

Source

pub fn receive_sb_file<'a>( &self, data: &[u8], progress: Option<&'a dyn Fn(usize)>, )

Source

pub fn erase_flash(&self, address: usize, length: usize)

Source

pub fn write_memory(&self, address: usize, data: Vec<u8>)

Source

pub fn properties(&self) -> GetProperties<'_>

Source

pub fn all_properties(&self) -> Properties

Source

pub fn run_command(&self, cmd: Command) -> Result<Response, Error>

Trait Implementations§

Source§

impl Debug for Bootloader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Bootloader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl UuidSelectable for Bootloader

Source§

fn list() -> Vec<Self>

Returns a vector of all HID devices that appear to be ROM bootloaders

Source§

fn try_uuid(&mut self) -> Result<Uuid>

Returns the UUID associated with the thing, if it has a UUID. Read more
Source§

fn having(uuid: Uuid) -> Result<Self>

Returns the thing with the given UUID. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V