Development [RECOVERY][3.7.0-12.1][UNOFFICIAL][UNIFIED] TWRP with A12/A13 encryption support

Search This thread

der_akinator

Senior Member
Mar 27, 2015
210
334
Berlin
OnePlus 3T
OnePlus 9 Pro

Evon88

Senior Member
Feb 4, 2019
132
17
OnePlus 6
This is an unofficial build of TWRP, based on the Android 12.1 branch, that supports encryption used by most Android 12 and 13 ROMs.

As always I'm not responsible any bricked device or data loss resulting from the use of this TWRP version. You use this at your own risk.

For ROMs using FBEv1 encryption aka A11 encryption, please use the official builds by
@Nebrassy from:


Download:



Installation:
  1. Get your rom's vendor_boot image. For most ROMs this can usually be downloaded. For OOS based ROMs you can get it for example by extracting it from the official payload.bin with payload-dumper-go. A third universal option, if you have root, is to use the command "dd if=/dev/block/by-name/vendor_boot_SLOT of=/sdcard/vendor_boot.img" on your device. This writes the vendor_boot image to your sdcard folder, but you have to substitute SLOT with either a or b, depending on your currently active slot.
  2. Reboot to bootloader.
  3. Run "fastboot flash vendor_boot vendor_boot.img" with the TWRP vendor_boot image.
  4. Run "fastboot boot boot.img" with the TWRP boot image.
  5. Go to Advanced > Flash Current TWRP.
  6. After that is done, if you were using a custom kernel, reflash it now.
  7. If you were using magisk, reflash it now.
  8. Reboot to bootloader.
  9. Run "fastboot flash vendor_boot vendor_boot.img" with the ROM vendor_boot image from step one.
In the case you just want to test TWRP without installation, please skip steps 5-7.
Permanent installation works fine for me with crdroid 13 and magisk installed. I have not tested any other ROMs or custom kernels. After permanent installation you can at any time reboot to recovery without reflashing vendor_boot. During a ROM update use the "Automatically reflash TWRP after flashing a ROM" option in the install zip menu to preserve TWRP.


Source Code:

Bugs:

Please let me know.


Thanks to:
  • Nebrassy
  • TWRP team
  • LineageOS
broooooooo, now you are helping all op9p users
much love and respect 😭
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,430
34,969
Halifax
GT-i9250
Google Nexus 4
Update

Hi everyone,
I just uploaded a new build. It fixes some missing firmware files and kernel module loading.
USB OTG, vibration and battery status is now working.

Download:
Does the A/B flashable zip with the TWRP ramdisk in it work to install it? Might be able to skip the vendor_boot steps that way.

I will try it. Thanks for your tip.
I tried it out over latest Lineage and it does seem to work! I even then re-rooted with Magisk and re-flashed blu_spark from within TWRP. 🥳

