[Magisk] Tecalote:
Huawei Patch01 breaks Magisk - can easy be solved

Huawei Patch01 breaks Magisk - can easy be solved. I found it out today.

Patch01 will be installed by Huawei on various devices via OTA → after rooting again with Magisk, phone hangs on boot screen ....

I originally reported it in the beta thread (Huawei P9 EVA): https://xdaforums.com/showpost.php?p=77415808&postcount=6556

[MENTION=2247733]ante0[/MENTION] reported it in Mate 10 forum: https://xdaforums.com/showpost.php?p=77483169&postcount=329

"All it contains is an PATCH.img which patches a few different things depending on cust. Some are apk patches, other are kernel modules. But one thing in common is that it breaks Magisk. (At least for now)"

[MENTION=8436723]heindrix[/MENTION] reported it here (Huawei Nova 2s):https://xdaforums.com/showpost.php?p=77522663&postcount=27218

[MENTION=4470081]topjohnwu[/MENTION] had responded to this on Twitter and [MENTION=4667597]Didgeridoohan[/MENTION] had asked "And this is regardless of dm-verity being disabled?"

Thanks for the hint!

→ For Magisk to work after Patch01, the flag must be checked: "Preserve AVB 2.0/dm-verity"

Even if avb is disabled in fstab, dm-verity flag is required so that the phone can boot with Magisk.

FYI: Patch01 install locations:

- primary location: /patch_hw - the kernel modul can be found in /patch_hw/kernel/HP000001.ko

- secondary location: /data/hw_init/hotpatch

For Users /instructions:

Tip: Look into Settings/Security & Privacy - if you find there an app called "TrustSpace", then disable it. Also in the same menu down in: "More" disable HiSuite HDB.

→ Note: Following Magisk settings solution is only required, if you have Firmware with Patch01

If the Patch01 was installed via OTA - you can not just flash the Magisk zip, because Magisk does not set the flag "Preserve AVB/dm-verity" automatically.

A) If there is a TWRP for your device that can handle the encrypted data partition and has access to /data then you can do the following:

1) Go in TWRP to "Advanced" and open "Terminal" - type following commands:

echo KEEPVERITY=true>>/data/.magisk
echo KEEPFORCEENCRYPT=true>>/data/.magisk

Confirm the entry to apply it and go back to the main menu on "Install"

2) Flash latest Magisk-v17.1.zip with TWRP

→ Thanks to [MENTION=4667597]Didgeridoohan[/MENTION] https://xdaforums.com/showpost.php?p=77562094&postcount=27405

B) If the TWRP for your device has not access to encrypted /data then you can do the following:

In this case it is necessary to make a Magisk patched ramdisk.img.

→ Note: In Android 6 and Android 7 it is called: boot.img - but on Android 8.x it's called: ramdisk.img

→ The name is not the problem, it just has to be flashed to the right place afterwards - in Android 6+7 you flash the patched_boot.img to: boot but on Android 8.x you flash it to: ramdisk

1) First you need the ramdisk.img from your current Firmware. Look in Settings /System /About phone how is your Build Number.

Open the site: http://pro-teammt.ru/firmware-database/?firmware_model=

Enter your model - (for example: BLA-L09c432) - then search for the Build Number, (for example: b150) - then click on FILELIST and a new window will pop up with the download Links. Download the update.zip for your device/cust/Build (it contains, what we need). Extract the update.zip, because we need the UPDATE.APP.

Download Huawei Extractor v0.9.9.5 from here: https://xdaforums.com/showthread.php?t=2433454

In the settings of the Huawei Extractor disable "verify header checksum" - then put with drag and drop the UDPATE.APP into Huawei Extractor and extract by right click the RAMDISK.img (on earlier Android Versions it would be: BOOT.img)

2) Copy the original RAMDISK.img to the internal storage in the folder: Download

3) Install the latest Magisk Manager: https://xdaforums.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445

4) Open Magisk Manager, Magisk Manager ask you "Install Magisk-vx.zip?" - first click on: no thanks

5) Enable the checkbox "Preserve AVB 2.0/dm-verity" in Magisk Manager. And since you are on Stock Firmware, which has internal storage encrypted by default, you must also enable the checkbox: "Preserve force encryption"

6) Then click on "Install" - "You want to install Magisk-v1x.zip now?" - Install - Patch Boot Image File...

7) Navigate to Download folder, and choose the RAMDISK.img

8) Magisk will now patch the RAMDISK.img and and once that's done, Magisk will save the patched ramdisk.img with the new name: patched_boot.img in the "Download" folder on internal storage.

→ Do not be confused - this is the patched ramdisk.img (or on Android 7 it would be the patched boot.img)

9) Now you must flash the patched_boot.img:

→ you can do it with TWRP or in Fastboot mode (dont do it twice):

a) with TWRP: Install - "Install img" and flashing to: ramdisk (on earlier Android Versions it would be: boot)

b) or in Fastboot mode on Android 8:

fastboot flash ramdisk patched_boot.img

in Fastboot mode on Android 7:

fastboot flash boot patched_boot.img

10) Reboot phone, install newest Magisk Manager, open it and you will be asked: "Requires Additional setup - to you want to proceed now" Yes.

After that, enjoy :)

Many Thanks for the Magisk developement! :good:

BTW: In the meantime I dont think, Huawei made this patch to prevent Root. It looks like a side effect.