当前位置:   article > 正文

高通镜像文件分包方法_checksparse.py

checksparse.py

文档说明

本文档以SC826(MSM8953平台,Android 7)为例,描述如何对SOC镜像文件分包。

应用背景

客户用QFIL刷固件的时候,由于客户自己编译生成的固件是没有经过分包的,烧录耗时较久。如果将编译生成的固件先分包后,再烧录就可以提升烧录效率。

分包准备工作

  1. 准备分包脚本checksparse.py
  1. #!/usr/bin/python
  2. #===========================================================================
  3. # This script parses "rawprogram.xml" looking for sparse="true" tags
  4. # if found, it tries to find the sparse files and updates rawprogram.xml
  5. # such that msp.py, T32 and QPST can program them
  6. # REFERENCES
  7. # $Header: //components/rel/boot.bf/3.3/boot_images/core/storage/tools/ptool/checksparse.py#3 $
  8. # $DateTime: 2016/09/12 00:31:06 $
  9. # $Author: pwbldsvc $
  10. # when who what, where, why
  11. # -------- --- -------------------------------------------------------
  12. # 2016-05-23 wek Merge sparse chunks in output file if the hole is small.
  13. # 2015-01-30 ah Add 4K Sector size support.
  14. # 2011-08-17 ah Added output directory to save chunks in, better error messages
  15. # 2011-07-26 ah Correct mistake in usage
  16. # 2011-07-21 ah Handles non-sparse images better
  17. # 2011-07-13 ah Better error messages for user experience
  18. # 2011-05-26 ah Output rawprogram.xml as tags/comments back, change input args
  19. # 2011-05-25 ab Original version
  20. # Copyright (c) 2011,2015-2016
  21. # Qualcomm Technologies Incorporated.
  22. # All Rights Reserved.
  23. # Qualcomm Confidential and Proprietary
  24. # ===========================================================================*/
  25. import struct, os, sys
  26. import re
  27. import shutil
  28. from types import *
  29. import math
  30. import struct
  31. if sys.version_info < (2,5):
  32. sys.stdout.write("\n\nERROR: This script needs Python version 2.5 or greater, detected as ")
  33. print sys.version_info
  34. sys.exit() # error
  35. from xml.etree import ElementTree as ET
  36. #from elementtree.ElementTree import ElementTree
  37. from xml.etree.ElementTree import Element, SubElement, Comment, tostring
  38. from xml.dom import minidom
  39. from copy import deepcopy
  40. import getopt
  41. """
  42. typedef struct sparse_header {
  43. __le32 magic; /* 0xed26ff3a */
  44. __le16 major_version; /* (0x1) - reject images with higher major versions */
  45. __le16 minor_version; /* (0x0) - allow images with higer minor versions */
  46. __le16 file_hdr_sz; /* 28 bytes for first revision of the file format */
  47. __le16 chunk_hdr_sz; /* 12 bytes for first revision of the file format */
  48. __le32 blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */
  49. __le32 total_blks; /* total blocks in the non-sparse output image */
  50. __le32 total_chunks; /* total chunks in the sparse input image */
  51. __le32 image_checksum; /* CRC32 checksum of the original data, counting "don't care" */
  52. /* as 0. Standard 802.3 polynomial, use a Public Domain */
  53. /* table implementation */
  54. } sparse_header_t;
  55. typedef struct chunk_header {
  56. __le16 chunk_type; /* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */
  57. __le16 reserved1;
  58. __le32 chunk_sz; /* in blocks in output image */
  59. __le32 total_sz; /* in bytes of chunk input file including chunk header and data */
  60. } chunk_header_t;
  61. """
  62. # Struct related definitions
  63. sparse_header_t = struct.Struct('<LHHHHLLLL')
  64. chunk_header_t = struct.Struct('<HHLL')
  65. SPARSE_HEADER_MAGIC = 0xed26ff3a
  66. CHUNK_TYPE_RAW = 0xCAC1
  67. CHUNK_TYPE_FILL = 0xCAC2
  68. CHUNK_TYPE_DONT_CARE = 0xCAC3
  69. _LARGEFILE64_SOURCE = 1
  70. _FILE_OFFSET_BITS = 64
  71. COPY_BUF_SIZE = (1024*1024)
  72. #This will be malloc'ed with the size of blk_sz from the sparse file header
  73. SPARSE_HEADER_MAJOR_VER = 1
  74. SPARSE_HEADER_LEN = sparse_header_t.size
  75. CHUNK_HEADER_LEN = chunk_header_t.size
  76. def PrintBigError(sz):
  77. print"\t _________________ ___________ "
  78. print"\t| ___| ___ \\ ___ \\ _ | ___ \\"
  79. print"\t| |__ | |_/ / |_/ / | | | |_/ /"
  80. print"\t| __|| /| /| | | | / "
  81. print"\t| |___| |\\ \\| |\\ \\\\ \\_/ / |\\ \\ "
  82. print"\t\\____/\\_| \\_\\_| \\_|\\___/\\_| \\_|\n"
  83. if len(sz)>0:
  84. pri
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/445152
推荐阅读
相关标签
  

闽ICP备14008679号