TWRP and Xiaomi Anti-rollback - Android Q&A, Help & Troubleshooting

There is an excellent explanation of Xiaomi's antirollback features elsewhere on the site. The thread contains a general overview of the steps required to install TWRP to flash a custom ROM. In brief (i) boot into TWRP installed on local machine with adb (ii) use TRWP to install TWRP itself and/or the ROM (iii) flash away....
My experience has been that TWRP run from the local machine cannot decrypt and access the file system to read/write/execute files. This is despite using the correct PIN, no PIN, factory reset. Note that TWRP cannot access /data so cannot selectively format it.
Any suggestions for a n00b???

droid_tsar said:
There is an excellent explanation of Xiaomi's antirollback features elsewhere on the site. The thread contains a general overview of the steps required to install TWRP to flash a custom ROM. In brief (i) boot into TWRP installed on local machine with adb (ii) use TRWP to install TWRP itself and/or the ROM (iii) flash away....
My experience has been that TWRP run from the local machine cannot decrypt and access the file system to read/write/execute files. This is despite using the correct PIN, no PIN, factory reset. Note that TWRP cannot access /data so cannot selectively format it.
Any suggestions for a n00b???
Click to expand...
Click to collapse
You cannot decrypt it because of:
a: you have to flash twrp with working decryption
b: boot to a custom recovery, WIPE DATA ONLY NOT FACTORY RESET (in advance) then flash Disable_Force_Encryption.zip (This will prevent the system to encrypt data from first boot)
Of course, everything you need is on XDA, just find it.
Xiaomi's AntiRollback feature prevents you from rollbacking from e.g MIUI 10 to MIUI 9 due to the vendor and firmware issues.
More details here https://www.xda-developers.com/xiaomi-anti-rollback-protection-brick-phone/amp/

Thanks Darklouis - solved the problem by not rebooting to the system before flashing the ROM...just reboot into bootloader mode without allowing the encryption to proceed, move ROM into storage and flash from TWRP. Worked well
Darklouis said:
You cannot decrypt it because of:
a: you have to flash twrp with working decryption
b: boot to a custom recovery, WIPE DATA ONLY NOT FACTORY RESET (in advance) then flash Disable_Force_Encryption.zip (This will prevent the system to encrypt data from first boot)
Of course, everything you need is on XDA, just find it.
Xiaomi's AntiRollback feature prevents you from rollbacking from e.g MIUI 10 to MIUI 9 due to the vendor and firmware issues.
More details here https://www.xda-developers.com/xiaomi-anti-rollback-protection-brick-phone/amp/
Click to expand...
Click to collapse

droid_tsar said:
Thanks Darklouis - solved the problem by not rebooting to the system before flashing the ROM...just reboot into bootloader mode without allowing the encryption to proceed, move ROM into storage and flash from TWRP. Worked well
Click to expand...
Click to collapse
Glad to help

Related

best non-root backup before unlocking bootloader?

