From ad94f10205609ed06ef846724b3215196e0e58fd Mon Sep 17 00:00:00 2001 From: Chris Renshaw Date: Mon, 1 Jun 2020 02:08:13 -0700 Subject: [PATCH] Fix direct install on NAND devices Co-authored-by: John Wu --- .../topjohnwu/magisk/core/tasks/MagiskInstallImpl.kt | 10 ++++++++++ scripts/util_functions.sh | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstallImpl.kt b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstallImpl.kt index fca87e49e..403b1bd7d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstallImpl.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstallImpl.kt @@ -239,6 +239,12 @@ abstract class MagiskInstallImpl : FlashResultListener { } private fun patchBoot(): Boolean { + var srcNand = "" + if ("[ -c $srcBoot ] && nanddump -f boot.img $srcBoot".sh().isSuccess) { + srcNand = srcBoot + srcBoot = File(installDir, "boot.img").path + } + var isSigned = false try { SuFileInputStream(srcBoot).use { @@ -258,6 +264,10 @@ abstract class MagiskInstallImpl : FlashResultListener { return false } + if (srcNand.isNotEmpty()) { + srcBoot = srcNand + } + val job = Shell.sh( "./magiskboot cleanup", "mv bin/busybox busybox", diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 7ceb8add0..da131b2a0 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -411,8 +411,8 @@ flash_image() { [ $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" - + flash_eraseall "$2" >&2 + eval $CMD1 | eval $CMD2 | nandwrite -p "$2" - >&2 else ui_print "- Not block or char device, storing image" eval $CMD1 | eval $CMD2 > "$2" 2>/dev/null