flasher: heimdall-bootimg: add support for '--no-reboot' and '--resume'

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C170534361606.26168.17672643433174186875-0@git.sr.ht%3E
This commit is contained in:
Andras Sebok 2024-01-15 19:27:57 +01:00 committed by Oliver Smith
parent 59898f515a
commit e0e3e213ba
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
4 changed files with 41 additions and 5 deletions

View file

@ -998,20 +998,23 @@ flashers = {
"list_devices": [["heimdall", "detect"]], "list_devices": [["heimdall", "detect"]],
"flash_rootfs": [ "flash_rootfs": [
["heimdall_wait_for_device.sh"], ["heimdall_wait_for_device.sh"],
["heimdall", "flash", "--$PARTITION_ROOTFS", "$IMAGE"]], ["heimdall", "flash", "--$PARTITION_ROOTFS", "$IMAGE",
"$NO_REBOOT", "$RESUME"]],
"flash_kernel": [ "flash_kernel": [
["heimdall_wait_for_device.sh"], ["heimdall_wait_for_device.sh"],
["heimdall", "flash", "--$PARTITION_KERNEL", ["heimdall", "flash", "--$PARTITION_KERNEL",
"$BOOT/boot.img$FLAVOR"]], "$BOOT/boot.img$FLAVOR", "$NO_REBOOT", "$RESUME"]],
"flash_vbmeta": [ "flash_vbmeta": [
["avbtool", "make_vbmeta_image", "--flags", "2", ["avbtool", "make_vbmeta_image", "--flags", "2",
"--padding_size", "$FLASH_PAGESIZE", "--padding_size", "$FLASH_PAGESIZE",
"--output", "/vbmeta.img"], "--output", "/vbmeta.img"],
["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img"], ["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img",
"$NO_REBOOT", "$RESUME"],
["rm", "-f", "/vbmeta.img"]], ["rm", "-f", "/vbmeta.img"]],
"flash_lk2nd": [ "flash_lk2nd": [
["heimdall_wait_for_device.sh"], ["heimdall_wait_for_device.sh"],
["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img"]] ["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img",
"$NO_REBOOT", "$RESUME"]]
}, },
}, },
"adb": { "adb": {

View file

@ -50,6 +50,14 @@ def run(args, action, flavor=None):
" in deviceinfo file. See also:" " in deviceinfo file. See also:"
" <https://wiki.postmarketos.org/wiki/" " <https://wiki.postmarketos.org/wiki/"
"Deviceinfo_reference>") "Deviceinfo_reference>")
if args.no_reboot and ("flash" not in action or method != "heimdall-bootimg"):
raise RuntimeError("The '--no-reboot' option is only"
" supported when flashing with heimall-bootimg.")
if args.resume and ("flash" not in action or method != "heimdall-bootimg"):
raise RuntimeError("The '--resume' option is only"
" supported when flashing with heimall-bootimg.")
# Run the commands of each action # Run the commands of each action
for command in cfg["actions"][action]: for command in cfg["actions"][action]:
@ -66,5 +74,7 @@ def run(args, action, flavor=None):
check_partition_blacklist(args, key, value) check_partition_blacklist(args, key, value)
command[i] = command[i].replace(key, value) command[i] = command[i].replace(key, value)
# Remove empty strings
command = [x for x in command if x != '']
# Run the action # Run the action
pmb.chroot.root(args, command, output="interactive") pmb.chroot.root(args, command, output="interactive")

View file

@ -61,6 +61,14 @@ def variables(args, flavor, method):
_dtb = "" _dtb = ""
if args.deviceinfo["append_dtb"] == "true": if args.deviceinfo["append_dtb"] == "true":
_dtb = "-dtb" _dtb = "-dtb"
_no_reboot = ""
if args.no_reboot:
_no_reboot = "--no-reboot"
_resume = ""
if args.resume:
_resume = "--resume"
vars = { vars = {
"$BOOT": "/mnt/rootfs_" + args.device + "/boot", "$BOOT": "/mnt/rootfs_" + args.device + "/boot",
@ -80,7 +88,9 @@ def variables(args, flavor, method):
"/var/lib/postmarketos-android-recovery-installer" "/var/lib/postmarketos-android-recovery-installer"
"/pmos-" + args.device + ".zip", "/pmos-" + args.device + ".zip",
"$UUU_SCRIPT": "/mnt/rootfs_" + args.deviceinfo["codename"] + "$UUU_SCRIPT": "/mnt/rootfs_" + args.deviceinfo["codename"] +
"/usr/share/uuu/flash_script.lst" "/usr/share/uuu/flash_script.lst",
"$NO_REBOOT": _no_reboot,
"$RESUME": _resume
} }
# Backwards compatibility with old mkinitfs (pma#660) # Backwards compatibility with old mkinitfs (pma#660)

View file

@ -289,6 +289,19 @@ def arguments_flasher(subparser):
" inside the device rootfs chroot on this computer") " inside the device rootfs chroot on this computer")
sub.add_parser("list_devices", help="show connected devices") sub.add_parser("list_devices", help="show connected devices")
group = ret.add_argument_group("heimdall options", \
"With heimdall as"
" flash method, the device automatically"
" reboots after each flash command. Use"
" --no-reboot and --resume for multiple"
" flash actions without reboot.")
group.add_argument("--no-reboot", dest="no_reboot",
help="don't automatically reboot after flashing",
action="store_true")
group.add_argument("--resume", dest="resume",
help="resume flashing after using --no-reboot",
action="store_true")
return ret return ret