pmbootstrap flasher: use boot.img file with fastboot

This commit is contained in:
Oliver Smith 2017-07-04 22:47:03 +02:00
parent d96c6951b7
commit 615880e161
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
4 changed files with 42 additions and 29 deletions

View File

@ -192,29 +192,31 @@ flash_mount_bind = [
"/dev/bus/usb/"
]
# Allowed variables:
# $KERNEL, $RAMDISK, $IMAGE (system partition image), $BOOTPARAM
"""
Flasher abstraction. Allowed variables:
$BOOT: Path to the /boot partition
$FLAVOR: Kernel flavor
$IMAGE: Path to the system partition image
$KERNEL_CMDLINE: Kernel commandline
Fastboot specific: $OFFSET_KERNEL, $OFFSET_RAMDISK, $OFFSET_TAGS, $PAGE_SIZE
"""
flashers = {
"fastboot": {
"depends": ["android-tools"],
"actions":
{
"list_devices": [["fastboot", "devices", "-l"]],
"flash_system": [["fastboot", "flash", "system", "$IMAGE"]],
"flash_kernel": [["fastboot",
"--base", "$OFFSET_BASE",
"flash_system": [["fastboot", "flash", "system", "$IMAGE"]],
"flash_kernel": [["fastboot", "flash" "boot", "$BOOT/boot.img-$FLAVOR"]],
"boot": [["fastboot",
"--kernel-offset", "$OFFSET_KERNEL",
"--ramdisk-offset", "$OFFSET_RAMDISK",
"--tags-offset", "$OFFSET_TAGS",
"--page-size", "$PAGE_SIZE",
"flash:raw", "$KERNEL", "$RAMDISK"]],
"boot": [["fastboot",
"--base", "$OFFSET_BASE",
"--kernel-offset", "$OFFSET_KERNEL",
"--ramdisk-offset", "$OFFSET_RAMDISK",
"--tags-offset", "$OFFSET_TAGS",
"--page-size", "$PAGE_SIZE",
"boot", "$KERNEL", "$RAMDISK"]],
"-c", "$KERNEL_CMDLINE",
"boot", "$BOOT/vmlinuz-$FLAVOR", "$BOOT/initramfs-$FLAVOR"]],
}
},
"heimdall": {
@ -222,10 +224,12 @@ flashers = {
"actions":
{
"list_devices": [["heimdall", "detect"]],
"flash_system": [
"flash_system": [
["heimdall_wait_for_device.sh"],
["heimdall", "flash", "--SYSTEM", "$IMAGE"]],
"flash_kernel": [["heimdall_flash_kernel.sh", "$RAMDISK", "$KERNEL"]]
"flash_kernel": [["heimdall_flash_kernel.sh",
"$BOOT/initramfs-$FLAVOR",
"$BOOT/vmlinuz-$FLAVOR"]]
},
},
}

View File

@ -50,15 +50,12 @@ def kernel(args):
# Generate the paths and run the flasher
pmb.flasher.init(args)
mnt = "/mnt/rootfs_" + args.device
kernel = mnt + "/boot/vmlinuz-" + flavor
ramdisk = mnt + "/boot/initramfs-" + flavor
if args.action_flasher == "boot":
logging.info("(native) boot " + flavor + " kernel")
pmb.flasher.run(args, "boot", kernel, ramdisk)
pmb.flasher.run(args, "boot", flavor)
else:
logging.info("(native) flash kernel " + flavor)
pmb.flasher.run(args, "flash_kernel", kernel, ramdisk)
pmb.flasher.run(args, "flash_kernel", flavor)
def list_flavors(args):
@ -78,7 +75,7 @@ def system(args):
# Run the flasher
logging.info("(native) flash system image")
pmb.flasher.run(args, "flash_system", image=img_path)
pmb.flasher.run(args, "flash_system")
def list_devices(args):

View File

@ -20,7 +20,7 @@ import pmb.flasher
import pmb.chroot.initfs
def run(args, action, kernel=None, ramdisk=None, image=None):
def run(args, action, flavor):
pmb.flasher.init(args)
# Verify action
@ -30,12 +30,18 @@ def run(args, action, kernel=None, ramdisk=None, image=None):
raise RuntimeError("action " + action + " is not"
" configured for method " + method + "!")
# Kernel commandline is optional
# Optional variables
cmdline = ""
if "kernel_cmdline" in args.deviceinfo:
cmdline = args.deviceinfo["kernel_cmdline"]
# Variable setup
vars = {
"$KERNEL": kernel,
"$RAMDISK": ramdisk,
"$IMAGE": image,
"$OFFSET_BASE": args.deviceinfo["flash_offset_base"],
"$BOOT": "/mnt/rootfs_" + args.device + "/boot",
"$FLAVOR": flavor,
"$IMAGE": "/home/user/rootfs/" + args.device + ".img",
"$KERNEL_CMDLINE": cmdline,
"$OFFSET_KERNEL": args.deviceinfo["flash_offset_kernel"],
"$OFFSET_RAMDISK": args.deviceinfo["flash_offset_ramdisk"],
"$OFFSET_SECOND": args.deviceinfo["flash_offset_second"],
@ -49,10 +55,11 @@ def run(args, action, kernel=None, ramdisk=None, image=None):
for key, value in vars.items():
for i in range(len(command)):
if key in command[i]:
if not value:
if not value and key != "$KERNEL_CMDLINE":
raise RuntimeError("Variable " + key + " found in"
" action " + action + " for method " + method + ","
" but the value for this variable is None!")
" but the value for this variable is None! Is that"
" missing in your deviceinfo?")
command[i] = command[i].replace(key, value)
# Run the action

View File

@ -129,7 +129,12 @@ def install(args, show_flash_msg=True):
" target device:")
logging.info("* pmbootstrap flasher flash_kernel")
logging.info(" Flashes the kernel + initramfs to your device:")
logging.info(" " + args.work + "/chroot_rootfs_" + args.device + "/boot")
logging.info(
" " +
args.work +
"/chroot_rootfs_" +
args.device +
"/boot")
method = args.deviceinfo["flash_methods"]
if (method in pmb.config.flashers and "boot" in
pmb.config.flashers[method]["actions"]):