赞
踩
本文档以SC826(MSM8953平台,Android 7)为例,描述如何对SOC镜像文件分包。
客户用QFIL刷固件的时候,由于客户自己编译生成的固件是没有经过分包的,烧录耗时较久。如果将编译生成的固件先分包后,再烧录就可以提升烧录效率。
分包准备工作
- #!/usr/bin/python
- #===========================================================================
-
- # This script parses "rawprogram.xml" looking for sparse="true" tags
- # if found, it tries to find the sparse files and updates rawprogram.xml
- # such that msp.py, T32 and QPST can program them
-
- # REFERENCES
-
- # $Header: //components/rel/boot.bf/3.3/boot_images/core/storage/tools/ptool/checksparse.py#3 $
- # $DateTime: 2016/09/12 00:31:06 $
- # $Author: pwbldsvc $
-
- # when who what, where, why
- # -------- --- -------------------------------------------------------
- # 2016-05-23 wek Merge sparse chunks in output file if the hole is small.
- # 2015-01-30 ah Add 4K Sector size support.
- # 2011-08-17 ah Added output directory to save chunks in, better error messages
- # 2011-07-26 ah Correct mistake in usage
- # 2011-07-21 ah Handles non-sparse images better
- # 2011-07-13 ah Better error messages for user experience
- # 2011-05-26 ah Output rawprogram.xml as tags/comments back, change input args
- # 2011-05-25 ab Original version
-
- # Copyright (c) 2011,2015-2016
- # Qualcomm Technologies Incorporated.
- # All Rights Reserved.
- # Qualcomm Confidential and Proprietary
- # ===========================================================================*/
-
- import struct, os, sys
- import re
- import shutil
- from types import *
- import math
- import struct
-
- if sys.version_info < (2,5):
- sys.stdout.write("\n\nERROR: This script needs Python version 2.5 or greater, detected as ")
- print sys.version_info
- sys.exit() # error
-
- from xml.etree import ElementTree as ET
- #from elementtree.ElementTree import ElementTree
- from xml.etree.ElementTree import Element, SubElement, Comment, tostring
- from xml.dom import minidom
- from copy import deepcopy
- import getopt
-
-
- """
- typedef struct sparse_header {
- __le32 magic; /* 0xed26ff3a */
- __le16 major_version; /* (0x1) - reject images with higher major versions */
- __le16 minor_version; /* (0x0) - allow images with higer minor versions */
- __le16 file_hdr_sz; /* 28 bytes for first revision of the file format */
- __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */
- __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */
- __le32 total_blks; /* total blocks in the non-sparse output image */
- __le32 total_chunks; /* total chunks in the sparse input image */
- __le32 image_checksum; /* CRC32 checksum of the original data, counting "don't care" */
- /* as 0. Standard 802.3 polynomial, use a Public Domain */
- /* table implementation */
- } sparse_header_t;
- typedef struct chunk_header {
- __le16 chunk_type; /* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */
- __le16 reserved1;
- __le32 chunk_sz; /* in blocks in output image */
- __le32 total_sz; /* in bytes of chunk input file including chunk header and data */
- } chunk_header_t;
- """
- # Struct related definitions
- sparse_header_t = struct.Struct('<LHHHHLLLL')
- chunk_header_t = struct.Struct('<HHLL')
- SPARSE_HEADER_MAGIC = 0xed26ff3a
- CHUNK_TYPE_RAW = 0xCAC1
- CHUNK_TYPE_FILL = 0xCAC2
- CHUNK_TYPE_DONT_CARE = 0xCAC3
- _LARGEFILE64_SOURCE = 1
- _FILE_OFFSET_BITS = 64
- COPY_BUF_SIZE = (1024*1024)
- #This will be malloc'ed with the size of blk_sz from the sparse file header
- SPARSE_HEADER_MAJOR_VER = 1
- SPARSE_HEADER_LEN = sparse_header_t.size
- CHUNK_HEADER_LEN = chunk_header_t.size
- def PrintBigError(sz):
- print"\t _________________ ___________ "
- print"\t| ___| ___ \\ ___ \\ _ | ___ \\"
- print"\t| |__ | |_/ / |_/ / | | | |_/ /"
- print"\t| __|| /| /| | | | / "
- print"\t| |___| |\\ \\| |\\ \\\\ \\_/ / |\\ \\ "
- print"\t\\____/\\_| \\_\\_| \\_|\\___/\\_| \\_|\n"
- if len(sz)>0:
- pri
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。