pmb.parse.bootimg: Add preliminary support for header v2 (MR 2194)
This includes setting header_version="2" as well as dtb_offset according to the input boot.img when header v2 is detected. Also adds the following previously missed deviceinfo_attributes: * "header_version" * "bootimg_custom_args" And fixes failing tests now that header_version is always parsed from boot.img files.
This commit is contained in:
parent
c36e4a43ac
commit
255e69be5e
|
@ -721,10 +721,13 @@ deviceinfo_attributes = [
|
||||||
"generate_legacy_uboot_initfs",
|
"generate_legacy_uboot_initfs",
|
||||||
"kernel_cmdline",
|
"kernel_cmdline",
|
||||||
"generate_bootimg",
|
"generate_bootimg",
|
||||||
|
"header_version",
|
||||||
"bootimg_qcdt",
|
"bootimg_qcdt",
|
||||||
"bootimg_mtk_mkimage",
|
"bootimg_mtk_mkimage",
|
||||||
"bootimg_dtb_second",
|
"bootimg_dtb_second",
|
||||||
|
"bootimg_custom_args",
|
||||||
"flash_offset_base",
|
"flash_offset_base",
|
||||||
|
"flash_offset_dtb",
|
||||||
"flash_offset_kernel",
|
"flash_offset_kernel",
|
||||||
"flash_offset_ramdisk",
|
"flash_offset_ramdisk",
|
||||||
"flash_offset_second",
|
"flash_offset_second",
|
||||||
|
|
|
@ -119,15 +119,15 @@ def bootimg(args, path):
|
||||||
working_dir=temp_path)
|
working_dir=temp_path)
|
||||||
|
|
||||||
output = {}
|
output = {}
|
||||||
header_version = None
|
header_version = 0
|
||||||
# Get base, offsets, pagesize, cmdline and qcdt info
|
# Get base, offsets, pagesize, cmdline and qcdt info
|
||||||
# This file does not exist for example for qcdt images
|
# This file does not exist for example for qcdt images
|
||||||
if os.path.isfile(f"{bootimg_path}-header_version"):
|
if os.path.isfile(f"{bootimg_path}-header_version"):
|
||||||
with open(f"{bootimg_path}-header_version", 'r') as f:
|
with open(f"{bootimg_path}-header_version", 'r') as f:
|
||||||
header_version = int(f.read().replace('\n', ''))
|
header_version = int(f.read().replace('\n', ''))
|
||||||
|
output["header_version"] = str(header_version)
|
||||||
|
|
||||||
if header_version is not None and header_version >= 3:
|
if header_version >= 3:
|
||||||
output["header_version"] = str(header_version)
|
|
||||||
output["pagesize"] = "4096"
|
output["pagesize"] = "4096"
|
||||||
else:
|
else:
|
||||||
with open(f"{bootimg_path}-base", 'r') as f:
|
with open(f"{bootimg_path}-base", 'r') as f:
|
||||||
|
@ -147,6 +147,11 @@ def bootimg(args, path):
|
||||||
with open(f"{bootimg_path}-pagesize", 'r') as f:
|
with open(f"{bootimg_path}-pagesize", 'r') as f:
|
||||||
output["pagesize"] = f.read().replace('\n', '')
|
output["pagesize"] = f.read().replace('\n', '')
|
||||||
|
|
||||||
|
if header_version == 2:
|
||||||
|
with open(f"{bootimg_path}-dtb_offset", 'r') as f:
|
||||||
|
output["dtb_offset"] = ("0x%08x"
|
||||||
|
% int(f.read().replace('\n', ''), 16))
|
||||||
|
|
||||||
output["qcdt"] = ("true" if os.path.isfile(f"{bootimg_path}-dt") and
|
output["qcdt"] = ("true" if os.path.isfile(f"{bootimg_path}-dt") and
|
||||||
os.path.getsize(f"{bootimg_path}-dt") > 0 else "false")
|
os.path.getsize(f"{bootimg_path}-dt") > 0 else "false")
|
||||||
output["mtk_mkimage"] = ("true" if check_mtk_bootimg(bootimg_path)
|
output["mtk_mkimage"] = ("true" if check_mtk_bootimg(bootimg_path)
|
||||||
|
|
|
@ -43,7 +43,8 @@ def test_bootimg_invalid_file(args):
|
||||||
|
|
||||||
def test_bootimg_normal(args):
|
def test_bootimg_normal(args):
|
||||||
path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
|
path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
|
||||||
output = {"base": "0x80000000",
|
output = {"header_version": "0",
|
||||||
|
"base": "0x80000000",
|
||||||
"kernel_offset": "0x00008000",
|
"kernel_offset": "0x00008000",
|
||||||
"ramdisk_offset": "0x04000000",
|
"ramdisk_offset": "0x04000000",
|
||||||
"second_offset": "0x00f00000",
|
"second_offset": "0x00f00000",
|
||||||
|
@ -73,7 +74,8 @@ def test_bootimg_qcdt(args):
|
||||||
|
|
||||||
def test_bootimg_mtk_mkimage(args):
|
def test_bootimg_mtk_mkimage(args):
|
||||||
path = pmb_test.const.testdata + "/bootimg/mtk_mkimage-boot.img"
|
path = pmb_test.const.testdata + "/bootimg/mtk_mkimage-boot.img"
|
||||||
output = {"base": "0x10000000",
|
output = {"header_version": "0",
|
||||||
|
"base": "0x10000000",
|
||||||
"kernel_offset": "0x00008000",
|
"kernel_offset": "0x00008000",
|
||||||
"ramdisk_offset": "0x01000000",
|
"ramdisk_offset": "0x01000000",
|
||||||
"second_offset": "0x00f00000",
|
"second_offset": "0x00f00000",
|
||||||
|
@ -88,7 +90,8 @@ def test_bootimg_mtk_mkimage(args):
|
||||||
|
|
||||||
def test_bootimg_mtk_mkimage_recovery(args):
|
def test_bootimg_mtk_mkimage_recovery(args):
|
||||||
path = pmb_test.const.testdata + "/bootimg/mtk_mkimage-boot-recovery.img"
|
path = pmb_test.const.testdata + "/bootimg/mtk_mkimage-boot-recovery.img"
|
||||||
output = {"base": "0x80000000",
|
output = {"header_version": "0",
|
||||||
|
"base": "0x80000000",
|
||||||
"kernel_offset": "0x00008000",
|
"kernel_offset": "0x00008000",
|
||||||
"ramdisk_offset": "0x04000000",
|
"ramdisk_offset": "0x04000000",
|
||||||
"second_offset": "0x00f00000",
|
"second_offset": "0x00f00000",
|
||||||
|
@ -103,7 +106,8 @@ def test_bootimg_mtk_mkimage_recovery(args):
|
||||||
|
|
||||||
def test_bootimg_dtb_second(args):
|
def test_bootimg_dtb_second(args):
|
||||||
path = pmb_test.const.testdata + "/bootimg/dtb-second-boot.img"
|
path = pmb_test.const.testdata + "/bootimg/dtb-second-boot.img"
|
||||||
output = {"base": "0x00000000",
|
output = {"header_version": "0",
|
||||||
|
"base": "0x00000000",
|
||||||
"kernel_offset": "0x00008000",
|
"kernel_offset": "0x00008000",
|
||||||
"ramdisk_offset": "0x02000000",
|
"ramdisk_offset": "0x02000000",
|
||||||
"second_offset": "0x00f00000",
|
"second_offset": "0x00f00000",
|
||||||
|
|
|
@ -91,7 +91,8 @@ def test_questions_bootimg(args, monkeypatch):
|
||||||
|
|
||||||
bootimg_path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
|
bootimg_path = pmb_test.const.testdata + "/bootimg/normal-boot.img"
|
||||||
fake_answers(monkeypatch, [bootimg_path])
|
fake_answers(monkeypatch, [bootimg_path])
|
||||||
output = {"base": "0x80000000",
|
output = {"header_version": "0",
|
||||||
|
"base": "0x80000000",
|
||||||
"kernel_offset": "0x00008000",
|
"kernel_offset": "0x00008000",
|
||||||
"ramdisk_offset": "0x04000000",
|
"ramdisk_offset": "0x04000000",
|
||||||
"second_offset": "0x00f00000",
|
"second_offset": "0x00f00000",
|
||||||
|
|
Loading…
Reference in New Issue