[GUIDE] How to flash TWRP on the Xperia 5 II

Search This thread

Jayram2000

Senior Member
Sep 14, 2015
98
22
Tampa
OnePlus 2
Sony Xperia 5 II
PLEASE NOTE I HAVE ONLY TESTED THIS ON MY PERSONAL DEVICE RUNNING BUILD 58.0.A.10.3 WITH DATA ENCRYPTED. NEWER FIRMWARE VERSIONS HAVE ISSUES THAT I CANNOT PRESENTLY FIX, THAT IS UP TO THE TWRP DEVELOPER.



This requires you to have adb installed on your computer, magisk needs to be installed, and your bootloader needs to be unlocked.
Use this guide for bootloader unlocking and Magisk installation
https://xdaforums.com/sony-xperia-5-ii/how-to/guide-magisk-twrp-recovery-t4177209


Step 1. Download the twrp.img linked in this thread
https://xdaforums.com/showthread.php?t=4185891
Step 2. Place that .img wherever your adb is installed on your pc.
Step 3. Reboot your device to fastboot by any means. Either use
Code:
adb reboot fastboot
when your device is plugged in, or boot your device while holding volume up.
Steps 4 - 8 are optional, as they make a TWRP backup of your stock recovery. I did this just to be safe because this TWRP isn't perfectly stable yet. It does work fine so far but its just a precaution.
Step 4.
Code:
fastboot flash boot_a Twrp-Xperia5II.img
Code:
fastboot flash boot_b Twrp-Xperia5II.img
Step 5.
Code:
fastboot reboot
Step 6. TWRP should boot now. Once in TWRP, be sure to change your language, it should be Chinese by default.
Step 7. Mount all partitions, except op2 and USB. Then create a backup of at least your recovery partition, although you can do all partitions if you would like. The backup will take a couple minutes, but let it runs its course.
Step 8. Reboot back to fastboot, either via TWRP or power button methods.
IF YOU MADE A RECOVERY BACKUP LOOK BELOW STEP 11 FIRST
Step 9.
Code:
fastboot flash recovery Twrp-Xperia5II.img
Step 10.
Code:
fastboot reboot recovery
Step 11. TWRP should now be booted from the recovery partition. You can verify by trying to reboot to system like normal. The easiest way to test once booted to system is to reboot to recovery in Magisk manager. If TWRP boots you are done.

THE FOLLOWING STEPS ARE ONLY NECESSARY IF YOU MADE A RECOVERY BACKUP IN STEPS 4 - 8
Immediately after Step 8 do the following, you will need your patched magisk .img file from the magisk guide I linked above.
Step 1.
Code:
fastboot flash boot_a [your patched magisk img]
Step 2.
Code:
fastboot flash boot_b [your patched magisk img]
Step 3.
Code:
fastboot reboot
Step 4. Go back to step 9 above.
Your system should now boot like normal again, but TWRP should be flashed to recovery. Test by following the steps listed in Step 11 above. Please reply with an questions or issues.

I will attach screenshots of what you should see in some of the steps in the second post.

Special thanks to Miustone and M-Rom for the Magisk guide and TWRP respectively.
 
Last edited:

TripodKnight

Member
Mar 24, 2013
13
4
/data/media/0 is encrypted?

Thank you very much for this guide and the TWRP image file.

I have tried creating the backup of recovery per your instructions but it seems my /data/media/0 is encrypted so I can't create the TWRP backup folder. How do you remove this to create the recovery backup?

Thanks!
 

palamosteliaro

Senior Member
Jan 14, 2009
174
67
Thank you very much for this guide and the TWRP image file.

I have tried creating the backup of recovery per your instructions but it seems my /data/media/0 is encrypted so I can't create the TWRP backup folder. How do you remove this to create the recovery backup?

Thanks!

You can wipe everything on the wipe menu, which will decrypt internal storage. This is a factory reset also so you will lose everything! I tried it in hope that I will at least be able to use twrp for future backups and zip flashing, but after rebooting the storage becomes encrypted again.

TWRP on the 5 ii is useless right now imo, you cant backup/restore or even flash anything with encrypted internal storage and no access to sdcard or usb OTG.
 

Jayram2000

Senior Member
Sep 14, 2015
98
22
Tampa
OnePlus 2
Sony Xperia 5 II
Thank you very much for this guide and the TWRP image file.

I have tried creating the backup of recovery per your instructions but it seems my /data/media/0 is encrypted so I can't create the TWRP backup folder. How do you remove this to create the recovery backup?

Thanks!

Did you make sure to allow system modifications when you first booted TWRP, because that is very important. I am running an encrypted internal storage myself and it works fine for backups and flashing.
 

Jayram2000

Senior Member
Sep 14, 2015
98
22
Tampa
OnePlus 2
Sony Xperia 5 II
You can wipe everything on the wipe menu, which will decrypt internal storage. This is a factory reset also so you will lose everything! I tried it in hope that I will at least be able to use twrp for future backups and zip flashing, but after rebooting the storage becomes encrypted again.

TWRP on the 5 ii is useless right now imo, you cant backup/restore or even flash anything with encrypted internal storage and no access to sdcard or usb OTG.

I have been able to run TWRP backups and restore fine on my device, even with encrypted storage. Please make sure you allowed system modification when you booted TWRP, as that is very important. As for SD card and OTG, I cannot help there. I am not the person who ported TWRP, I simply made the guide using the steps I did to make it work.
 

TripodKnight

Member
Mar 24, 2013
13
4
Did you make sure to allow system modifications when you first booted TWRP, because that is very important. I am running an encrypted internal storage myself and it works fine for backups and flashing.

Thanks for the advice. I wasn't given the option to allow system modifications. I've reflashed multiple times and not once does the option come up. I also notice that when I try to mount system then try a backup that the system mount box becomes unchecked.

