• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE]Porting TWRP without source

Search This thread

Augustoandro

Senior Member
Jun 20, 2017
560
240
Pune
@Augustoandro Can you create a guide on creating/porting TWRP if kernel sources are available? I have Samsung Galaxy M40 (updated to Android 11) and its sources are available at https://opensource.samsung.com/uploadSearch?searchValue=m40. The main concern than I have is how do I test any TWRP/Recovery if I started to port any recovery image. I have not done this before so any help would be appreciated.
I tried porting using kernel sources for one of my devices but ended up bricking it.
I don't have anymore devices to test, so there won't be a guide for a while.
 

Suji2k

Member
May 10, 2021
44
1
I have vivo y15s and unlocked bootloader but after unlock it goes to stock recovery and wipes data itself without prompting. But wiping data fails and it does not boot system because after vivo logo it reverts back to stock recovery and fails to wipe data.
I used twrp build by auto porting by hovatek, but it didn't boot. I have a stock recovery and all firmware dump. Will the problem solved using twrp? Can you please build a Twrp?
This problem cannot be solved even I flash full firmware using sp flast tool(mtk6580), only restoring dump backup solves the problem.
firmware version: PD1304DW_EX_A_1.70.5
Stock Recovery Link(bin format): https://drive.google.com/file/d/18f6ithUDCr1NSkxzcZoUpol_OzCJ8UKf/view?usp=sharing

boot.bin: https://drive.google.com/file/d/1VC6Rg40fVb2a-iMmvwhmze8mpZjUC_wl/view?usp=sharing

Scatter file: https://drive.google.com/file/d/1G4M9XziBV5nIbULZsO4nYGPHT2DjHMOt/view?usp=sharing

Available version firmware in google: PD1304DE_EX_A_1.10.5
Recovery: https://drive.google.com/file/d/1U_qP6PsQPdY7THN2F_YqlhgXfEYYiD94/view?usp=sharing


Tried patched boot image but all goes to wipe data failed and in fastboot mode to remote failed.
 

Augustoandro

Senior Member
Jun 20, 2017
560
240
Pune
@Augustoandro Instead of using motorolanexus6 as base TWRP

can we use TWRP of a device which is very similar to ours? In Galaxy M40's (1080 x 2340p resolution) case it would be Redmi Note 7 Pro.
Yes, you can. The TWRPs I suggested in the guide are most editable. And have had the most success according to my experience.
If you find better editable ones, you are free to use them.

HIT THANKS IF FOUND USEFUL
 
  • Like
Reactions: rohitrss

Augustoandro

Senior Member
Jun 20, 2017
560
240
Pune
I have vivo y15s and unlocked bootloader but after unlock it goes to stock recovery and wipes data itself without prompting. But wiping data fails and it does not boot system because after vivo logo it reverts back to stock recovery and fails to wipe data.
I used twrp build by auto porting by hovatek, but it didn't boot. I have a stock recovery and all firmware dump. Will the problem solved using twrp? Can you please build a Twrp?
This problem cannot be solved even I flash full firmware using sp flast tool(mtk6580), only restoring dump backup solves the problem.
firmware version: PD1304DW_EX_A_1.70.5
Stock Recovery Link(bin format): https://drive.google.com/file/d/18f6ithUDCr1NSkxzcZoUpol_OzCJ8UKf/view?usp=sharing

boot.bin: https://drive.google.com/file/d/1VC6Rg40fVb2a-iMmvwhmze8mpZjUC_wl/view?usp=sharing

Scatter file: https://drive.google.com/file/d/1G4M9XziBV5nIbULZsO4nYGPHT2DjHMOt/view?usp=sharing

Available version firmware in google: PD1304DE_EX_A_1.10.5
Recovery: https://drive.google.com/file/d/1U_qP6PsQPdY7THN2F_YqlhgXfEYYiD94/view?usp=sharing


Tried patched boot image but all goes to wipe data failed and in fastboot mode to remote failed.
Feel free to use this guide for porting a TWRP of your own.
I have stopped porting TWRP for others since I don't have that much time anymore.
 
  • Like
Reactions: Suji2k

Suji2k