Only issue (but it's pretty big) is that vibration is broken and it seems to hang the UI hard any time it tries to vibe, so my workaround is to hit Cancel at the Decrypt page, go to Settings and turn all the vibration down to 0, then go back to Mount and Decrypt Data from there. (You can also just be verrrrrry patient when doing pattern.)

Not sure if this is because I installed the whole ramdisk directly like that or because it's over Lineage. I'm guessing the latter, with some kind of modules mismatch?

Any ideas how to resolve that? Disabling vibration entirely might be needed, since I recall @Nebrassy never got it working across all ROMs.

Either way, being able to use the TWRP zips will save a lot of headaches for rooted users. 🙂

P.S. Also great that vendor_boot is only need for fastboot tempboot, since that means my twrp_ab addon.d-v2 script should work for us already! 🤘

P.P.S. We need to get you in the TWRP Development Zulip if you're not lurking there already: https://rebrand.ly/teamwin-recovery-zulip-community

Edit: twrp-installer-3-7-0_12-0-20221129-lemonadep-zip attachment removed since a newer build exists.
 
Last edited:

der_akinator

Senior Member
Mar 27, 2015
210
334
Berlin
OnePlus 3T
OnePlus 9 Pro
I tried it out over latest Lineage and it does seem to work! I even then re-rooted with Magisk and re-flashed blu_spark from within TWRP. 🥳

Only issue (but it's pretty big) is that vibration is broken and it seems to hang the UI hard any time it tries to vibe, so my workaround is to hit Cancel at the Decrypt page, go to Settings and turn all the vibration down to 0, then go back to Mount and Decrypt Data from there. (You can also just be verrrrrry patient when doing pattern.)

Not sure if this is because I installed the whole ramdisk directly like that or because it's over Lineage. I'm guessing the latter, with some kind of modules mismatch?

Any ideas how to resolve that? Disabling vibration entirely might be needed, since I recall @Nebrassy never got it working across all ROMs.

Either way, being able to use the TWRP zips will save a lot of headaches for rooted users. 🙂

P.S. Also great that vendor_boot is only need for fastboot tempboot, since that means my twrp_ab addon.d-v2 script should work for us already! 🤘

P.P.S. We need to get you in the TWRP Development Zulip if you're not lurking there already: https://rebrand.ly/teamwin-recovery-zulip-community
Yes, your twrp install script works for me too. Tanks for that.

I disabled vibration in a fresh build. Maybe I will find a way to get it working but it isn't important.

I think it's is reasonable for non root users to take the extra two steps in comparison to the official version because it's a one time thing. Updates are possible by using the zip installer.
 
  • Like
Reactions: galaxys and osm0sis

erad1

Senior Member
Dec 3, 2010
1,421
776
MiamiBeach
OnePlus 6
So first off ...thanks for the awesomeness! But ... I'm having an issue with roms not flashing because of a "timestamp" issue? Is there a workaround?
 

GeminiRx

Senior Member
Apr 16, 2011
164
16
HTC Desire
Samsung Galaxy S4
Quick question.
The following is not clear to me.
In step 1 it says to download your own vendor_boot.
In step 3 it says to flash it but which one? My own one or the TWRP one. (I'm currently on CrDroid13)
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,430
34,969
Halifax
GT-i9250
Google Nexus 4
You flash the twrp one in order to boot twrp, then after permanent install, you flash yours or it won't boot to os
Now that there's a TWRP zip you could skip vendor_boot shenanigans altogether by, a) flash from Magisk app, or even b) flash from custom ROM recovery like Lineage Recovery. 🤘
 

TheSayaMan

Senior Member
Sep 12, 2016
1,118
492
OnePlus 9 Pro
Now that there's a TWRP zip you could skip vendor_boot shenanigans altogether by, a) flash from Magisk app, or even b) flash from custom ROM recovery like Lineage Recovery. 🤘
Actually no, when you boot this twrp, it will not boot to twrp without the twrp vendor_boot. Likewise, the os won't boot unless you replace it with the original vendor_boot from stock, rom, etc.
 

Top Liked Posts

  • 5
    fastbootd should work...

    Also you can also flash abl while booted if you are rooted and want to do it manually, like `dd if=/sdcard/abl.img of=/dev/block/bootdevice/by-name/abl_a`

    Same works in TWRP Terminal/adb shell.
    3
    But it didn't, and the smart folks in the OP 9 Telegram group said that's because fastbootD is broken in TWRP. I always ended up with that error and no matter if I tried to get to fastbootD via fastboot command or TWRP, I always ended up in the same spot again. I was told I should restore stock boot.img and then root + install TWRP again after flashing that abl file, but that seemed like a lot of hassle when using the Firmware Flasher achieved the same thing and was so simple 😇
    That error is related to kernel module loading. All custom roms install kernel modules to vendor_dlkm, but OOS does not. It uses vendor and vendor_dlkm doesn't exist. So this error isn't nice, but just cosmetic.
    I tested fastbootd under windows and linux without any issues. You just have to make sure to install google usb drivers and select them to use fastboot with windows. I updated OP with a section related to mtp, adb and fastbootd and how to select the right drivers.
    1
    He doesn't need to edit in your abl file if he uses the Firmware Flasher. I'm not sure what exactly that flashes, but we end up with the same firmware on both slots (which I think is good for when we want to go to a custom rom?) AND without that warning. So 2 birds with 1 stone so to speak - but no editing/modifying anything is needed :cool:
    Getting the same firmware to both slots? That doesn't make the orange state go away, does it? You have to flash the right abl.img.

    Or, the firmware you are flashing has the abl.img without warning? That might be the case.

    This is a very useful guide and it has more than one way to safely flash abl.img without hassle if you are rooted.
    1
    Getting the same firmware to both slots? That doesn't make the orange state go away, does it? You have to flash the right abl.img.

    Or, the firmware you are flashing has the abl.img without warning? That might be the case.

    This is a very useful guide and it has more than one way to safely flash abl.img without hassle if you are rooted.
    It does make the orange state go away, I'm guessing it has the correct abl.img included already? And it's really simple too - just flash it from (custom) rcovery and that's it, no hassle at all.
    For all those who have TWRP installed (like me lol), which means no more fastbootD, it's the simplest solution :)
    1
    fastbootd should work...
    But it didn't, and the smart folks in the OP 9 Telegram group said that's because fastbootD is broken in TWRP. I always ended up with that error and no matter if I tried to get to fastbootD via fastboot command or TWRP, I always ended up in the same spot again. I was told I should restore stock boot.img and then root + install TWRP again after flashing that abl file, but that seemed like a lot of hassle when using the Firmware Flasher achieved the same thing and was so simple 😇
  • 6
    Update
    • unified boot image (tested on los-20221227 (OOS 12) and latest crdroid (OOS 13))
    • update usb/mtp stuff
    • exclude "/data/system/users/0/package-restrictions.xml" from backup
    Testers for the unified boot image are welcome, especially OP9 users. I think for existing backups "/data/system/users/0/package-restrictions.xml" has to be deleted manually after restore, but I haven't tested it.

    6
    Hello, I installed an Android 13 custom rom on a Samsung device with twrp-3.7.0_9-0 but unfortunately there is no encryption. Does encryption depend on the rom or on TWRP and will this TWRP version work on a Samsung phone? And is there some trick to enforce encryption when flashing custom rom with TWRP?
    First of all, this is a thread for OnePlus 9/Pro; not Samsung. Please refer to your phone's forum for better support.

    Secondly, you should have written your phone model and ROM specifically in your message, rather than just "Android 13 custom rom on a Samsung device".

    Thirdly, encryption depends on the ROM you are using. Most latest phones/ROMs automatically encrypt data upon first boot. And if they don't, you can manually enable encryption from Settings > Security (requires charger plugged in). Just go to Settings > Security to see if it's already encrypted or not. There is no trick to enforce encryption at the time of flashing ROM in TWRP; not to my knowledge at least. It's a ROM-dependent feature (and "almost" all ROMs support it).

    Lastly, looking at the TWRP version, I assume your phone is from 2017-18, and most probably TWRP would be official for your phone, and it would support decryption. If your phone/ROM is encrypted, it would ask for decryption when TWRP boots.
    6
    I can'y thank you enough @der_akinator for reviving the TWRP recovery for OnePlus 9 Pro. I'm really happy for it.
    Thank you so much, everything works fine, except MTP. I can't see my storage when connected to my PC using USB cable.
    if you can fix this it would be great.
    Thank you again.
    I can't reproduce your issues too, and it's the same for the sideloading issues addressed by @Rallyharry. I tested under windows and linux with the latest builds. The only thing I noticed was that I had to switch drivers under windows manually to WinMTP and I couldn't use mtp and adb simultaneously. But the whole windows driver system is a mess anyway.

    I pulled some minimal changes from qcom's upstream usb repo and also added a proposed patch series regarding mtp into twrp source. My tests with those changes are fine, and I can upload a new build tomorrow, if you want.
    5
    Of course, I'm talking about his existing device tree. But enough with Samsung.
    5
    fastbootd should work...

    Also you can also flash abl while booted if you are rooted and want to do it manually, like `dd if=/sdcard/abl.img of=/dev/block/bootdevice/by-name/abl_a`

    Same works in TWRP Terminal/adb shell.
  • 53
    This is an unofficial build of TWRP, based on the Android 12.1 branch, that supports encryption used by Android 12 and 13 ROMs. This build is tested on OP9 pro, but it was confirmed to work on regular OP9 too.

    As always I'm not responsible for any bricked device or data loss resulting from the use of this TWRP builds. You use this at your own risk.

    For ROMs using FBEv1 encryption aka A11 encryption, please use the official builds by
    @Nebrassy from:

    Download:


    Installation:

    Permanent installation is not possible with TMO stock ROM installed.

    Installation overwrites all boot partition changes done previously (e.g. by Magisk or custom kernel). So you have to reflash all zips that change the boot partition after TWRP is installed.

    For permanent installation, you have three options depending on your current system.

    1. Option for rooted devices:
    1. Download the twrp-installer zip
    2. Flash it with Magisk manager or some other kernel flash utility
    3. Reflash your custom kernel and Magisk.apk if previously installed (see example of how to install with Magisk manager below). Or alternatively flash zips in TWRP.
      1. Don't reboot
      2. Rename downloaded Magisk.apk to Magisk.zip
      3. Open Magisk app
      4. Select Modules tab
      5. Click "Install from storage"
      6. Select Magisk.zip
    2. Option for users with other custom recoveries but without root:
    1. Download the twrp-installer zip
    2. Reboot to recovery
    3. Flash it with "adb sideload twrp-installer*.zip"
    4. Reboot to recovery
    5. Reflash your custom kernel and Magisk.apk if previously installed
    3. Option is universal:
    1. Download boot.img
    2. Reboot to bootloader
    3. Run "fastboot boot boot.img" with the boot image
    4. Go to Advanced > Flash Current TWRP
    5. Reflash your custom kernel and Magisk.apk if previously installed

    Try without installation:
    1. Download boot.img
    2. Reboot to bootloader
    3. Run "fastboot boot boot.img" with the boot image

    Uninstall:

    Just flash the boot partition with your current ROMs boot image with the following steps.
    Replace "YOUR ROM BOOTIMAGE" with the filename of the extracted boot image of your current ROM.
    1. Reboot to bootloader
    2. Run "fastboot flash boot_a YOUR ROM BOOTIMAGE"
    3. Run "fastboot flash boot_b YOUR ROM BOOTIMAGE"
    Alternatively you can flash your currently installed OTA zip, which overwrites boot on the unused slot, but not on the currently used one.

    TWRP Updates:
    1. Download and flash the twrp-installer zip
    2. After that reflash your custom kernel and Magisk if previously installed

    ROM Updates:

    Please follow the official update instructions for your ROM!

    If they give an option to update via recovery you have to substitute adb sideload commands with zip installations. Also use the "Automatically reflash TWRP after flashing a ROM" option, if you are going to install a ROM zip to preserve TWRP installation.

    In case your ROM does not provide a recovery update instruction you can try to update via recovery but you are on the safe side if you follow the official instructions. They always have a reason for their particular update instructions!

    Instructions that work for me (on LOS based ROMs):
    1. Flash ROM zip with "Automatically reflash TWRP after flashing a ROM" checked
    2. Flash your previously installed zips (custom kernel, Gapps, Magisk, etc)
    3. Reboot to system
    4. If Gapps packages keep crashing:
      1. Reboot to TWRP
      2. Flash Gapps again
      3. Reboot to system
    For OOS updates should work out of the box, but if you have issues you can follow these steps (I haven't tested them):

    About backups/restore:

    Restore data only WITHOUT pin/pattern set.

    If you restore a backup made from another ROM, then the currently installed, you may have to format data. So please manually copy all contents from /sdcard to a PC or flash drive.

    Backups can be made with or without pin/pattern set. It is always good practice to copy your backups to your PC or an USB drive. Also after you restored your data partition you have to reboot to system and do a second reboot to get a working system.
    To make first boot faster and eliminate the need to reboot again, additionally use the step mandatory for OOS users.

    If you want to copy your backup to PC, but it doesn't show up, flash change_backup_selinux_context.zip, which is available in download folder.

    For OOS users:
    When data is restored, you have to delete "/data/system/users/0/package-restrictions.xml" before rebooting to system.

    In case you restore a backup with pin/pattern set or have some other issues I have a guide that works for me:

    How to use MTP, adb and fastbootD:

    Windows:
    Install official Google USB drivers and select the right USB drivers. For MTP and adb, the WinUSB driver is sufficient on Windows 11. For fastbootD, Google drivers (Android Bootloader interface) has to be chosen.
    You may have to select WinMTP for MTP and Google USB drivers for adb, if you run Windows 10.

    To use adb on Windows, MTP has to be disabled with "Mount->Disable MTP" in TWRP.

    Steps for choosing a specific driver (no the exact wording):
    1. Connect phone in specific mode
    2. Open device manager
    3. Right click on phone either under "Android device" or "USB device", depending on mode
    4. Select "update driver"
    5. Select 2. option "browse my computer"
    6. Select "pick from available drivers"
    7. Pick driver according to above description
    Linux:
    1. Intall the fastboot and adb packages for your distribution
    2. Set udev rules. There might be a package for your distro or use this gh repo: https://github.com/M0Rf30/android-udev-rules
    3. Add user to the group used in udev rules. Most common are "plugdev" and "adbusers"

    Source Code:

    Bugs:
    • Permanent installation alongside TMO stock isn't possible
    • Error message regarding vendor_dlkm in fastbootD for OOS users (just cosmetic and not problematic)
    • In case you notice anything else please let me know.
    If you encounter any bug, please give me description with logcat.txt and recovery.log output attached. You can copy those to your data folder in TWRP, if you go to Advanced->Copy Logs.

    Thanks to:
    • @Nebrassy for the original device tree
    • @osm0sis for the zip installer
    • TWRP team
    • LineageOS
    13
    Update
    • /data/fonts/* is excluded from backups (has to be verified by someone with backup errors)
    • screen turns completely off now
    • updated firmware files from LE2125_11.C.63 (maybe this helps with OOS13 problems)
    • initial installation is now possible without flashing vendor_boot (I tested a few combinations of installation methods and initial system configurations. So hopefully nothing is broken this time.)
    Have a happy New Year tomorrow!

    10
    Update
    • improve vibration support
    • fix kernel modules loading in fastbootd mode for custom roms (might result in an error message regarding vendor_dlkm for OOS users, but it's just cosmetic)
    Tested on LOS 19.1 (OOS 12 firmware) and crdroid 13 (OOS 13 firmware).

    10
    Update
    • add vendor_boot and dtbo to backup targets
    • add CPU temperature output
    • fix vibration (still doesn't work in fastbootd mode)
    I tested this build on LOS 19.1 (OOS 12 firmware) and crdroid 13 (OOS 13 firmware). Also keep in mind that you have to use the boot image according to your installed firmware, if you want to install/test via fastboot.

    10
    Good new for OOS users. One of the TWRP devs found a workaround for data restore on OOS. Just delete "/data/system/users/0/package-restrictions.xml", after data is restored. I will exclude this file by default in a future build, but for existing backups, the file must always be removed manually.

    Edit:
    This is also useful for custom ROMs, because it makes first boot faster and eliminates the need to reboot again.