forked from Mirror/pmbootstrap
bootimg_analyze: Add support for boot header version 3 (MR 2073)
This commit is contained in:
parent
9d22989a88
commit
d764b0de58
4 changed files with 53 additions and 20 deletions
|
@ -73,25 +73,34 @@ def bootimg(args, path):
|
|||
working_dir=temp_path)
|
||||
|
||||
output = {}
|
||||
header_version = None
|
||||
# Get base, offsets, pagesize, cmdline and qcdt info
|
||||
with open(bootimg_path + "-base", 'r') as f:
|
||||
output["base"] = ("0x%08x" % int(f.read().replace('\n', ''), 16))
|
||||
with open(bootimg_path + "-kernel_offset", 'r') as f:
|
||||
output["kernel_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(bootimg_path + "-ramdisk_offset", 'r') as f:
|
||||
output["ramdisk_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(bootimg_path + "-second_offset", 'r') as f:
|
||||
output["second_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(bootimg_path + "-tags_offset", 'r') as f:
|
||||
output["tags_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(bootimg_path + "-pagesize", 'r') as f:
|
||||
output["pagesize"] = f.read().replace('\n', '')
|
||||
with open(bootimg_path + "-cmdline", 'r') as f:
|
||||
output["cmdline"] = f.read().replace('\n', '')
|
||||
# This file does not exist for example for qcdt images
|
||||
if os.path.isfile(f"{bootimg_path}-header_version"):
|
||||
with open(f"{bootimg_path}-header_version", 'r') as f:
|
||||
header_version = int(f.read().replace('\n', ''))
|
||||
|
||||
if header_version is not None and header_version >= 3:
|
||||
output["header_version"] = str(header_version)
|
||||
output["pagesize"] = "4096"
|
||||
else:
|
||||
with open(f"{bootimg_path}-base", 'r') as f:
|
||||
output["base"] = ("0x%08x" % int(f.read().replace('\n', ''), 16))
|
||||
with open(f"{bootimg_path}-kernel_offset", 'r') as f:
|
||||
output["kernel_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(f"{bootimg_path}-ramdisk_offset", 'r') as f:
|
||||
output["ramdisk_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(f"{bootimg_path}-second_offset", 'r') as f:
|
||||
output["second_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(f"{bootimg_path}-tags_offset", 'r') as f:
|
||||
output["tags_offset"] = ("0x%08x"
|
||||
% int(f.read().replace('\n', ''), 16))
|
||||
with open(f"{bootimg_path}-pagesize", 'r') as f:
|
||||
output["pagesize"] = f.read().replace('\n', '')
|
||||
|
||||
output["qcdt"] = ("true" if os.path.isfile(f"{bootimg_path}-dt") and
|
||||
os.path.getsize(f"{bootimg_path}-dt") > 0 else "false")
|
||||
output["mtk_mkimage"] = ("true" if has_mtk_header(f"{bootimg_path}-kernel",
|
||||
|
@ -99,6 +108,8 @@ def bootimg(args, path):
|
|||
output["dtb_second"] = ("true" if is_dtb(f"{bootimg_path}-second")
|
||||
else "false")
|
||||
|
||||
with open(f"{bootimg_path}-cmdline", 'r') as f:
|
||||
output["cmdline"] = f.read().replace('\n', '')
|
||||
# Mediatek: Check that the ramdisk also has a known-good label
|
||||
# We don't care about the return value, just whether it throws an exception
|
||||
# or not.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue