scripts: add nand/mtd support to installer

- Magisk's busybox now has nanddump, flash_eraseall and nandwrite, so use these to support character devices

Closes #1526
This commit is contained in:
osm0sis 2020-03-11 16:57:52 -03:00 committed by John Wu
parent 72f6770d61
commit 47e50e8511
1 changed files with 14 additions and 1 deletions

View File

@ -376,8 +376,11 @@ flash_image() {
local blk_sz=`blockdev --getsize64 "$2"`
[ $img_sz -gt $blk_sz ] && return 1
eval $CMD1 | eval $CMD2 | cat - /dev/zero > "$2" 2>/dev/null
elif [ -c "$2" ]; then
flash_eraseall "$2"
eval $CMD1 | eval $CMD2 | nandwrite -p "$2" -
else
ui_print "- Not block device, storing image"
ui_print "- Not block or char device, storing image"
eval $CMD1 | eval $CMD2 > "$2" 2>/dev/null
fi
return 0
@ -408,6 +411,13 @@ patch_dtb_partitions() {
install_magisk() {
cd $MAGISKBIN
# Dump image for MTD/NAND character device boot partitions
if [ -c $BOOTIMAGE ]; then
nanddump -f boot.img $BOOTIMAGE
local BOOTNAND=$BOOTIMAGE
BOOTIMAGE=boot.img
fi
eval $BOOTSIGNER -verify < $BOOTIMAGE && BOOTSIGNED=true
$BOOTSIGNED && ui_print "- Boot image is signed with AVB 1.0"
@ -419,6 +429,9 @@ install_magisk() {
ui_print "- Flashing new boot image"
# Restore the original boot partition path
[ "$BOOTNAND" ] && BOOTIMAGE=$BOOTNAND
if ! flash_image new-boot.img "$BOOTIMAGE"; then
ui_print "- Compressing ramdisk to fit in partition"
./magiskboot cpio ramdisk.cpio compress