Fix and improve rootfs flashing

This commit is contained in:
jld3103 2021-08-14 13:31:04 +02:00
parent da8a437341
commit e1ddf636b7
2 changed files with 115 additions and 29 deletions

23
boot.py
View file

@ -2,6 +2,7 @@ import os
import urllib.request
from image import get_device_and_flavour, get_image_name
from logger import logging, setup_logging, verbose_option
from flash import dump_bootimg, erase_dtbo
import click
import subprocess
@ -17,20 +18,6 @@ boot_strategies = {
}
def dump_bootimg(image_name: str) -> str:
path = '/tmp/boot.img'
result = subprocess.run([
'debugfs',
image_name,
'-R',
f'dump /boot/boot.img {path}',
])
if result.returncode != 0:
logging.fatal(f'Faild to dump boot.img')
exit(1)
return path
@click.command(name='boot', help=f'Leave TYPE empty or choose \'{JUMPDRIVE}\'')
@verbose_option
@click.argument('type', required=False)
@ -49,7 +36,13 @@ def cmd_boot(verbose, type):
else:
path = dump_bootimg(image_name)
result = subprocess.run(['fastboot', 'boot', path])
erase_dtbo()
result = subprocess.run([
'fastboot',
'boot',
path,
])
if result.returncode != 0:
logging.fatal(f'Failed to boot {path} using fastboot')
exit(1)