Hi,
I can finally unlock the bootloader - which AFAIK wipes user data. Now, since I've used the phone heavily over the waiting period, there's a lot to backup and reintegrate later on.
What's the quickest way to do so?
MTP-copy all of Internal Storage to PC -> unlock -> copy back?
(I am experienced with unlocking, rooting, flashing Roms and recoveries, but haven't had a non-rooted phone for about 8 years, so I am a bit out of the loop on non-root backup procedures)
TIA!
Using adb pull, you could probably get your internal storage.
Iirc the canonical dirs are:
/storage/emulated/0
/storage/emulated/legacy​Helium should be sufficient for apps.
For me unlocking didn't wipe data.
Only wipe was when I installed developer rom to be able to unlock.
So the process should be unlock, flash twrp and then flash magisk to maintain twrp and avoid the bootloop. Then you can backup with root and clean flash if you want.
Twrp can't decrypt data but it's not needed to flash magisk. Anyway you can flash orangefox (latest version, beta 6) from twrp and it can decrypt data to access it from recovery.
omnomnomkimiiee said:
Using adb pull, you could probably get your internal storage.
Iirc the canonical dirs are:
/storage/emulated/0
/storage/emulated/legacy​Helium should be sufficient for apps.
Click to expand...
Click to collapse
Thanks.
Any advantage of using adb vs. just mounting the device via mtp? Last I've used adb for file transfer it was slower than even mtp...
jes0411 said:
For me unlocking didn't wipe data.
Only wipe was when I installed developer rom to be able to unlock.
Click to expand...
Click to collapse
do you mean "to be able to root"? because otherwise I don't follow...
So the process should be unlock, flash twrp and then flash magisk to maintain twrp and avoid the bootloop. Then you can backup with root and clean flash if you want.
Twrp can't decrypt data but it's not needed to flash magisk. Anyway you can flash orangefox (latest version, beta 6) from twrp and it can decrypt data to access it from recovery.
Click to expand...
Click to collapse
Thanks. This is gonna sound very noob, but since I'm new to MIUI - is data already encrypted in stock MIUI? Otherwise I'll need orangefox only for switching between future custom ROMs, right?
santoo said:
do you mean "to be able to root"? because otherwise I don't follow...
Thanks. This is gonna sound very noob, but since I'm new to MIUI - is data already encrypted in stock MIUI? Otherwise I'll need orangefox only for switching between future custom ROMs, right?
Click to expand...
Click to collapse
I mean to unlock because I can't bind my mi account in stable and had to install developer rom to bind account.
Yes data is already encrypted on stock rom. If you need to access data partition in recovery you need orangefox. But it's not needed to flash magisk.
To use custom roms you don't need orangefox because you can format data from twrp and then flash the rom. I started using orangefox since I tried miui 10 oreo beta because I was unable to avoid encryption on that rom.
jes0411 said:
I mean to unlock because I can't bind my mi account in stable and had to install developer rom to bind account.
Yes data is already encrypted on stock rom. If you need to access data partition in recovery you need orangefox. But it's not needed to flash magisk.
To use custom roms you don't need orangefox because you can format data from twrp and then flash the rom. I started using orangefox since I tried miui 10 oreo beta because I was unable to avoid encryption on that rom.
Click to expand...
Click to collapse
Thanks for the explanations!
I plan on just unlocking bootloader, enabling cam2 and installing a current gcam today - I'll wait with flashing until miui10 stable is released in the next week or so, so I can do a "fair" comparison between Lineage and Miui (and possibly some others)
jes0411 said:
For me unlocking didn't wipe data.
Click to expand...
Click to collapse
A quick heads-up, just in case anyone stumbles upon this thread:
As of MIUI 9.5.17 global stable, using official MIUI unlock 3.3.525.23, unlocking the bootloader DOES WIPE user data & factory-resets the phone (to be more precise - it wipes the complete internal storage).
SD is, as expected, left alone.
santoo said:
A quick heads-up, just in case anyone stumbles upon this thread:
As of MIUI 9.5.17 global stable, using official MIUI unlock 3.3.525.23, unlocking the bootloader DOES WIPE user data & factory-resets the phone (to be more precise - it wipes the complete internal storage).
SD is, as expected, left alone.
Click to expand...
Click to collapse
I only shared my experience.
My data was wiped when I installed developer rom to bind account but when I unlocked bootloader after 360h data remained intact. When I flashed twrp phone didn't boot but I solved it flashing magisk.
jes0411 said:
I only shared my experience.
Click to expand...
Click to collapse
Yes, and I thank you for it.
I was not accusing you of anything - things may well have changed with different versions of MIUI or different versions of the unlock tool, or between chinese/global versions. Just a warning for others that, at least with the versions I posted, having a backup is reaaaaally nice :good:

Some root questions

I want to root my poco f1 ....
But i have some questions regarding it
1. Will my data be format while rooting and installing twrp
2. How i will get ota update
3. Will installing ota update also format my data?
1. Your whole internal data needs to be wiped... To flash the force decryption enabler at first...
Even while installing twrp via fastboot.. Your data will be formated
2. You will get updates... But not via ota.... Yes you will get to download the updateds in some roms... But you need to dirty flash them.
3. While dirty flashing.... Formatting data is not required.
roxor101 said:
1. Your whole internal data needs to be wiped... To flash the force decryption enabler at first...
Even while installing twrp via fastboot.. Your data will be formated
2. You will get updates... But not via ota.... Yes you will get to download the updateds in some roms... But you need to dirty flash them.
3. While dirty flashing.... Formatting data is not required.
Click to expand...
Click to collapse
Does the twrp with working decryption also need to format my data?
You can root your device in two ways.
First, with twrp (OTA won't work afterwards)
Second, without twrp (OTA will work)
First method, unlock the bootloader (device will be wiped)>Grab the twrp with working decryption>Boot your device into fastboot and type fastboot flash recovery twrp.img (or whatever the recovery image name is)>Now type fastboot boot twrp.img (or whatever the recovery image name is)>Once booted into twrp, swipe to allow modification>Now download Magisk installer and copy into the device>Flash it?Reboot to system>Profit.
N.B. After flashing twrp, make sure to first boot into twrp before booting into system or else device will restore stock recovery. If you need to update in future, just grab the twrp flashable update package and flash it. That's it. No need for OTA.
Second method, this will also require an unlocked bootloader. Once the bootloader is unlocked, get the stock boot image of your current software (e.g. if you are on miui 10 with October security patch, make sure to grab the stock boot image for miui 10 october). Now install Magisk manager apk in your device. Now open magisk manager and go to install. You will find an option for patching stock boot image. Click on it and select the stock boot image. Magisk will patch the boot image and will place it in your internal memory. Now boot into fastboot mode and type fastboot boot patched_boot.img (or whatever the name is). Once device is booted into system, go to Magisk and click on Install>Direct install (recommended).Magisk will get flashed by itself and reboot. Once rebooted, go to Magisk manager and check. If you do everything correctly, you are rooted.
N.B. When you get an OTA update, open Magisk and go to Unsinatll and click on "Complete uninstall". It will uninstall magisk and revert your stock boot image back. Note that, if you play witgh system partition like modifying build.prop or change host file or bootanimantion or any such thing, you won't be able to get any further OTA update. In that case, you need to flash the complete fastboot rom through MiFlash tool.
For more information, please go to Magisk thread or search online.

*Urgent* Need clarifications regarding the flashing of TWRP recovery & custom ROMs

*Urgent* Need clarifications regarding the flashing of TWRP recovery & custom ROMs
I want to flash a custom ROM (Pixel Experience Plus) on my Poco/Pocophone F1.
It would be of great help if I get clarifications regarding the following:
1. After unlocking the bootloader, is it necessary to flash TWRP recovery using 'fastboot flash recovery' cmd command, to flash a custom ROM? Or can TWRP recovery just be booted by using the 'fastboot boot' cmd command & then flash the ROM? (This is because I'd prefer to flash a custom ROM without permanently flashing TWRP recovery, I want TWRP temporarily)
2. In case if it's necessary to flash TWRP using 'fastboot flash recovery' cmd command, then do I have to flash DFE (Disable Force Encryption). Can I skip flashing DFE? (Because I don't want to flash DFE & want TWRP temporarily)
3. I want a clean install of the custom ROM. So, can I wipe Dalvilk/ART cache, Data, System, Cache, Internal Storage, SDCard? i.e. everything except, USBOTG (Because, the custom ROM & firmware ZIP files are stored in it & I'll flash them from USB OTG device).
Would this type of wiping affect the TWRP recovery?
4. After wiping everything except USBOTG, can the custom ROM & firmware ZIP files be transferred into the phone's internal storage by connecting it to the PC, while in TWRP recovery?
5. Is it safe to flash the ZIP files from a USB OTG device?
6. As I already mentioned that I want TWRP temporarily (If it's possible). After flashing the firmware & custom ROM. If the recovery is still a stock Mi recovery. Would it affect the functioning of the custom ROM in any way?
If all of the above can be done, is this one of the proper way to flash/boot TWRP recovery & flash a custom ROM? If not, please guide me accordingly.
imegsp said:
I want to flash a custom ROM (Pixel Experience Plus) on my Poco/Pocophone F1.
It would be of great help if I get clarifications regarding the following:.
Click to expand...
Click to collapse
i'm no expert and i'm fairly new to flashing if you're kind enough to read it here's my 2cents.
1) I believe it is necessary to flash with that command & have TWRP as your custom recovery , it is packed with powerful tools. so i don't see a problem not wanting it permanently and it saves you the hassle of flashing it again when changing roms , fixes,etc..
2) Yes , you need to flash the DFE so you won't encounter any errors in TWRP later.
3) " Dalvilk/ART cache, Data, System, Cache " this should be okay , no need to flash everything. for best practices do a factory wipe in TWRP and in advanced mode wipe those 4. make sure to create a backup in-case something goes wrong.
4) I haven't tried this yet , but it seems not doable as you need permission in the phone for the default USB connection toggle if it's in data transfer mode , usb debuggin , charging etc. best is boot your phone then do the transfer in file manager.
5) Yes it is safe since OTG is another form of External Data devices such as SD Card , etc.
6) No it wouldn't affect the rom functionality since rom and recovery is two different thing.. but still , to avoide future mishaps stick with TWRP
you can check this helpful link by madsponge26 : https://forum.xda-developers.com/poco-f1/how-to/xiaomi-poco-f1-unlock-bootloader-custom-t3839405
imegsp said:
I want to flash a custom ROM (Pixel Experience Plus) on my Poco/Pocophone F1.
It would be of great help if I get clarifications regarding the following:
1. After unlocking the bootloader, is it necessary to flash TWRP recovery using 'fastboot flash recovery' cmd command, to flash a custom ROM? Or can TWRP recovery just be booted by using the 'fastboot boot' cmd command & then flash the ROM? (This is because I'd prefer to flash a custom ROM without permanently flashing TWRP recovery, I want TWRP temporarily)
2. In case if it's necessary to flash TWRP using 'fastboot flash recovery' cmd command, then do I have to flash DFE (Disable Force Encryption). Can I skip flashing DFE? (Because I don't want to flash DFE & want TWRP temporarily)
3. I want a clean install of the custom ROM. So, can I wipe Dalvilk/ART cache, Data, System, Cache, Internal Storage, SDCard? i.e. everything except, USBOTG (Because, the custom ROM & firmware ZIP files are stored in it & I'll flash them from USB OTG device).
Would this type of wiping affect the TWRP recovery?
4. After wiping everything except USBOTG, can the custom ROM & firmware ZIP files be transferred into the phone's internal storage by connecting it to the PC, while in TWRP recovery?
5. Is it safe to flash the ZIP files from a USB OTG device?
6. As I already mentioned that I want TWRP temporarily (If it's possible). After flashing the firmware & custom ROM. If the recovery is still a stock Mi recovery. Would it affect the functioning of the custom ROM in any way?
If all of the above can be done, is this one of the proper way to flash/boot TWRP recovery & flash a custom ROM? If not, please guide me accordingly.
Click to expand...
Click to collapse
1. if you always want to depend on PC to trigger your Poco in to recovery then use command "fastboot boot recovery.img", otherwise lets say you are on the move and got pixel update! you can simply download it , and flash it in 15 mins on the go , so mainly its upto you . from security point of view, yes its not good to have twrp flashedi n your /recovery , anyone can boot and do harm! , so its a judgement call for you...
2. again upto you, DFE wont interfere/confilt with either rom or twrp
3. android device have various paritition wiping "/system" & "/data" (user setting and apps & appdata) is ENOUGH and called CLEAN FLASHING in various threads of custom roms. you don't have to wipe internal storage!!! you will lose you data... BUT YES if you get encryption error then you must click "FORMAT DATA" button on twrp in order to make storage usable/accessable to twrp. this FORMAT DATA will format your /data /system and /internalStorage partitions and you will delete all your data! then you can flash custom rom of your choice from scratch
4. you don't get access of TWRP FILEMANAGER via fastboot commands from pc, BUT you can do similar by enableing TWRP SIDELOAD option under settings, this adb sideload is a mode listening for new incoming file to flash! if you side load pixelrom.zip from fastboot command while your twrp has active sideload waiting, fastboot will start sending the file and twrp will wait and as soon as the transmit is completed! the file will automatically be flashed!. ,
however you can put files in usbotg drive or combo drive and using file manager in twrp move files from HERE to THERE!
5. I always do it!, but make sure the connection is not faulty!!! otherwise high chances of incomplete flashing and I lost my redmi3i due to impcomplete flashing of stable rom! (bricked)
6. no it wont affect! infact you can even keep the /recovery partition blank! ( fastboot erase recovery).
for MIUI FLASHING/ROOTING / Disabling force encryption etc , this post is king
https://forum.xda-developers.com/poco-f1/how-to/xiaomi-poco-f1-unlock-bootloader-custom-t3839405
I am on HAVOC2.8 and this is how i did it
1. flashed TWRP 3.3.1 unofficial (download it from HERE ) ref Reference - as official twrp has TOUCH driver issues. this one worked with me very well
2. I wiped /data, /system then
3. flashed VENDOR.zip from HERE
4. FLASHED CUSTOM ROM (i use HAVOC2.8)
5. FLASHED DFE HERE - REFERENCE
6. FLASHED GOOGLE APPS ( GAPPS.ORG) ( ARM64>9.0MicroPackage)
7. Flash Optimus Drunk Kernel ( OPTIONAL- havoc uses shadow kernel , i feel OD kernel is better, battery and 4g connectivity)
8. FLASHING MAGISK19.3
9. when i was on havoc2.7, by using MIGRATE, it made flashable zip of my APPS+DATA, stored in internalStorage, and now I will FLASH that file., Mine size goes to 2gb you can get it from HERE
10. WIPE CACHE/DELVIK
11. REBOOT
fire reboot may go in to bootloop and then second reboot may take a while and finally you should see Pixel Setup asking google accounts and info etc
once after you finish setup! don't RESTORE APPS from PLAYSTORE, (download only license apk, in my case I have purchases many apps from playstore and saperate license info is always appear in intial setup! SELECT THOSE ONLY)
ONCE playstore is DONE downloading all your selected (fewer) apps, and MAGISK ROOT is working...... put device on AIRPLANE MODE
FROM DROP DOWN Notification panel, CLICK MIGRATE, and it will prompt you what do you wana restore from your previouce ROM to newly flashed HAVOC ..APPS+SETTINGS+PERMISSION+DATA etc - migrate restoration may take upto 30 mins,
once done, uninstall from system and reboot device!
REMEMBER I DONOT RECOMEND MIGRATE TRICK FOR WHATSAPP, it doesn't work properly and NOTIFICATION ISSUES with BLANK DP observed by me whenever I forcely re-instated whatsapp by migrate!

Can't install TWRP without rooting; need... better drivers...?

Followed the instructions on several websites such as this one here at XDA:
https://www.xda-developers.com/how-to-install-twrp/
All goes well until I get to this line:
fastboot flash recovery recovery.img (latest TWRP image, renamed)
The command prompt window just sits there and says "(waiting for any device)"...
Most websites and forum threads seem to indicate that this is a problem with the drivers. Can anyone confirm?
FWIW, I did a total reflash of the latest stock ROM from this thread:
https://forum.xda-developers.com/ga...icial-stock-fw-update-odin-thread-xx-t3825204
so I currently have only the "stock" recovery.
I'd rather not root it quite yet. Help please?
P.S. The phone shows up in Device Manager and for "adb devices"; the phone's bootloader has been unlocked... can't see what I'm missing... I'm using a Windows 10 computer... I removed any screen locking mechanisms (PIN, fingerprint, etc.)...
Follow this instructions https://forum.xda-developers.com/galaxy-note-9/development/recovery-twrp-galaxy-note9-exynos-t4097441
Most samsung device use odin to install twrp
ACC18 said:
Follow this instructions https://forum.xda-developers.com/galaxy-note-9/development/recovery-twrp-galaxy-note9-exynos-t4097441
Most samsung device use odin to install twrp
Click to expand...
Click to collapse
Thanks. I'm trying it with 3.4.0-0
Do I flash this file while I'm still in TWRP? Or do I reboot the phone and go back *into* TWRP to flash it?
>After booting in TWRP download and flash no-verity-opt-encrypt-6.1 zip to disable data partition encryption
Edit: I tried flashing no-verity-opt while still in TWRP. Got the dreaded:
"Verification failed.
Unable to restart your device. The integrity verification has failed. You need to reset your device to factory default settings. This will erase all your data."​
I *really* tried to follow the instructions exactly, and think I did.
Was it because I tried to flash 3.4.0-0...?
I am currently re-flashing the stock firmware again.
Dougmeister said:
Thanks. I'm trying it with 3.4.0-0
Do I flash this file while I'm still in TWRP? Or do I reboot the phone and go back *into* TWRP to flash it?
>After booting in TWRP download and flash no-verity-opt-encrypt-6.1 zip to disable data partition encryption
Edit: I tried flashing no-verity-opt while still in TWRP. Got the dreaded:
"Verification failed.
Unable to restart your device. The integrity verification has failed. You need to reset your device to factory default settings. This will erase all your data."​
I *really* tried to follow the instructions exactly, and think I did.
Was it because I tried to flash 3.4.0-0...?
I am currently re-flashing the stock firmware again.
Click to expand...
Click to collapse
You need to format data after install twrp. This is avoiding internal data encrypted.
After twrp installed, do format data from twrp. Of course all of ur data on internal erased. And then take custom rom. I suggest devbase rom, this have "no verity encrypt" when u install this rom. Devbase is stock firmware for easy upgrade for rooted phone. And this is easy to install for beginner
Sorry for bad English
ACC18 said:
You need to format data after install twrp. This is avoiding internal data encrypted.
After twrp installed, do format data from twrp. Of course all of ur data on internal erased. And then take custom rom. I suggest devbase rom, this have "no verity encrypt" when u install this rom. Devbase is stock firmware for easy upgrade for rooted phone. And this is easy to install for beginner
Sorry for bad English
Click to expand...
Click to collapse
No worries. Thank you for your help.
I use Odin to install the Devbase ROM, right? Or can I use TWRP?
Edit: apparently it works just fine to install it with TWRP.
Thank you so much. This time TWRP works just fine for me and the new ROM is great.

After P.Experience Rom TWRP is gone and everything is encrypted

Hi. I installed Android 12 Pixel Experience rom and my TWRP gone after this. After installing the rom, TWRP replaced with Pixel Experience's own recovery mode. Currently, the ROM is installed and I can use it without any problems, but I cannot switch to a different ROM in any way. When I install TWRP with ADB, I cannot install the file named "DM Verity & ForceEncrypt disabler" because everything is encrypted. I do not use any passwords on the ROM (fingerprint, screen lock, etc.). I want to install new ROM so I need to make TWRP permanent and remove encryption on TWRP, because i can't see my files. As I said, the phone is can open and I can use it without problems. Looking forward to your help, thank you.
1) Backup everything
2) Install twrp and sideload the PE rom but don't boot into it
3) Flash the DFE (disable force encryption ) zip from twrp
4) Boot into the rom
Remember you won't get the ota updates if you disable the encryption and have to manually update the rom
easdasd617 said:
Hi. I installed Android 12 Pixel Experience rom and my TWRP gone after this. After installing the rom, TWRP replaced with Pixel Experience's own recovery mode. Currently, the ROM is installed and I can use it without any problems, but I cannot switch to a different ROM in any way. When I install TWRP with ADB, I cannot install the file named "DM Verity & ForceEncrypt disabler" because everything is encrypted. I do not use any passwords on the ROM (fingerprint, screen lock, etc.). I want to install new ROM so I need to make TWRP permanent and remove encryption on TWRP, because i can't see my files. As I said, the phone is can open and I can use it without problems. Looking forward to your help, thank you.
Click to expand...
Click to collapse
You need to read the instructions before you flash anything. PE A12 is encrypted by default and because TWRP can't handle the decryption of A12 ROMs, PE replacing the TWRP with PE Recovery, so to be able to get OTA updates. This is a workaround until TWRP fix the decryption issue.
To flash another ROM, take backup of the files you want from your Internal Storage, flash TWRP via ADB, wipe everything and format data. Then connect your device to PC and transfer the ROM and the files you want to flash into your Internal Storage and proceed with flashing.

Categories

Resources