FORUMS

[Howto][China] Flash TWRP, custom ROM and fix Google Pay

78 posts
Thanks Meter: 23
 
By ionflux, Member on 7th July 2019, 10:03 AM
Post Reply Email Thread
I realize that there's no howto guide yet on this forum. To a new Xiaomi device user, this can be daunting.

This is my guide on how I flashed my China Redmi K20 Pro and fixed Google Pay.

I am NOT responsible for whatever happens to your device as a result of following the below instructions.

At all times remember to download only the ones applicable for the China version i.e. recovery, ROM.

EXTRA:: New phone out of the box and waiting for bootloader unlock?
Install Google Play. Some of the download links in the thread are outdated so it is best to go to apkmirror.com to search, download and install them.

1) In order to flash any custom ROM, the bootloader must be unlocked
Xiaomi locks this by default on all devices. You must unlock it before proceeding to next steps, or you will brick your device. If it's bricked, try this or read the last section of this post.
i. Check Mi lock status from Developer Options. To enable Developer Options, go to Settings -> My Device -> All Specs -> tap on MIUI version. The Developer Options will appear in Settings -> Additional Settings eventually after about 7 taps.
The unlock time can take anywhere from 2 days to 30 days. You can check the timer in step 1vi. You no longer need to apply to Xiaomi to unlock the bootloader.
ii. Download the miflash_unlock_en_3.3.827.31. Extract the zip and run miflash_unlock.exe
iii. On the computer, sign in to the same mi account that's being bound to your phone.
iv. Send the phone to fastboot mode (power down, then power button + volume down button at the same time until the android picture appears).
v. Connect the phone to the computer by USB.
vi. On the computer, attempt to proceed to unlock. It will show you the number of hours left that you need to wait before the phone can be unlocked. Try again after that.

2) Bootloader unlocked
When you try to unlock the phone now (step 1iii - vi), the phone's screen will suddenly change while your mi unlock tool is "verifying" the phone. The tool will say error unlocking. This is normal. On the phone's screen, after progressing about 10% it will appear to reset. Your phone is now unlocked. You can verify the lock status by repeating step 1.

3) Install TWRP custom recovery
You need an Intel (AMD Ryzen seems to be an issue) Windows PC and ADB/fastboot installed. If you don't already, download from here.

There are several recoveries out there, but this one works for me. Download your choice into your PC. When you are done:
i. Open PowerShell (in File Explorer, shift + left click on an empty space) in that folder you downloaded into. If it's a zip, extract to get the .img file.
ii. Send phone into fastboot mode (power down, then vol down button + power button together).
iii. Connect phone to computer.
iv. Type
Code:
fastboot devices
into the PowerShell window. On your computer, you will be able to see that the phone is now in fastboot mode.
v. Type
Code:
fastboot flash recovery TWRP-3.3.1-0529-REDMI_K20PRO-CN-wzsx150.img
vi. When done, send your phone into TWRP recovery (vol up button + power button together).
Note: You must complete step vi or you will lose TWRP recovery because official ROMs restore to official recovery. If you missed this step, you must repeat from steps 3ii to go into TWRP.

4) Send ROM to your phone. If you have the ROM downloaded into your phone already, you may skip this step
Choose a ROM from the ROM section. For me, I use xiaomi.eu 9.8.22. Direct download link for the lazy.
Continuing in the same PowerShell window, type:
Code:
adb devices
adb push "D:\xiaomi.eu_multi_HMK20ProMI9TPro_9.8.22_v10-10.zip" /sdcard/
Replace D:\...... with the full path to the downloaded ROM. The file transfer may take some time. Wait for the PowerShell window to finish the executing command. It took 320 seconds for me.

