AmlogicSoC

Struct AmlogicSoC 

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

The main interface for interacting with Amlogic-based hardware

This provides low-level access to the Amlogic SoC on the Superbird device, allowing for memory operations, partition management, and firmware flashing.

Implementations§

Source§

impl AmlogicSoC

Source

pub fn init(callback: Option<Callback>) -> Result<Self>

Initialize a connection to an Amlogic SoC device

This will search for a connected device, put it in the correct mode if necessary, and establish a connection for flashing operations.

§Parameters
  • callback: Optional callback function to receive status updates
§Returns
  • Result<Self>: A connected AmlogicSoC instance or an error
Source

pub fn write_simple_memory(&self, address: u32, data: &[u8]) -> Result<()>

Write data to device memory

This writes a small amount of data (up to 64 bytes) to device memory. For larger transfers, use write_large_memory instead.

§Parameters
  • address: The memory address to write to
  • data: The data to write, must be <= 64 bytes
§Returns
  • Result<()>: Success or an error
Source

pub fn write_memory(&self, address: u32, data: &[u8]) -> Result<()>

Write arbitrary size data to device memory

This breaks down larger transfers into multiple write_simple_memory operations.

§Parameters
  • address: The memory address to write to
  • data: The data to write
§Returns
  • Result<()>: Success or an error
Source

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

Read a small amount of data from device memory

This reads up to 64 bytes from device memory. For larger transfers, use read_memory instead.

§Parameters
  • address: The memory address to read from
  • length: The number of bytes to read (must be <= 64)
§Returns
  • Result<Vec<u8>>: The read data or an error
Source

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

Read arbitrary size data from device memory

This breaks down larger transfers into multiple read_simple_memory operations.

§Parameters
  • address: The memory address to read from
  • length: The number of bytes to read
§Returns
  • Result<Vec<u8>>: The read data or an error
Source

pub fn run(&self, address: u32, keep_power: Option<bool>) -> Result<()>

Execute code at the specified memory address

§Parameters
  • address: The memory address to execute code from
  • keep_power: Whether to keep power on after execution
§Returns
  • Result<()>: Success or an error
Source

pub fn identify(&self) -> Result<String>

Identify the device

§Returns
  • Result<String>: The device identification string or an error
Source

pub fn write_large_memory( &self, memory_address: u32, data: &[u8], block_length: usize, append_zeros: bool, ) -> Result<()>

Write large blocks of data to device memory

This is used for writing firmware images and other large data blocks.

§Parameters
  • memory_address: The memory address to write to
  • data: The data to write
  • block_length: The size of each block to transfer
  • append_zeros: Whether to pad data with zeros to match block_length
§Returns
  • Result<()>: Success or an error
Source

pub fn write_large_memory_to_disk<R: Read, F: Fn(FlashProgress)>( &self, disk_address: u32, reader: &mut R, data_size: usize, block_length: usize, append_zeros: bool, progress_callback: F, ) -> Result<()>

Write large blocks of data directly to a disk address with progress tracking

§Parameters
  • disk_address: The disk address to write to
  • reader: A reader providing the data to write
  • data_size: The total size of data to write
  • block_length: The size of each block to transfer
  • append_zeros: Whether to pad data with zeros to match block_length
  • progress_callback: Function to call with progress updates
§Returns
  • Result<()>: Success or an error
Source

pub fn write_amlc_data(&self, offset: u32, data: &[u8]) -> Result<()>

Source

pub fn write_amlc_data_packet( &self, seq: u8, amlc_offset: u32, data: &[u8], ) -> Result<()>

Source

pub fn get_boot_amlc(&self) -> Result<(u32, u32)>

Source

pub fn bl2_boot( &self, bl2: Option<&[u8]>, bootloader: Option<&[u8]>, ) -> Result<()>

Execute the BL2 boot sequence

This boots the device using the specified BL2 and bootloader binaries.

§Parameters
  • bl2: Optional BL2 binary data (uses built-in if None)
  • bootloader: Optional bootloader binary data (uses built-in if None)
§Returns
  • Result<()>: Success or an error
Source

pub fn bulkcmd(&self, command: &str) -> Result<String>

Send a bulk command to the device

§Parameters
  • command: The command string to send
§Returns
  • Result<String>: The command response or an error
Source

pub fn validate_partition_size( &self, part_name: &str, part_info: &PartitionInfo, ) -> Result<usize>

Validate the size of a partition

§Parameters
  • part_name: The name of the partition
  • part_info: Partition information
§Returns
  • Result<usize>: The validated partition size or an error
Source

pub fn restore_partition<R: Read, F: Fn(FlashProgress)>( &self, part_name: &str, part_size: usize, reader: R, file_size: usize, progress_callback: F, ) -> Result<()>

Restore a partition from a data source

§Parameters
  • part_name: The name of the partition to restore
  • part_size: The size of the partition
  • reader: A reader providing the partition data
  • file_size: The size of the data being read
  • progress_callback: Function to call with progress updates
§Returns
  • Result<()>: Success or an error
Source

pub fn unbrick(&self) -> Result<()>

Execute the unbrick procedure

This writes the emergency unbrick image to the device.

§Returns
  • Result<()>: Success or an error
Source

pub fn host_setup() -> Result<()>

Set up the host environment for USB access

On Linux, this creates udev rules to allow access to the device.

§Returns
  • Result<()>: Success or an error

Trait Implementations§

Source§

impl Clone for AmlogicSoC

Source§

fn clone(&self) -> AmlogicSoC

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for AmlogicSoC

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more