add "fastboot-bootpart" flasher to flash split images with fastboot (!1871)

asus-me176c has a Fastboot interface that can be used for flashing,
but in postmarketOS we do not use Android boot images for it.
This is because is it not very practical - the boot partition is
quite small and there is a (custom) EFI bootloader that can boot
directly from any other FAT32 partition.

At the moment the installation process is manual:
  1. pmbootstrap install --split to have separated boot (FAT32)
     and rootfs images
  2. pmbootstrap export
  3. Flash boot and rootfs images manually using Fastboot

The "fastboot-bootpart" flasher implements that process in a more
convenient way. When a device uses the "fastboot-bootpart" flasher:

  - We generate --split images on "pmbootstrap install" by default.
    (This can be disabled using --no-split instead.)

  - pmbootstrap flasher flash_kernel flashes the raw boot partition
    (not an Android boot image) using Fastboot, just like the rootfs.

There are some limitations that could be improved in the future:

  - "fastboot-bootpart" is not offered in the device wizard.
    I think it is special enough that no-one will be starting with it,
    and the difference to normal "fastboot" might be confusing.

  - Support "pmbootstrap flasher boot". asus-me176c does not support
    "fastboot boot" properly, but theoretically we could still generate
    Android boot images to use when booting an image directly.

  - At the moment the boot partition image is not regenerated when
    using "pmbootstrap flasher flash_kernel" (unlike when using Android
    boot images). "pmbootstrap install" needs to be run manually first.
This commit is contained in:
Minecrell 2020-02-04 11:30:28 +01:00 committed by Alexey Min
parent ba1e39f48e
commit 87dd071b32
No known key found for this signature in database
GPG key ID: 0B19D2A65870B448
6 changed files with 77 additions and 29 deletions

View file

@ -61,16 +61,21 @@ def list_flavors(args):
def rootfs(args):
method = args.flash_method or args.deviceinfo["flash_method"]
# Generate rootfs, install flasher
img_path = "/home/pmos/rootfs/" + args.device + ".img"
if not os.path.exists(args.work + "/chroot_native" + img_path):
suffix = ".img"
if pmb.config.flashers.get(method, {}).get("split", False):
suffix = "-root.img"
img_path = args.work + "/chroot_native/home/pmos/rootfs/" + args.device + suffix
if not os.path.exists(img_path):
raise RuntimeError("The rootfs has not been generated yet, please run"
" 'pmbootstrap install' first.")
# Do not flash if using fastboot & image is too large
method = args.flash_method or args.deviceinfo["flash_method"]
if method == "fastboot" and args.deviceinfo["flash_fastboot_max_size"]:
img_size = os.path.getsize(args.work + "/chroot_native" + img_path) / 1024**2
if method.startswith("fastboot") and args.deviceinfo["flash_fastboot_max_size"]:
img_size = os.path.getsize(img_path) / 1024**2
max_size = int(args.deviceinfo["flash_fastboot_max_size"])
if img_size > max_size:
raise RuntimeError("The rootfs is too large for fastboot to"