AK2: add MTD device support and dd wiping

- add built-in support for mtd-utils (nanddump, flash_erase, nandwrite) for MTD-based Android devices that do not work with dd
- wipe boot block with dd before write to be clean/safe (SuperSU zip also does this)

Known working mtd-utils ARM binaries can be found in my FlashIt v2.5 package:
https://forum.xda-developers.com/showthread.php?t=2239421
This commit is contained in:
osm0sis committed 2017-02-02 15:52:09 -04:00
1 parent a531fff38b
commit b6d48eed5e
1 file changed
+12 -2
+12 -2
View File
@@ -27,7 +27,11 @@ contains() { test "${1#*$2}" != "$1" && return 0 || return 1; }
# dump boot and extract ramdisk
dump_boot() {
dd if=$block of=/tmp/anykernel/boot.img;
if [ -f "$bin/nanddump" ]; then
$bin/nanddump -f /tmp/anykernel/boot.img $block;
else
dd if=$block of=/tmp/anykernel/boot.img;
fi;
if [ -f "$bin/unpackelf" ]; then
$bin/unpackelf -i /tmp/anykernel/boot.img -o $split_img;
mv -f $split_img/boot.img-ramdisk.cpio.gz $split_img/boot.img-ramdisk.gz;
@@ -134,7 +138,13 @@ write_boot() {
ui_print " "; ui_print "User script execution failed. Aborting..."; exit 1;
fi;
fi;
dd if=/tmp/anykernel/boot-new.img of=$block;
if [ -f "$bin/flash_erase" -a -f "$bin/nandwrite" ]; then
$bin/flash_erase $block 0 0;
$bin/nandwrite -p $block /tmp/anykernel/boot-new.img;
else
dd if=/dev/zero of=$block;
dd if=/tmp/anykernel/boot-new.img of=$block;
fi;
}
# backup_file <file>