From 834cc7f8771cc2a86f9942f4da8616a05c4193fe Mon Sep 17 00:00:00 2001 From: Dylan Van Assche Date: Tue, 22 Jun 2021 22:04:05 +0200 Subject: [PATCH] install: allow to use last block for embedding (MR 2069) Devices such as ODROIDs have binaries use which every single block for embedding. Do not raise an error when binaries are touching, but not overlapping, each other when embedding these binaries during installation. Add a test for this scenario, which fails when reverting the change. Co-Authored-By: Oliver Smith --- pmb/install/_install.py | 4 ++-- test/test_install.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index 89dd98df..be8f5705 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -465,8 +465,8 @@ def generate_binary_list(args, suffix, step): 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)): + 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 " f"other firmware image: {binary}") diff --git a/test/test_install.py b/test/test_install.py index 057acfed..af7a193a 100644 --- a/test/test_install.py +++ b/test/test_install.py @@ -160,3 +160,23 @@ def test_generate_binary_list(args): with pytest.raises(RuntimeError) as e: func(args, suffix, step) assert str(e.value).startswith("The following firmware binary does not") + + # Binaries are touching but not overlapping + # boot_part_start is at 2 sectors (1024 b) + # |-----|---------------------|-------------------|------------------- + # | … | binary2.bin (100 b) | small.bin (600 b) | /boot part start … + # |-----|---------------------|-------------------|------------------- + # 0 324 424 1024 + step = 1 + binaries = "binary2.bin:324,small.bin:424" + args.deviceinfo = {"sd_embed_firmware": binaries, + "boot_part_start": "2"} + assert func(args, suffix, step) == [('binary2.bin', 324), + ('small.bin', 424)] + + # Same layout written with different order in sd_embed_firmware + binaries = "small.bin:424,binary2.bin:324" + args.deviceinfo = {"sd_embed_firmware": binaries, + "boot_part_start": "2"} + assert func(args, suffix, step) == [('small.bin', 424), + ('binary2.bin', 324)]