Member
May 10, 2021
44
1
Feel free to use this guide for porting a TWRP of your own.
I have stopped porting TWRP for others since I don't have that much time anymore.
Okay sir, I ported twrp successfully and luck is that it has zero bug. So thanks to you also. Now issue is of stock rom, need custom rom for rooting, so stepping forward to it. If anybody want twrp, I may just port it but I cant say it always work. Thank you sir.
 

Augustoandro

Senior Member
Jun 20, 2017
560
240
Pune
Okay sir, I ported twrp successfully and luck is that it has zero bug. So thanks to you also. Now issue is of stock rom, need custom rom for rooting, so stepping forward to it. If anybody want twrp, I may just port it but I cant say it always work. Thank you sir.
Just flash Magisk. You don't need a custom ROM for rooting. Flashing Magisk zip will do the trick.

HIT THANKS IF FOUND USEFUL
 

Fury_Phoenix

Member
Mar 11, 2020
21
1
Erm.... I understand how to do it, but I don't know how to pull recovery.img and there isn't any image on the internet. It's for a SGH-T959P, Canadian variant. I know I should be probably quitting trying to port TWRP to it though. The closest thing I have is /recovery which is a file...
 
Mar 25, 2012
1,053
772
31
Crete,,,Heraklio
Just flash Magisk. You don't need a custom ROM for rooting. Flashing Magisk zip will do the trick.

HIT THANKS IF FOUND USEFUL

Hey, I just found you! Hi from greece! trying for days to twrp for sda-8tab pioneer but no luck, if you can help me I will will buy you a drink! Maybe Raki like we have here in crete here is the files, is allwinner a50 cpu
1280x720 resolution, you are my last hope, please help me out, I have taken the files from emmc dump I did using easyjtag
 

Attachments

  • Imgs.zip
    19.5 MB · Views: 2

jnvl_wolf

