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.
This commit is contained in:
Ion Agorria 2019-01-18 20:01:03 +01:00 committed by Oliver Smith
parent 712dd4e20e
commit 39b3a489ef
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
3 changed files with 18 additions and 6 deletions

View File

@ -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"]],

View File

@ -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"] +

View File

@ -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