From 63acc8ddcd4298775fad342b23a50accd3fdffd5 Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Sun, 13 Jun 2021 17:07:50 +0200 Subject: [PATCH] install: add option to disable overlap detection Some devices such as ODROID XU3/XU4/HC1/HC2/MC1 have boot binaries which overlap when flasing them to uboot partition. This is not allowed by pmbootstrap. Add a deviceinfo option to disable this check. --- pmb/config/__init__.py | 1 + pmb/install/_install.py | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index 10350f00..b53c2bdd 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -424,6 +424,7 @@ deviceinfo_attributes = [ "rootfs_image_sector_size", "sd_embed_firmware", "sd_embed_firmware_step_size", + "sd_embed_check_overlap", "partition_blacklist", "boot_part_start", "root_filesystem", diff --git a/pmb/install/_install.py b/pmb/install/_install.py index 143ddfe5..7deb21ef 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -391,6 +391,13 @@ def embed_firmware(args, suffix): device_rootfs = mount_device_rootfs(args, suffix) binaries = args.deviceinfo["sd_embed_firmware"].split(",") + detect_overlap = True + if args.deviceinfo["sd_embed_detect_overlap"]: + detect_overlap = (args.deviceinfo["sd_embed_detect_overlap"] == "true") + + if not detect_overlap: + logging.info("Embedding firmware overlap detection disabled") + # Perform three checks prior to writing binaries to disk: 1) that binaries # exist, 2) that binaries do not extend into the first partition, 3) that # binaries do not overlap each other @@ -420,14 +427,16 @@ def embed_firmware(args, suffix): max_size)) # Insure that the firmware does not conflict with any other firmware # that will be embedded - binary_start = offset * step - binary_end = binary_start + binary_size - for start, end in binary_ranges.items(): - if ((binary_start >= start and binary_start <= end) or - (binary_end >= start and binary_end <= end)): - raise RuntimeError("The firmware overlaps with at least one " - "other firmware image: {}".format(binary)) - binary_ranges[binary_start] = binary_end + if detect_overlap: + binary_start = offset * step + binary_end = binary_start + binary_size + for start, end in binary_ranges.items(): + if ((binary_start >= start and binary_start <= end) or + (binary_end >= start and binary_end <= end)): + raise RuntimeError("The firmware overlaps with at least " + f"one other firmware image: {binary}") + binary_ranges[binary_start] = binary_end + binary_list.append((binary, offset)) # Write binaries to disk