uimg.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pyUBoot 作者: molejar 项目源码 文件源码
def get_img_type(data, offset=0):
    """ Help function for extracting image fom raw data
    :param data: The raw data as byte array
    :param offset: The offset
    :return: Image type and offset where image start
    """
    while True:
        if (offset + Header.SIZE) > len(data):
            raise Exception("Error: Not an U-Boot image !")

        (header_mn, header_crc,) = unpack_from('!2L', data, offset)
        # Check the magic number if is U-Boot image
        if header_mn == 0x27051956:
            header = bytearray(data[offset:offset+Header.SIZE])
            header[4:8] = [0]*4
            if header_crc == CRC32(header):
                break
        offset += 4

    (image_type,) = unpack_from('B', data, offset + 30)

    return image_type, offset
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号