From b6d48eed5e72e81d4a4c4dbafaca7759293ddfa6 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Thu, 2 Feb 2017 15:35:10 -0400 Subject: [PATCH] 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 --- tools/ak2-core.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/ak2-core.sh b/tools/ak2-core.sh index e0740ca..319a398 100755 --- a/tools/ak2-core.sh +++ b/tools/ak2-core.sh @@ -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