Skip to content

Commit 2d892e1

Browse files
committed
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 ARM binaries can be found in my FlashIt v2.5 package: https://forum.xda-developers.com/showthread.php?t=2239421
1 parent a531fff commit 2d892e1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: tools/ak2-core.sh

+12-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ contains() { test "${1#*$2}" != "$1" && return 0 || return 1; }
2727

2828
# dump boot and extract ramdisk
2929
dump_boot() {
30-
dd if=$block of=/tmp/anykernel/boot.img;
30+
if [ -f "$bin/nanddump" ]; then
31+
$bin/nanddump -f /tmp/anykernel/boot.img $block;
32+
else
33+
dd if=$block of=/tmp/anykernel/boot.img;
34+
fi;
3135
if [ -f "$bin/unpackelf" ]; then
3236
$bin/unpackelf -i /tmp/anykernel/boot.img -o $split_img;
3337
mv -f $split_img/boot.img-ramdisk.cpio.gz $split_img/boot.img-ramdisk.gz;
@@ -134,7 +138,13 @@ write_boot() {
134138
ui_print " "; ui_print "User script execution failed. Aborting..."; exit 1;
135139
fi;
136140
fi;
137-
dd if=/tmp/anykernel/boot-new.img of=$block;
141+
if [ -f "$bin/flash_erase" -a -f "$bin/nandwrite" ]; then
142+
$bin/flash_erase $block 0 0;
143+
$bin/nandwrite -p $block /tmp/anykernel/boot-new.img;
144+
else
145+
dd if=/dev/zero of=$block;
146+
dd if=/tmp/anykernel/boot-new.img of=$block;
147+
fi;
138148
}
139149

140150
# backup_file <file>

0 commit comments

Comments
 (0)