5) Flash the ROM
For a clean ROM install, be sure to wipe the data, Dalvik and cache partitions. It is called a dirty flash if you wipe only Dalvik and cache.
i. On your phone while still in TWRP, go to Wipe -> Advanced Wipe -> select Dalvik / ART Cache and Data partitions. DON'T choose the FORMAT DATA or wipe any other partition.
ii. Select Install, then choose the ROM and swipe to start the flash. Alternatively, you can also run the same by continuing in the PowerShell window:
Code:
adb shell twrp install /sdcard/xiaomi.eu_multi_MI9_9.8.22_v10-10.zip
iii. When done, select "Reboot System". The first startup will take some time (maybe 3 minutes). You may disconnect the cable from the computer now.

6) Congrats! You are now using a custom ROM!

7) Set up Google Pay
Last tested and still working on 29 August 2019.
There's still one last obstacle. It seems that even though we can pass SafetyNet, Google Pay still doesn't want to work.
a) Make sure Google Pay app has already been installed and run once.
b) Install Magisk Manager
i. Open the App and then download the Magisk zip file.
ii. Send the phone into recovery. Power down the phone, then power button + vol up button at the same time.
iii. Select the Install menu, then select the Magisk zip file and slide to confirm flash. When done, select "Reboot to system".
c) Open Magisk App, then under Downloads, find and install Busybox for Android NDK and SQLite3 for ARM aarch64. Reboot phone.
d) Download the GPay SQLite Fix (more reading here)
Which version to use? It depends on how you want the fix:
Fix stays even if Magisk is uninstalled - use v1.5
To uninstall later, use Termux, type in the following:
Code:
su
chattr -i /data/data/com.google.android.gms/databases/dg.db
Grant superuser to the App when prompted.
Fix is uninstalled together when Magisk is uninstalled - use v1.7
e) Open Magisk app, go to Modules, press on the + button to custom select a module. Select file manager, then browse to the downloaded zip file. When done flashing, reboot phone. You can begin to setup contactless payment next.
If you used v1.5, you may uninstall Magisk now.

TIP: You need to change the NFC method if you want to use Google Pay.
Under Settings, go to Wireless & Networks -> More -> Secure element position -> Use HCE Wallet.






Help! It keeps rebooting into TWRP and never into my ROM!
I hope you never end up needing this. But if it did happen:
a) Download and install MIUI ROM Flashing Tool from MIUI.com. Guide is also available in the page.
b) Download a fastboot ROM from here example: China V10.3.8.0PFKCNXM Fastboot.
c) Unzip into a directory with no space in between:
Code:
D:\Redmi K20 Pro\fastboot - NOT OK
D:\Redmi_K20_Pro\fastboot - OK
d) Send phone to fastboot mode (power down, then vol down button + power button together).
e) Connect phone to computer
f) Open the MIUI ROM Flashing Tool. Browse to the directory where you had extracted the file e.g. D:\Redmi_K20_Pro\fastboot\raphael_images_V10.3.8.0 .PFKCNXM_20190601.0000.00_9.0_cn
The program always defaults to "clean all and lock". This option will install the official ROM and lock the bootloader.
Make sure to change to "clean all" to keep the bootloader unlocked.

g) Press "refresh" to confirm your phone is listed and then press "flash" when you are ready.
The flashing process will take several minutes. Do not disconnect the cable.
The program will show "success" under result.
Your phone will automatically boot into the official ROM.
You may then repeat step 3 Install TWRP custom recovery.
The Following 12 Users Say Thank You to ionflux For This Useful Post: [ View ] Gift ionflux Ad-Free
7th July 2019, 12:46 PM |#2  
Member
Thanks Meter: 2
 
More
im having issue with twrp, i flashed it successfully and boot to the system(rom) but when i try to boot to recovery the stock recovery overwrites twrp, flashed 4x same result, how to fix this?
7th July 2019, 01:40 PM |#3  
Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by karltabby

im having issue with twrp, i flashed it successfully and boot to the system(rom) but when i try to boot to recovery the stock recovery overwrites twrp, flashed 4x same result, how to fix this?

Same here and flipping bought my phone from Ebay and its now locked to Mi account
7th July 2019, 02:29 PM |#4  
Member
Thanks Meter: 2
 
More
Quote:
Originally Posted by Gooners4life

Same here and flipping bought my phone from Ebay and its now locked to Mi account

