Skip to main content

SebootFrame

Struct SebootFrame 

Source
pub struct SebootFrame { /* private fields */ }
Expand description

SEBOOT command frame builder.

Builds frames according to the official HiSilicon SEBOOT protocol.

Implementations§

Source§

impl SebootFrame

Source

pub fn new(frame_type: CommandType) -> Self

Create a new frame with the given command type.

Source

pub fn handshake(baud_rate: u32) -> Self

Build handshake frame.

Frame structure (18 bytes total):

  • Magic: 4 bytes (0xDEADBEEF)
  • Length: 2 bytes (0x0012 = 18)
  • Type: 1 byte (0xF0)
  • ~Type: 1 byte (0x0F)
  • BaudRate: 4 bytes
  • DataBits: 1 byte
  • StopBits: 1 byte
  • Parity: 1 byte
  • FlowCtrl: 1 byte
  • CRC16: 2 bytes
Source

pub fn set_baud_rate(baud_rate: u32) -> Self

Build set baud rate frame.

Source

pub fn download_flash_image( addr: u32, len: u32, erase_size: u32, is_rom: bool, ) -> Self

Build download flash image frame.

Frame structure (24 bytes total):

  • Magic: 4 bytes
  • Length: 2 bytes (0x0018 = 24)
  • Type: 1 byte (0xD2)
  • ~Type: 1 byte (0x2D)
  • FileAddr: 4 bytes (flash address)
  • FileLen: 4 bytes (data length)
  • EraseSize: 4 bytes (size to erase, 0xFFFFFFFF for full)
  • Formal: 1 byte (0x00 for normal)
  • ~Formal: 1 byte (0xFF)
  • CRC16: 2 bytes
Source

pub fn download_factory_bin(addr: u32, len: u32, erase_size: u32) -> Self

Build download factory bin frame.

Source

pub fn download_nv( addr: u32, len: u32, erase_size: u32, erase_all: bool, ) -> Self

Build download NV frame.

Source

pub fn download_otp_efuse(len: u32) -> Self

Build download OTP/eFuse frame.

Source

pub fn download_version(len: u32) -> Self

Build download version frame.

Source

pub fn upload_data(addr: u32, len: u32) -> Self

Build upload data frame.

Source

pub fn read_otp_efuse(start_bit: u16, bit_width: u16) -> Self

Build read OTP/eFuse frame.

Source

pub fn flash_lock(param: u16) -> Self

Build flash lock frame.

Source

pub fn reset() -> Self

Build reset frame.

Source

pub fn switch_dfu() -> Self

Build switch to DFU mode frame.

Source

pub fn erase_all() -> Self

Build erase all flash frame.

Source

pub fn build(&self) -> Vec<u8>

Build the complete frame data.

Source

pub fn command_type(&self) -> CommandType

Get the command type.

Trait Implementations§

Source§

impl Debug for SebootFrame

Source§

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

Formats the value using the given formatter. 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<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, 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.