P20 Pro LineageOS 16 flashing guide

    LineageOS·English

  1. What you need:
  2. Before we start
  3. Downgrading to 9.0
  4. Edit the updater_script
  5. Getting RECOVERY_RAMDIS.IMG
  6. Install TWRP
  7. Flash LineageOS (and gapps)
  8. Flash TWRP again
  9. Huawei camera app

I tried installing LineageOS 16 on my P20 Pro a couple of times now, but it failed every time. Usually because I had a new EMUI installed, which wasn’t supported or using the wrong versions of packages.

So, today, I was about to try again. It worked and I actually documented it now.

Updates:

  • 2019-10-12 Initial post
  • 2019-10-13 Added description of RECOVERY_RAMDIS.IMG

What you need:

  1. TWRP (I grabbed the latest one at the time)
  2. Lineage OS 16
  3. Platform tools (fastboot and adb)
  4. HiSuite (if you are on EMUI 9.1 or higher)
  5. Huawei Firmware Extractor
  6. RECOVERY_RAMDIS.IMG (recovery from an official Huawei ROM)

Before we start

All this has been made possible by a lot of people, all I did was write this hacky guide to get a P20 Pro, with an EMUI 9.1 ROM installed, flashed to LineageOS.

Did I forget anyone? Let me know.

Downgrading to 9.0

If you are already on EMUI 9.0 instead of 9.1, you should downgrade first to 9.0. This can be done by using HiSuite on Windows (OSX doesn’t have this option). I used 9.0.0.293 for this.

Edit the updater_script

The P20 Pro requires the updater_script in the LineageOS zip file to be edited, before it will actually install. You can download an updated updater_script here and insert it in the ZIP file at META-INF\com\google\android\. It should overwrite an already existing file.

If you want to manually edit the file, just read this thread on XDA.

Getting RECOVERY_RAMDIS.IMG

You will need a file called RECOVERY_RAMDIS.IMG. This is the official Huawei recovery which you can extract from an original ROM. So here are the things you need to get hold of it:

  1. Download an original Huawei ROM file for the P20 Pro. Find the right one of this page. You should be picking the Update file for your phone. It is very important you know the right model for your phone. I picked 9.0.0.195 for the CLT-L29C432 for example.
  2. Extract the downloaded ZIP file. This will give you an Update.zip and some other files.
  3. Extract that Update.zip and that will give you access to the Update.app file you need.
  4. Start Huawei Firmware Extractor.
  5. Go to the Settings tab
  6. Disable Verify header checksum
  7. Go to the Extract tab
  8. Select the Update.app file where it says Update file.
  9. The ROM should then load and it displays a list of files
  10. Find RECOVERY_RAMDIS.IMG (not ERECOVERY_RAMDI.IMG)
  11. Right-click that file and choose Extract selected, make sure you put it in a convenient spot.
  12. Done!

Install TWRP

  1. Enable USB debugging
  2. adb reboot bootloader
  3. fastboot flash recovery_ramdisk twrp-3.2.3-1-charlotte.img
  4. Prepare yourself to remove USB cable and hold volume up
  5. fastboot reboot
  6. Unplug and hold that button you were preparing for in #4

You should now be in TWRP.

Flash LineageOS (and gapps)

  1. In TWRP go to Advanced > ADB Sideload
  2. adb sideload lineage.zip
  3. adb sideload mind-the-gapps
  4. In TWRP go to Advanced > Reboot > Bootloader
  5. fastboot flash recovery_ramdisk RECOVERY_RAMDIS.IMG
  6. fastboot reboot recovery
  7. You should now be in the stock recovery. If not, boot into stock recovery :)
  8. Select Wipe data / factory reset
  9. Reboot system now

Yay, LineageOS

Flash TWRP again

So, I flashed TWRP again after LineageOS was flashed, to make sure I could easily update it to the latest version. There is a problem with the updater in LineageOS in combination with TWRP, but at least you can install the latest version using the ADB sideloading method.

Huawei camera app

After I got this running, I did want the Huawei camera app back, because that is actually quite a cool app.

You can download the ZIP from this thread. You also need to download this XML file.

  1. Boot in TWRP
  2. Go to Advanced > ADB Sideload
  3. adb sideload HwCamera2_addon_P.zip
  4. adb push privapp-permissions-com.huawei.camera.xml /tmp
  5. Go to Mount and check the system partition.
  6. Go to Advanced > File Manager
  7. Move the privapp-permissions-com.huawei.camera.xml from /tmp to /system/system/etc/permissions
  8. Reboot!