But you can only port a TWRP if you implement parts of all the guides.
This guide is a summation of all those guides.
I would be using AIK-Linux in this tutorial, since I don't recommend Windows for all this, who knows what problems you will get into.
1.Download these TWRP recoveries in accordance with your screen resolution.
A. If your screen resolution is 480x850, 480x854; download
B. If your screen resolution is 720x1280, 800x1280 or 720xsomething; download
C. If your screen resolution is 1080x1920, download
2. Download Android Image Kitchen-Linux from this thread:
1. Unzip Android Image Kitchen zip file.
3. Now, navigate to the unzipped folder of AIK (Android Image Kitchen).
4. Just Right Click and select "Open Terminal here".
5. Copy and paste your stock recovery.img and paste it in AIK folder.
6. In the terminal, type the command
8. Cut the new folders, ramdisk and split_img, and paste them somewhere outside of AIK folder.
9. Remove the stock recovery.img in AIK folder.
10. Now, copy and paste the twrp_recovery.img according to your screen resolution in the AIK folder.
11. Now, revert back to the terminal and type
13. Delete all the files in the new split_img folder we got by unpackimg twrp_recovery.img
14. Copy and paste all the files in stock split_img folder to the new split_img folder.
15. Delete following files from new ramdisk folder.
D. Any other file like ueventd.devicename.rc
16. Copy and paste these files from stock ramdisk folder to new ramdisk folder.
default.prop fstab.devicename ueventd.rc
18. Paste the recovery.fstab file in new ramdisk/etc folder.
19. Edit the twrp.fstab file according to the newly pasted recovery.fstab
20. You will have to replace"/sdcard" with "/external_sd" and "/usb" with "/usb-otg".
21. If the partitions stated above are not available in your fstab files then add these lines. Order may change on the format in which the files are written.
/external_sd vfat /dev/block/mmcblk1p1 flags=removable;storage;display="SDCARD" /usb-otg auto /dev/block/sda1 flags=removable;storage;display="USB-OTG"
ro.secure=0 ro.adb.secure=0 security.perf_harden=0 ro.debuggable=1 persist.sys.usb.config=adb,mtp
When you have successfully built the TWRP, or if you want to request one instead of creating yourself, contact me on this thread:
SPECIAL INSTRUCTIONS FOR MEDIATEK DEVICES:
1. The recovery.fstab you will get after unpacking your stock recovery.img would be flawed in most cases. I believe OEMs do this deliberately.
2. In order to know which partition is mounted at which location and at which device, you'll need DiskInfo (Install it from Play Store) and a root explorer.
3. Enable the following Diskinfo settings:
Show mount path Show partition name Show file system Expert mode Unmounted partitions Device Mapper partitions Temporary filesystems
5. You can trace their exact locations by navigating within the /dev directory for partition names like mmcblk0p5.
SPECIAL INSTRUCTIONS FOR DEVICES THAT DON'T HAVE RECOVERY.FSTAB WITHIN STOCK RECOVERY.IMG
1. In the ramdisk/etc folder, there might be a dummy recovery.fstab file with the symbol of link on it.
2. Right click on the file and select "Show Target". You'll get to know the path of original recovery.fstab file. It might be within the unpacked recovery or inside some other partition on your phone.
For example: Honor 7C devices have their recovery.fstab in /vendor/etc folder.
1. If you get a dm-verity error or facing an encryption problem, go to this thread and flash the "dm-verity and forceencrypt disabler zip".
2. If you encounter a bootloop while booting into your new TWRP, please consult post #20 of this thread.
3. At times, the path of partitions during recovery boot is not the same as those during normal boot. That's why you may get errors like
Updating partitions details... Failed to mount '/cache' (Invalid argument) Failed to mount '/system' (Invalid argument) Failed to mount '/data' (Invalid argument) Failed to mount '/metadata' (Invalid argument) ...done Unable to mount storage Failed to mount '/data' (Invalid argument)
find /dev/block -name by-name
If there are some bugs or you need some assistance in porting TWRP, contact me by mentioning in your post, for example @Augustoandro, we'll work on it to make it bug-free.
Special thanks to @aIecxs for his troubleshooting instructions of bootloop, "Failed to mount /partition_name (invalid argument)" error and also @inguna for guiding me on how to fix the "SDCARD not detected by the TWRP" problem and also fixing the MTP, ADB not working issue.
Another thanks to @seanybiker and @avirus for their troubleshooting instructions on "DM-Verity and forceencrypt" errors.
@HostZero for his porting guide.
@osm0sis for his awesome Android Image Kitchen
@Zackptg5 for his "DM-Verity and Forceencrypt disabler zip".