[Huawei P20 Lite ROMs, Kernels, Recoveries, & Other] gh0stza:
Today I will be giving a tutorial on how to root the Huawei P20 Lite using STOCK ROM (ANE-LX1 ANE-L01 ANE-L21)

If you need bootloader unlock code

----------------------------------------

You can use dc-unlocker but, only if you can rollback to 8.0.0.146 or lower (i was on 8.0.0.46 when i used dc-unlocker).

You can try to use PotatoNV, but that will require testpoint access (haven't tested yet).

You can use HCU client with a 3day account pass, which is quite expensive (I have not actually tested this yet).

Rollback EMUI 9 to EMUI 8

-----------------------------

This is where my frustrations with this phone began.

You can try to use dload method, but in my experience this DOES NOT WORK when you're on EMUI 9.

It will just give you an error about incompatible version, every time.

Forced dload was also a complete bust for me, 24 hours wasted

I was finally able to rollback from HiSuite 11. I was on 9.1.0.200 when I had the option to rollback and it rolled me back to 8.0.0.163.

From 8.0.0.163 I could use normal dload to rollback further until I could use dc-unlocker.

I made the mistake of upgrading to EMUI 9 after I unlocked my bootloader. My advise: if you can manage to get to 8, stay there. It's less bloated and feels smoother. I have not received the option to rollback after I re-upgraded to 9 since. And I have not found AANNYY method to rollback to 8 since then, I pretty much gave up and stayed on EMUI 9.

EMUI 8

---------

copy magisk23.zip to sdcard

flash twrp to recovery_ramdisk.img

fastboot flash recovery_ramdisk "twrp-3.2.1-0.img"

EDIT: ***NEW official TWRP version*** TWRP 3.6.2.0_9-0

fastboot flash recovery_ramdisk "twrp-official-3.6.2_9-0-anne.img"

fastboot reboot recovery

Once in twrp install the magisk23.zip file.

This will patch the boot.img from recovery_ramdisk.img with magisk v23

Reboot -> System

Once in android you will get the usual magisk app, open and allow to perform additional tasks like installing the manager app.

Pretty straight forward

EMUI 9

---------

While still on stock firmware, update your android to the highest possible firmware (HiSuite or on phone -> Settings -> System ....)

1. When your back in android power off phone.

2. Go into fastboot (USB cable plugged in -> Power + Vol Down)

3. Flash twrp into recovery_ramdisk

fastboot flash recovery_ramdisk twrp-3.2.1-0.img

fastboot reboot recovery

Now In TWRP

4. Install Image -> twrp-3.2.1-0.img into eRecovery partition

5. Install Image -> magisk23_patched-ane.img into Recovery Partition

6. Reboot -> Recovery

Note: So booting into recovery mode gives you a ROOTED environment and System Mode gives you NON-ROOTED.

EDIT: *** With the new TWRP 3.6.2.0_9-0 you will have to boot into recovery (by holding Vol Up + Power till the screen comes on) every time you boot the phone or it will boot into normal system where the root environment isn't present ***

That's it. Now you should have root access.

You can still use twrp, but you have to access it like you would access eRecovery. So from power off (coldstart) -> Hold Vol Up while plugging in the USB Cable, continue to hold Vol Up, till you get the twrp logo.

Caution: This overwrites eRecovery, this can be dangerous, as eRecovery is the only thing standing between you can a hard brick if twrp wont boot anymore. This is due to fastboot not being able to flash eRecovery. You can only flash eRecovery from twrp. This is particularly dangerous if your data partition gets corrupted, this can happen when formatting data through twrp 3.4.0 and above. When your data partition is corrupt, twrp will freeze on the loading logo, leaving you no way to flash the original eRecovery.

Note: I think you can flash the eRecovery_ramdisk.img over the normal recovery_ramdisk in case of a brick situation. Though I haven't tested that idea yet, im just planning on going that route if I run into such a scenario. The eRecovery is particularly usefull as it can recover almost any situation by using wifi to download a stock rom and full flash that entire rom.

This way is robust, no need for key combo's when restarting the device etc.

All Downloads (GDrive):

Gdrive

After the root, you might find yourself needing safetynet attest pass.

This can be achieved by:

1. Open Magisk and setup MagiskHide ( Search on XDA if you don't know how to do this )

2. Magisk Modules -> Install Riru

3. Magisk Modules -> Install from storage -> Select safetynet-fix-v2.1.0.zip

note: If PropsConfig is installed, remove it first and reboot

If you need to use Smali then it's once again kinda straight forward.

1. Copy /system/framework to sdcard (anywhere u can copy it from)

2. Copy the framework folder onto pc

3. Open SmaliPatcher.exe -> Select the framework folder -> select patch options and patch

4. Copy the created magisk module zip file onto sdcard

5. Install magisk module -> Magisk -> Modules -> Install from storage

Hope you have a smooth experience rooting this device.

External links:

Tested custom recoveries from -Alf-

Source of rooting and flashing information by -Alf-

Credits:

@-Alf- for the magisk patched image. I only repatched his recovery_ramdisk from magisk v21 to v23

And also for the twrp recovery 3.2.1-0 GAGUGA Edition