diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index d6f6f0f9..74e113d0 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -721,10 +721,13 @@ deviceinfo_attributes = [ "generate_legacy_uboot_initfs", "kernel_cmdline", "generate_bootimg", + "header_version", "bootimg_qcdt", "bootimg_mtk_mkimage", "bootimg_dtb_second", + "bootimg_custom_args", "flash_offset_base", + "flash_offset_dtb", "flash_offset_kernel", "flash_offset_ramdisk", "flash_offset_second", diff --git a/pmb/parse/bootimg.py b/pmb/parse/bootimg.py index 1eb667ff..59172840 100644 --- a/pmb/parse/bootimg.py +++ b/pmb/parse/bootimg.py @@ -119,15 +119,15 @@ def bootimg(args, path): working_dir=temp_path) output = {} - header_version = None + header_version = 0 # Get base, offsets, pagesize, cmdline and qcdt info # 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', '')) + output["header_version"] = str(header_version) - if header_version is not None and header_version >= 3: - output["header_version"] = str(header_version) + if header_version >= 3: output["pagesize"] = "4096" else: 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: 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 os.path.getsize(f"{bootimg_path}-dt") > 0 else "false") output["mtk_mkimage"] = ("true" if check_mtk_bootimg(bootimg_path) diff --git a/test/test_bootimg.py b/test/test_bootimg.py index 7a7483c4..a3ee42eb 100644 --- a/test/test_bootimg.py +++ b/test/test_bootimg.py @@ -43,7 +43,8 @@ def test_bootimg_invalid_file(args): def test_bootimg_normal(args): path = pmb_test.const.testdata + "/bootimg/normal-boot.img" - output = {"base": "0x80000000", + output = {"header_version": "0", + "base": "0x80000000", "kernel_offset": "0x00008000", "ramdisk_offset": "0x04000000", "second_offset": "0x00f00000", @@ -73,7 +74,8 @@ def test_bootimg_qcdt(args): def test_bootimg_mtk_mkimage(args): path = pmb_test.const.testdata + "/bootimg/mtk_mkimage-boot.img" - output = {"base": "0x10000000", + output = {"header_version": "0", + "base": "0x10000000", "kernel_offset": "0x00008000", "ramdisk_offset": "0x01000000", "second_offset": "0x00f00000", @@ -88,7 +90,8 @@ def test_bootimg_mtk_mkimage(args): def test_bootimg_mtk_mkimage_recovery(args): path = pmb_test.const.testdata + "/bootimg/mtk_mkimage-boot-recovery.img" - output = {"base": "0x80000000", + output = {"header_version": "0", + "base": "0x80000000", "kernel_offset": "0x00008000", "ramdisk_offset": "0x04000000", "second_offset": "0x00f00000", @@ -103,7 +106,8 @@ def test_bootimg_mtk_mkimage_recovery(args): def test_bootimg_dtb_second(args): path = pmb_test.const.testdata + "/bootimg/dtb-second-boot.img" - output = {"base": "0x00000000", + output = {"header_version": "0", + "base": "0x00000000", "kernel_offset": "0x00008000", "ramdisk_offset": "0x02000000", "second_offset": "0x00f00000", diff --git a/test/test_questions.py b/test/test_questions.py index 075cfb5e..6cf3c059 100644 --- a/test/test_questions.py +++ b/test/test_questions.py @@ -91,7 +91,8 @@ def test_questions_bootimg(args, monkeypatch): bootimg_path = pmb_test.const.testdata + "/bootimg/normal-boot.img" fake_answers(monkeypatch, [bootimg_path]) - output = {"base": "0x80000000", + output = {"header_version": "0", + "base": "0x80000000", "kernel_offset": "0x00008000", "ramdisk_offset": "0x04000000", "second_offset": "0x00f00000",