AK2: add backwards compat for crazy devices hacking their mmcblk0

see comments here: https://github.com/osm0sis/AnyKernel2/pull/38#issuecomment-479577751

This will allow the current way people were adding arguments to dd via block= but also allow them to control this directly by adding customdd= to anykernel.sh.
This commit is contained in:
osm0sis committed 2019-04-05 21:24:52 -03:00
1 parent 3998baa529
commit a40fe9c65b
1 file changed
+10 -1
+10 -1
View File
@@ -39,10 +39,16 @@ split_boot() {
if [ ! -e "$(echo $block | cut -d\ -f1)" ]; then
ui_print " "; ui_print "Invalid partition. Aborting..."; exit 1;
fi;
if [ "$(echo $block | cut -d\ -f2-)" ]; then
block=$(echo $block | cut -d\ -f1);
customdd=$(echo $block | cut -d\ -f2-);
elif [ ! "$customdd" ]; then
local customdd="bs=1048576";
fi;
if [ -f "$bin/nanddump" ]; then
$bin/nanddump -f /tmp/anykernel/boot.img $block;
else
dd if=$block of=/tmp/anykernel/boot.img bs=1048576;
dd if=$block of=/tmp/anykernel/boot.img $customdd;
fi;
nooktest=$(strings /tmp/anykernel/boot.img | grep -E 'Red Loader|Green Loader|Green Recovery|eMMC boot.img|eMMC recovery.img|BauwksBoot');
if [ "$nooktest" ]; then
@@ -356,6 +362,9 @@ flash_boot() {
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;
elif [ "$customdd" ]; then
dd if=/dev/zero of=$block $customdd 2>/dev/null;
dd if=/tmp/anykernel/boot-new.img of=$block $customdd;
else
cat /tmp/anykernel/boot-new.img /dev/zero > $block 2>/dev/null;
fi;