I have no idea why it would work for you and not for us others. Maybe you used a different twrp build?
 

palamosteliaro

Senior Member
Jan 14, 2009
174
67
I have been able to run TWRP backups and restore fine on my device, even with encrypted storage. Please make sure you allowed system modification when you booted TWRP, as that is very important. As for SD card and OTG, I cannot help there. I am not the person who ported TWRP, I simply made the guide using the steps I did to make it work.

I remember that prompt from my s10, but I didn't get it here. I installed a twrp in chinese (from another topic here) is yours different?
 

Jayram2000

Senior Member
Sep 14, 2015
98
22
Tampa
OnePlus 2
Sony Xperia 5 II
Thanks for the advice. I wasn't given the option to allow system modifications. I've reflashed multiple times and not once does the option come up. I also notice that when I try to mount system then try a backup that the system mount box becomes unchecked.

I have no idea why it would work for you and not for us others. Maybe you used a different twrp build?
I am using the exact same build that M-Rom posted, the one I linked. One thing to try is mounting your partitions manually in the TWRP menu prior to starting a backup. I have those all checked as mounted in my TWRP.
 

Jayram2000

Senior Member
Sep 14, 2015
98
22
Tampa
OnePlus 2
Sony Xperia 5 II
This requires you to have adb installed on your computer, magisk needs to be installed, and your bootloader needs to be unlocked.
Use this guide for bootloader unlocking and Magisk installation
https://xdaforums.com/sony-xperia-5-ii/how-to/guide-magisk-twrp-recovery-t4177209


Step 1. Download the twrp.img linked in this thread
https://xdaforums.com/showthread.php?t=4185891
Step 2. Place that .img wherever your adb is installed on your pc.
Step 3. Reboot your device to fastboot by any means. Either use
Code:
adb reboot fastboot
when your device is plugged in, or boot your device while holding volume up.
Steps 4 - 8 are optional, as they make a TWRP backup of your stock recovery. I did this just to be safe because this TWRP isn't perfectly stable yet. It does work fine so far but its just a precaution.
Step 4.
Code:
fastboot flash boot_a Twrp-Xperia5II.img
Code:
fastboot flash boot_b Twrp-Xperia5II.img
Step 5.
Code:
fastboot reboot
Step 6. TWRP should boot now. Once in TWRP, be sure to change your language, it should be Chinese by default.
Step 7. Mount all partitions, except op2 and USB. Then create a backup of at least your recovery partition, although you can do all partitions if you would like. The backup will take a couple minutes, but let it runs its course.
Step 8. Reboot back to fastboot, either via TWRP or power button methods.
IF YOU MADE A RECOVERY BACKUP LOOK BELOW STEP 11 FIRST
Step 9.
Code:
fastboot flash recovery Twrp-Xperia5II.img
Step 10.
Code:
fastboot reboot recovery
Step 11. TWRP should now be booted from the recovery partition. You can verify by trying to reboot to system like normal. The easiest way to test once booted to system is to reboot to recovery in Magisk manager. If TWRP boots you are done.

THE FOLLOWING STEPS ARE ONLY NECESSARY IF YOU MADE A RECOVERY BACKUP IN STEPS 4 - 8
Immediately after Step 8 do the following, you will need your patched magisk .img file from the magisk guide I linked above.
Step 1.
Code:
fastboot flash boot_a [your patched magisk img]
Step 2.
Code:
fastboot flash boot_b [your patched magisk img]
Step 3.
Code:
fastboot reboot
Step 4. Go back to step 9 above.
Your system should now boot like normal again, but TWRP should be flashed to recovery. Test by following the steps listed in Step 11 above. Please reply with an questions or issues.

I will attach screenshots of what you should see in some of the steps in the second post.

Special thanks to Miustone and M-Rom for the Magisk guide and TWRP respectively.

It has come to my attention that users on updated system firmware are encountering decryption issues with the TWRP version listed here, rendering it useless. I am currently running build number 58.0.A.10.3 on my X5II, however flyl0 has brought it to my attention that other build versions could be proving to be the issue.

Please note that this guide is entirely based on the steps I took to do this on my own device, which currently isn't updated to the latest version of stock firmware. I will add a note in the OP as well. Sorry for any confusion.
 

palamosteliaro

Senior Member
Jan 14, 2009
174
67
This is the same TWRP M-Rom posted in another thread, and yes it does default to chinese.

Then I am doing something wrong in my root/twrp process. I am not able to edit (R/W) the system partition anyway after installing magisk, but I think that's expected. When you are just running android, are you able to edit the system? With root explorer for example? Or does it show that the partition is full?
 

TripodKnight

Member
Mar 24, 2013
13
4
It has come to my attention that users on updated system firmware are encountering decryption issues with the TWRP version listed here, rendering it useless. I am currently running build number 58.0.A.10.3 on my X5II, however flyl0 has brought it to my attention that other build versions could be proving to be the issue.

Please note that this guide is entirely based on the steps I took to do this on my own device, which currently isn't updated to the latest version of stock firmware. I will add a note in the OP as well. Sorry for any confusion.

Thanks for the clarification. Do you have the build number 58.0.A.10.3 from xperiFirm? Would you be able to upload it so I can downgrade and then install TWRP?
 

Kaora2828

New member
Nov 16, 2020
2
0
Thanks for the clarification. Do you have the build number 58.0.A.10.3 from xperiFirm? Would you be able to upload it so I can downgrade and then install TWRP?

XQ-AS72(Hongkong or Tiwan model) is 58.0.A.10.3, I flash that, and I can use TWRP and also able to make backup.
But flash for XQ-AS52 ones (such as for EUver), I cant use TWRP(boot is OK, but cant make backup).