#include <std_disclaimer.h> /* * Your warranty is now void. * * We are not responsible for bricked devices, dead SD cards, * thermonuclear war, or you getting fired because the alarm app failed. Please * do some research if you have any concerns about features included in this recovery * before flashing it! YOU are choosing to make these modifications, and if * you point the finger at us for messing up your device, we will laugh at you. * */
Let’s start with the installation process
- If you already unlocked your bootloader, start with step 3.
If you are already rooted, start with step 4.
If you already installed a previous version of TWRP, start with step 4.
If you already have TWRP installed and just want to root, start with step 5.
- First you need to unlock your bootloader. You can do so by enabling developer settings first, enable oem unlocking, then shut down your phone, hold volume up and down at the same time and while holding them plugin your charger. Your phone now should show a green screen with instructions to unlock the bootloader. Just follow them and after the unlocking your data should get wiped. After that your device will boot up and land in setup screen. Do not setup anything, just skip as much as possible, because your phone will get wiped again. Enable developer settings and make sure oem unlocking is greyed out and enabled. (If it does not show up, connect to a network first!)
- Now you need to overwrite vbmeta partition, so you can flash third party partitions. Download vbmeta.tar then go into download mode on your device. Put vbmeta.tar to AP in Odin, click start. This should finish pretty quickly, so pay attention when your device reboots, because you need to boot into recovery (Hold power and volume up after the screen turns black). When booted into recovery, wipe your data and reboot normally into system. Now you can setup your phone as usual and make sure oem unlocking is still greyed out and enabled!
- Time to flash recovery. Download (link is at the end of this post) the latest version as zip and extract it. You should end up with one single file named recovery.img. Pack it as tar with 7zip or any other compression tool you prefer. This packed tar file should only contain recovery.img and nothing else, also make sure the name is still recovery.img, otherwise Odin will refuse to flash it. In Odin put the tar file in AP and simply hit start. Congrats you now have TWRP installed!
- (Optional) You might have lost root access by flash TWRP if you followed this standard guide for rooting. If you did lose it and want to gain root access again (you can also root your device with this method, even when you never rooted your device), download the latest Magisk Manager from the canary channel and install the apk to your phone.
- If you are on stock:
Push the recovery.img file you just download for TWRP to your phone. Open Magisk Manager and hit install and patch a file. Select recovery.img and Magisk should start the patching process. Once Magisk is done, boot into TWRP. Backup your boot partition first and afterwards go into install and then hit install image on the bottom right of the screen. Select /sdcard/Download/magisk_patched.img and install it to boot. Now reboot and Magisk should work. If you run into issues after this, go into TWRP and restore the boot partition you backed up previously.
- If you are on an AOSP based rom:
Reboot to TWRP. Create a backup with boot partition. Reboot back to system, then open Magisk and hit install and patch a file. Locate the TWRP backup folder and look up your backup you just created. Select boot.emmc.win for patching. Once Magisk is done, reboot back to TWRP. Go into install and then hit install image on the bottom right of the screen. Select /sdcard/Download/magisk_patched.img and install it to boot. Now reboot and Magisk should work. If you run into issues after this, go into TWRP and restore the boot partition you backed up previously.
- If you are on stock:
So that was the easy part. The hard part is to completely read these following points!
Decryption works on this TWRP release, but only partially. That means you have to open the Settings Application first on your phone and disable a feature called strong protection. You can find it in Settings->Biometrics and security>Other security settings. It doesn’t matter when you disable it. Flash TWRP first and disable it, fine. Disable it and flash TWRP afterwards, fine. Never disable it, also fine, TWRP just fails to decrypt your data, but won’t do any harm. When this feature gets turned off, the device will generate a key which doesn't require any authentication for decryption, currently only this allows TWRP to decrypt the data partition successfully. This only applies to stock roms though, if you are using an AOSP based rom, then you don't have to do any of this.
- Disabling decryption
Disabling decryption will create many problems. First TWRP will refuse to unmount system partition and thus you might run into problems flashing various zips. So I advise you to not disable decryption. If you still want to disable it you have to open terminal in TWRP and type in "stop servicemanager" everytime you want to unmount the system partition.
Backup and Restore
Because of encryption it's more complicated to backup your data partition.
If you want to backup data you have to make sure TWRP successfully decrypted your internal storage, otherwise you will run into problems backing up.
Restoring is even more complicated. Every time you set up a rom, new crypto keys will be generated and you can't backup these. That means if you want to restore data you have to restore the whole rom first excluding data. Format data partition completely, boot it up, then go back to TWRP and restore data. You will lose your internal storage, so I'd recommend you move important stuff to external storage.
Developers specific details
- Recovery image size
For some reason the ramdisk has a size limit, so I used LZMA compression to get its size down as much as possible.
- During kernel compilation you will run into a DTC error. Apparently Samsung didn’t bother to update their DTC source in the kernel and you have to use their precompiled binary. I edited my kernel sources to automatically use their dtc binary.
- Device tree of Redmi Note 7 Pro (https://github.com/TeamWin/android_device_xiaomi_violet). Helped a lot!
- Topjohnwu for the detailed installation guide (https://topjohnwu.github.io/Magisk/i...system-as-root)
- TWRP Galaxy S10 thread for describing System-as-root pretty well
https://github.com/Grarak/android_de...-twrp/releases (Also changelog)
Note The download is a zip file, unpack it and you will get the recovery image. To flash it in Odin pack it as tar with 7zip or a compression tool of your liking.