From 39b3a489ef66e277cbc05ebef26c4ac30ce53dfe Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 18 Jan 2019 20:01:03 +0100 Subject: [PATCH] pmbootstrap flasher flash_kernel --partition (!1741) Allow changing the kernel partition for fastboot and heimdall in deviceinfo and on the fly while doing "pmbootstrap flasher flash_kernel". Also allow changing the partition for "... flash_rootfs" with fastboot (this was only possible with heimdall so far). Introduce two new deviceinfo variables: * flash_fastboot_partition_kernel * flash_fastboot_partition_system This is useful for devices with dual partitioning that have boot_a and boot_b. --- pmb/config/__init__.py | 7 +++++-- pmb/flasher/variables.py | 9 +++++++-- pmb/parse/arguments.py | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index ab3e2cdb..31363cc5 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -249,6 +249,8 @@ deviceinfo_attributes = [ "flash_heimdall_partition_kernel", "flash_heimdall_partition_initfs", "flash_heimdall_partition_system", + "flash_fastboot_partition_kernel", + "flash_fastboot_partition_system", "generate_legacy_uboot_initfs", "kernel_cmdline", "generate_bootimg", @@ -321,10 +323,11 @@ Flasher abstraction. Allowed variables: $BOOT: Path to the /boot partition $FLAVOR: Kernel flavor $IMAGE: Path to the rootfs image +$PARTITION_KERNEL: Partition to flash the kernel/boot.img to $PARTITION_SYSTEM: Partition to flash the rootfs to Fastboot specific: $KERNEL_CMDLINE, $VENDOR_ID -Heimdall specific: $PARTITION_KERNEL, $PARTITION_INITFS +Heimdall specific: $PARTITION_INITFS """ flashers = { "fastboot": { @@ -336,7 +339,7 @@ flashers = { "flash_rootfs": [["fastboot", "-i", "$VENDOR_ID", "flash", "$PARTITION_SYSTEM", "$IMAGE"]], "flash_kernel": [["fastboot", "-i", "$VENDOR_ID", - "flash", "boot", "$BOOT/boot.img-$FLAVOR"]], + "flash", "$PARTITION_KERNEL", "$BOOT/boot.img-$FLAVOR"]], "boot": [["fastboot", "-i", "$VENDOR_ID", "-c", "$KERNEL_CMDLINE", "boot", "$BOOT/boot.img-$FLAVOR"]], diff --git a/pmb/flasher/variables.py b/pmb/flasher/variables.py index 716a06dd..0444522c 100644 --- a/pmb/flasher/variables.py +++ b/pmb/flasher/variables.py @@ -24,10 +24,15 @@ def variables(args, flavor, method): _cmdline = args.cmdline if method == "fastboot": - _partition_system = "system" + _partition_kernel = args.deviceinfo["flash_fastboot_partition_kernel"] or "boot" + _partition_system = args.deviceinfo["flash_fastboot_partition_system"] or "system" else: + _partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"] or "KERNEL" _partition_system = args.deviceinfo["flash_heimdall_partition_system"] or "SYSTEM" + if "partition" in args and args.partition: + # Only one of two operations is done at same time so it doesn't matter sharing the arg + _partition_kernel = args.partition _partition_system = args.partition vars = { @@ -36,7 +41,7 @@ def variables(args, flavor, method): "$IMAGE": "/home/pmos/rootfs/" + args.device + ".img", "$VENDOR_ID": args.deviceinfo["flash_fastboot_vendor_id"], "$KERNEL_CMDLINE": _cmdline, - "$PARTITION_KERNEL": args.deviceinfo["flash_heimdall_partition_kernel"] or "KERNEL", + "$PARTITION_KERNEL": _partition_kernel, "$PARTITION_INITFS": args.deviceinfo["flash_heimdall_partition_initfs"] or "RECOVERY", "$PARTITION_SYSTEM": _partition_system, "$RECOVERY_ZIP": "/mnt/buildroot_" + args.deviceinfo["arch"] + diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index 8c663fa3..472c72a1 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -67,6 +67,9 @@ def arguments_flasher(subparser): flash_kernel = sub.add_parser("flash_kernel", help="flash a kernel") for action in [boot, flash_kernel]: action.add_argument("--flavor", default=None) + flash_kernel.add_argument("--partition", default=None, + help="partition to flash the kernel to (defaults" + " to deviceinfo_flash_*_partition_kernel)") # Flash rootfs flash_rootfs = sub.add_parser("flash_rootfs", aliases=["flash_system"], @@ -74,8 +77,9 @@ def arguments_flasher(subparser): " device (partition layout does not get" " changed)") flash_rootfs.add_argument("--partition", default=None, - help="partition to flash to (Android: default" - " is 'system', but 'userdata' may have more" + help="partition to flash the rootfs to (defaults" + " to deviceinfo_flash_*_partition_system," + " 'userdata' on Android may have more" " space)") # Actions without extra arguments