New member
Sep 17, 2021
4
0
Samsung Galaxy F62
Does this tutorial still work? I would like to create a twrp.img for the Samsung M62. Can anybody help me? I followed the entire procedure. Can I post here what I did for you to check if it's correct?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 34
    Yes, I know XDA is filled with such guides.
    But you can only port a TWRP if you implement parts of all the guides.
    This guide is a summation of all those guides.

    NOTE:
    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.

    REQUIREMENTS:
    1.Download these TWRP recoveries in accordance with your screen resolution.
    A. If your screen resolution is 480x850, 480x854; download
    https://twrp.me/lg/lgnexus4.html
    B. If your screen resolution is 720x1280, 800x1280 or 720xsomething; download
    https://twrp.me/asus/asusnexus720123g.html
    C. If your screen resolution is 1080x1920, download
    https://twrp.me/motorola/motorolanexus6.html
    2. Download Android Image Kitchen-Linux from this thread:
    https://forum.xda-developers.com/showthread.php?t=2073775

    LET'S BEGIN:
    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
    Code:
    su
    Enter your root password, then type
    Code:
    ./unpackimg.sh
    7. This will unpack your stock recovery.img. Do not close the terminal.
    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
    Code:
    ./unpackimg.sh
    12. This will unpack your twrp_recovery.img
    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.
    A. default.prop
    B. fstab.devicename_or_chipsetname
    C. ueventd.rc
    D. Any other file like ueventd.devicename.rc
    16. Copy and paste these files from stock ramdisk folder to new ramdisk folder.
    Code:
    default.prop
    fstab.devicename
    ueventd.rc
    17. Now go into stock ramdisk/etc folder and copy recovery.fstab
    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.
    Code:
    /external_sd          vfat         /dev/block/mmcblk1p1  flags=removable;storage;display="SDCARD"
    /usb-otg                auto         /dev/block/sda1    flags=removable;storage;display="USB-OTG"
    22. Edit the following lines as shown in default.prop
    Code:
    ro.secure=0
    ro.adb.secure=0
    security.perf_harden=0
    ro.debuggable=1
    persist.sys.usb.config=adb,mtp
    23. Now, come out of the ramdisk folder and open the terminal.
    24. Type
    Code:
    ./repackimg.sh
    25. Your new TWRP img would be generated and named as image-new.img by default. You may change the name later.

    When you have successfully built the TWRP, or if you want to request one instead of creating yourself, contact me on this thread:
    https://forum.xda-developers.com/android/general/unofficial-twrps-devices-source-code-t3833338


    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:
    Code:
    Show mount path
    Show partition name
    Show file system
    Expert mode
    Unmounted partitions
    Device Mapper partitions
    Temporary filesystems

    4. Use the root explorer to find the path of your partitions. They would be located under /dev (mtk devices have bootimg and recovery here generally) and some other partitions like /system, /cache would be deeper inside.
    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.

    TROUBLESHOOTING INSTRUCTIONS:
    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".
    https://forum.xda-developers.com/android/software/universal-dm-verity-forceencrypt-t3817389
    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
    Code:
    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)
    To resolve this, in your TWRP terminal type the following command
    Code:
    find /dev/block -name by-name
    Replace the paths of the partitions in your fstab files with the ones you get as output using the command above (only the partitions which failed to mount).

    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.

    CREDITS:
    @HostZero for his porting guide.
    @osm0sis for his awesome Android Image Kitchen
    @Zackptg5 for his "DM-Verity and Forceencrypt disabler zip".
    2
    Hi and thanks for the extensive guide!

    I'm trying to port TWRP to a digital signage display using a RK3288 chip (basically a huge 43 inch tablet)
    I managed to find a version of TWRP for RockChip devices that I was able to flash using the official TWRP app. After rebooting to recovery however, TWRP wasn't able to find the partitions properly.
    When trying to run a backup (the main scope is to be able to backup/restore), I got the following messages:


    and so on.

    I'm assuming that it's because of the recovery.fstab/twrp.fstab that are not configured properly, but I seem not to be able to match the syntax of the original files with the new ones.
    My original recovery.fstab looks like this:


    And the twrp.fstab (for now) looks like this:


    What is confusing is that I also have a recovery.emmc.fstab in my orginal ramdisk/etc folder. It looks like this:


    Since this i s a port for the same board "family" (I see RK30boar mentioned all over the place), I'm I right assuming I only need to adapt the file system tables in order to get it working?

    For good measure (and not to be blamed for not giving enough info when requesting help :D), here is the content of the original default.prop:


    Help or a hint in the right direction would be much appreciated :)
    Thanks and cheers
    Oli
    I really apologize for the delay in replying.
    Check the point number 3 in TROUBLESHOOTING INSTRUCTIONS section in the guide.
    I have just added the instructions to the guide for everyone.
    Thank you for bringing this to my attention, I had forgotten to add these instructions in the guide.

    HIT THANKS IF FOUND USEFUL
    2
    SuperSU or Magisk won't install into system but into boot and data

    in TWRP you have a terminal. type
    Code:
    ls -ld $(find /dev/block -name by-name)/*
    you can manually mount, all you need is a folder as mount point
    Code:
    mkdir /system_root
    mount /dev/block/bootdevice/by-name/system /system_root
    mount
    2
    to all people who experience boot loop on TWRP splash screen:
    Code:
    adb shell
    df
    you will figure out which mount point is crashing. fix it in fstab. you may have a look in /cache/recovery/last_log too
    for me the reason was vold mounts, i simply deleted two lines (yes, its /devices instead of /sys/devices i don't know if it is a bug, its from stock boot.img)
    Code:
    /devices/mtk-msdc.0/11120000.msdc0* auto vfat defaults voldmanaged=sdcard0:auto
    /devices/mtk-msdc.0/11130000.msdc1* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
    if touch screen is not working, you can still use touch screen when booted from fastboot (unfortunately no fix, yet):
    Code:
    fastboot boot <twrp.img>
    2
    Hi I tried to Port a Recovery for my H96 Max RK3399 TV Box .
    I used TWRP From My RK3328 TVBox.
    I can Boot in Recovery, but its not Mounting any Partition (everywhere 0MB)
    I Think the problem is in .Fstab File but I am Not sure.
    I would appreciate help

    Sorry for my poor English
    Partitions not being recognized means the problem is in fstab files. Both recovery.fstab and twrp.fstab need to be edited.
    I am sure of it.

    HIT THANKS IF FOUND USEFUL