your have mi accnt of the previous owner
7th July 2019, 03:04 PM |#5  
Senior Member
Thanks Meter: 648
 
More
Quote:
Originally Posted by ionflux

I realize that there's no howto guide yet on this forum. To a new xiaomi device user this can be daunting.

This is my guide on how I flashed my Redmi K20 Pro and fixed gpay.

I am NOT responsible for whatever happens to your device as a result of following the below instructions.

EXTRA:: New phone out of the box and waiting for bootloader unlock?
Install Google Play. Some of the download links in the thread are outdated so it is best to go to apkmirror.com to search, download and install them.

1) In order to flash any custom ROM, the bootloader must be unlocked. Xiaomi locks this by default on all devices. You must unlock it before proceeding to next steps, or you will brick your device.
i. Check Mi lock status from Developer Options
To enable Developer Options, go to Settings -> My Device -> All Specs -> tap on MIUI version. The Developer Options will appear in Settings -> Additional Settings eventually after about 7 taps.
If this is locked, you will need to apply to Xiaomi to unlock. This can take anywhere from 2d to 30d. I think it is a random countdown timer set by Xiaomi. Mine took 7 days.
ii. You will be able to download their unlock tool (miflash_unlock_en_3.3.827.31) after applying. Extract the zip and run this tool (miflash_unlock.exe).
iii. On the computer, sign in to the same mi account that's used on your phone.
iv. Send the phone to fastboot mode (power down. then power button + volume down button at the same time until android picture appears)
v. Connect the phone to the computer by USB
vi. On the computer, attempt to proceed to unlock. It will show you the number of hours left you need to wait before the phone can be unlocked. Try again after that

2) Bootloader unlocked
When you try to unlock the phone now (step 1iii - vi), the phone's screen will suddenly change when your mi software is "verifying" the phone. The software will say error unlocking. This is normal. On the phone's screen, after progressing about 10% it will appear to reset. Your phone is now unlocked. You can verify by trying step 1.

3) Install TWRP custom recovery
There is a thread here that links to the custom TWRP made for Redmi K20 Pro. The last time I tried the download link had expired, so I used the archived one linked by the thread poster.
After extracting the zip, you will find a few important files:

These are essentially all you need to flash the custom recovery.
i. Open PowerShell in that folder you unzipped into. (In File Explorer, shift + left click on an empty space)
ii. Send phone into fastboot mode (power down, then power button + vol down button together)
iii. Connect phone to computer
iv. Type into the PowerShell window. You will be able to see that the phone is now in fastboot on your computer.
v. Type
vi. Type
vii. Your phone should boot into TWRP now.

4) Send ROM to your phone. If you have the ROM downloaded into your phone already, you may skip this step.
I downloaded the stable ROM 10.3.12.0. Direct link for the lazy
Continuing in the same PowerShell window, type

Replace D:\...... with the full path to the downloaded ROM. The file transfer may take some time. It took 454 seconds for me.

5) Flash the ROM.
Before flashing the ROM, clean the data and Dalvik cache partitions.
i. On your phone while it's still in TWRP, go to Wipe -> Advanced Wipe -> select Dalvik Cache and Data partitions. DON'T wipe any other partitions.
ii. Go back to home screen. Now go to Install menu, then select the ROM.zip in your /sdcard/ directory. Slide to confirm flash. When done, select "Reboot to system". The first startup will take some time (maybe 3 minutes).

6) You are using xiaomi.eu ROM (yay!)
Congrats! You are now using xiaomi.eu ROM!

