From 9f1dd64fa1024b5c6373ae8441b64014b97fecf2 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Sat, 11 Jan 2020 19:24:37 -0800 Subject: [PATCH] install/partition: allow specifying a different boot partition start (!1856) This adds a new deviceinfo parameter, 'boot_part_start' which accepts an int and indicates the number of sectors from the start of the drive to place the boot partition. The librem5 devkit (and actual phone) u-boot has grown beyond the 2048 sector space previously before the boot partition, so this is necessary in order to boot pmos on this device. --- pmb/install/_install.py | 3 ++- pmb/install/partition.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index dcb71a20..fd38b583 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -340,7 +340,8 @@ def embed_firmware(args): "{}".format("/usr/share/" + binary)) # Insure that embedding the firmware will not overrun the # first partition - max_size = (2048 * 512) - (offset * step) + boot_part_start = args.deviceinfo["boot_part_start"] or "2048" + max_size = (int(boot_part_start) * 512) - (offset * step) binary_size = os.path.getsize(binary_path) if binary_size > max_size: raise RuntimeError("The firmware is too big to embed in the " diff --git a/pmb/install/partition.py b/pmb/install/partition.py index 18589e1c..03afccf8 100644 --- a/pmb/install/partition.py +++ b/pmb/install/partition.py @@ -74,9 +74,11 @@ def partition(args, size_boot): # sometimes "fails to inform the kernel". In case it really failed with # partitioning, the follow-up mounting/formatting will not work, so it # will stop there (see #463). + boot_part_start = args.deviceinfo["boot_part_start"] or "2048" + commands = [ ["mktable", "msdos"], - ["mkpart", "primary", filesystem, "2048s", mb_boot], + ["mkpart", "primary", filesystem, boot_part_start + 's', mb_boot], ["mkpart", "primary", mb_boot, "100%"], ["set", "1", "boot", "on"] ]