pub fn write_uboot_image(&self, uboot: &[u8]) -> Result<(u32, u32), Error> {
        if uboot.len() <= UBOOT_HEADER_SIZE as usize {
            bail!("insufficient U-boot size");
        }

        let image_type = get_image_type(uboot)?;
        if image_type != UbootImageType::Firmware {
            bail!("expected firmware image, got {} image", image_type)
        }

        let data_size = BigEndian::read_u32(&uboot[12..16]);
        let load_addr = BigEndian::read_u32(&uboot[16..20]);
        if data_size != uboot.len() as u32 - UBOOT_HEADER_SIZE {
            bail!(
                "U-Boot image data size mismatch: expected {:#010x}, got {:#010x}",
                uboot.len() as u32 - UBOOT_HEADER_SIZE,
                data_size
            );
        }
        // TODO (from sunxi-fel): Verify image data integrity using the checksum field `ih_dcrc`,
        // available from `BigEndian::read_u32(&uboot[24..28])`.
        //
        // However, this requires *CRC* routines that mimic their *U-Boot* counterparts, namely
        // `image_check_dcrc()` in `${U-BOOT}/common/image.c` and `crc_wd()` in
        // `${U-BOOT}/lib/crc32.c`.

        // If we get here, we're "good to go" (i.e. actually write the data)
        self.fel_write(load_addr, &uboot[UBOOT_HEADER_SIZE as usize..])
            .context("could not write the U-Boot image to the device")?;

        Ok((load_addr, data_size))
    }
/// This function tests a given buffer for a valid *U-Boot* image. Upon success, the image data
/// gets transferred to the default memory address stored within the image header; and the
/// function returns the *U-Boot* entry point (offset) and size values, in that order.
This function tests a given buffer for a valid *U-Boot* image. Upon success, the image data
gets transferred to the default memory address stored within the image header; and the
function returns the *U-Boot* entry point (offset) and size values, in that order.
This function tests a given buffer for a valid * U - Boot * image . Upon success the image data gets transferred to the default memory address stored within the image header ; and the function returns the * U - Boot * entry point ( offset ) and size values in that order .
pub fn write_uboot_image(&self, uboot: &[u8]) -> Result<(u32, u32), Error> {
        if uboot.len() <= UBOOT_HEADER_SIZE as usize {
            bail!("insufficient U-boot size");
        }
        let image_type = get_image_type(uboot)?;
        if image_type != UbootImageType::Firmware {
            bail!("expected firmware image, got {} image", image_type)
        }
        let data_size = BigEndian::read_u32(&uboot[12..16]);
        let load_addr = BigEndian::read_u32(&uboot[16..20]);
        if data_size != uboot.len() as u32 - UBOOT_HEADER_SIZE {
            bail!(
                "U-Boot image data size mismatch: expected {:#010x}, got {:#010x}",
                uboot.len() as u32 - UBOOT_HEADER_SIZE,
                data_size
            );
        }
        // TODO (from sunxi-fel): Verify image data integrity using the checksum field `ih_dcrc`,
        // available from `BigEndian::read_u32(&uboot[24..28])`.
        //
        // However, this requires *CRC* routines that mimic their *U-Boot* counterparts, namely
        // `image_check_dcrc()` in `${U-BOOT}/common/image.c` and `crc_wd()` in
        // `${U-BOOT}/lib/crc32.c`.
        // If we get here, we're "good to go" (i.e. actually write the data)
        self.fel_write(load_addr, &uboot[UBOOT_HEADER_SIZE as usize..])
            .context("could not write the U-Boot image to the device")?;
        Ok((load_addr, data_size))
    }
pub fn write_uboot_image ( & self , uboot : & [ u8 ] ) -> Result < ( u32 , u32 ) , Error > { if uboot . len ( ) <= UBOOT_HEADER_SIZE as usize { bail ! ( " " ) ; } let image_type = get_image_type ( uboot ) ? ; if image_type != UbootImageType :: Firmware { bail ! ( " " image_type ) } let data_size = BigEndian :: read_u32 ( & uboot [ 12 .. 16 ] ) ; let load_addr = BigEndian :: read_u32 ( & uboot [ 16 .. 20 ] ) ; if data_size != uboot . len ( ) as u32 - UBOOT_HEADER_SIZE { bail ! ( " " uboot len ( ) as u32 UBOOT_HEADER_SIZE data_size ) ; } // TODO (from sunxi-fel): Verify image data integrity using the checksum field `ih_dcrc`, // available from `BigEndian::read_u32(&uboot[24..28])`. // // However, this requires *CRC* routines that mimic their *U-Boot* counterparts, namely // `image_check_dcrc()` in `${U-BOOT}/common/image.c` and `crc_wd()` in // `${U-BOOT}/lib/crc32.c`. // If we get here, we're "good to go" (i.e. actually write the data) self . fel_write ( load_addr , & uboot [ UBOOT_HEADER_SIZE as usize .. ] ) . context ( " " ) ? ; Ok ( ( load_addr , data_size ) ) }
This function tests a given buffer for a valid *U-Boot* image.
This function tests a given buffer for a valid * U - Boot * image .
&self
uboot
&[u8]
&self
uboot
&[u8]