7) Set up Google Pay
There's still one last obstacle. It seems that even though we can pass SafetyNet, Google Pay still doesn't want to work.
As of this post, I have tried this fix and it works.
Make sure Google Pay app has already been installed and run once.
a) Install Magisk Manager
i. Open the App and then download the Magisk zip file.
ii. Send the phone into recovery. Power down the phone, then power button + vol up button at the same time.
iii. Select Install menu, then select the Magisk zip file and slide to confirm flash. When done, select "Reboot to system".
b) Open Magisk app, then under Downloads, find and install busybox. Reboot phone.
c) Download the gpay sqlite fix (more reading here)
d) Open Magisk app, go to Modules, press on the + button to custom select a module. Select file manager, then browse to the downloaded zip file. When done flashing, reboot phone.
OPTIONAL: If you don't want Magisk, you can uninstall it now. After the phone reboots, you can begin to setup contactless payment.
If you want to keep Magisk, then you should hide Magisk Manager and all other apps that check for rooting i.e. Google Pay and other banking apps.

TIP: You need to change the NFC method if you want to use Google Pay
Under Settings, go to Wireless & Networks -> More -> Secure element position -> Use HCE Wallet.

You no longer need to apply for unlock permissions. This has been the case for a few months. I've no idea why Xiaomi don't take down the unlock request page.

---------- Post added at 03:04 PM ---------- Previous post was at 03:02 PM ----------

Quote:
Originally Posted by karltabby

im having issue with twrp, i flashed it successfully and boot to the system(rom) but when i try to boot to recovery the stock recovery overwrites twrp, flashed 4x same result, how to fix this?

MIUI will restore stock recovery on reboot. After flashing TWRP immediately boot into TWRP and install Magisk. This will prevent stock MIUI from restoring stock recovery.
7th July 2019, 04:15 PM |#6  
Member
Thanks Meter: 3
 
More
Quote:
Originally Posted by karltabby

your have mi accnt of the previous owner

The phone was sealed when I got it and boot loader was unlocked. On a Paypal dispute.
7th July 2019, 04:50 PM |#7  
Quote:
Originally Posted by Robbo.5000

You no longer need to apply for unlock permissions. This has been the case for a few months. I've no idea why Xiaomi don't take down the unlock request page.

can you share the link to this? i wouldn't dare to try flashing a custom ROM without unlocking
7th July 2019, 04:52 PM |#8  
Quote:
Originally Posted by karltabby

im having issue with twrp, i flashed it successfully and boot to the system(rom) but when i try to boot to recovery the stock recovery overwrites twrp, flashed 4x same result, how to fix this?

you cannot boot into system after flashing twrp. on the official ROM they will restore to the official recovery. you need to flash a custom ROM like xiaomi.eu while in TWRP, then boot into system.
7th July 2019, 04:54 PM |#9  
Quote:
Originally Posted by Gooners4life

Same here and flipping bought my phone from Ebay and its now locked to Mi account

same how? could you get into TWRP? you need to sign out of the mi account
7th July 2019, 05:37 PM |#10  
Member
Thanks Meter: 2
 
More
Quote:
Originally Posted by ionflux

you cannot boot into system after flashing twrp. on the official ROM they will restore to the official recovery. you need to flash a custom ROM like xiaomi.eu while in TWRP, then boot into system.

If i flash eu rom while on twrp after reboot twrp will stay as default recovery? Someone tol me to flash "descript" i have no idea what it is
7th July 2019, 06:06 PM |#11  
Senior Member
Thanks Meter: 648
 
More
Quote:
Originally Posted by ionflux

can you share the link to this? i wouldn't dare to try flashing a custom ROM without unlocking

You still need to unlock the bootloader and you will most likely need to wait to unlock it, probably 7 days. But you no longer need to apply for unlock permissions for your Mi account.
There are still a lot of Xiaomi bootloader unlock How-to articles being written that tell you to go to the Xiaomi bootloader unlock permission webpage and apply for unlock permissions for your Mi account. This is not necessary anymore.

---------- Post added at 06:06 PM ---------- Previous post was at 06:01 PM ----------

Quote:
Originally Posted by ionflux

you cannot boot into system after flashing twrp. on the official ROM they will restore to the official recovery. you need to flash a custom ROM like xiaomi.eu while in TWRP, then boot into system.

If you want to keep an official ROM, then you need to install Magisk.
Though if you are not installing a custom ROM or you're not installing Magisk, then I'm not sure why you'd be installing TWRP.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes