FORUMS
Remove All Ads from XDA

[RECOVERY] [TREBLE] TWRP with Tissot Manager (Treble & Dual boot support)

5,806 posts
Thanks Meter: 7,683
 
By CosmicDan, Senior Member on 22nd May 2018, 02:02 AM
Post Reply Email Thread
Announcement from CosmicDan: 2.5 released - TWRP 3.2.3, payload certificate fix (latest LOS), and flash payloads to the same slot!
About

This is a TWRP Installer ZIP and bootable IMG with extra capability such as Treble-izing, Dual boot repartitioning and other power-user tools with integrated Aroma Installer-powered GUI screens that I call Tissot Manager.

HIGHLY recommended reading and guide for everyone new to Treble - [TREBLE][GUIDE] From Stock to Treble - everything you need to know!. It also has some general protips hidden within there, for example the seamless/slot system interactions and nuances, so it's worth reading for anyone who wants to be a master of the Android flashing domain


Features:
  • TWRP fully Treble-ready with dual-boot ROM patcher;
  • Maintained with latest TWRP version;
  • Fully compatible with non-Treble devices - can be used as normal without Treble partitioning;
  • USB-OTG fixed
  • Has 'TWRP survival' function for automatically re-installing TWRP recovery when installing ROMs and kernels;
  • Option to install a payload ROM in the current slot, rather than the inactive one;
  • Option to ignore Payload<>Recovery certificate failures (fix for newer LOS-based ROMs);
  • Adds a "Tissot Manager" Aroma GUI to TWRP Advanced Menu (bottom-right button), which is the tool used to repartition the device for Treble and Dual boot, as well as some other nifty stuff:
    • Has the option to shrink System OR Userdata to create Vendor partitions. All relevant partitions will be resized and formatted in one go.
    • If you shrink System, you will keep max size Userdata - however it will be incompatible with non-Treble ROM's (they will crash on installing with Error 28 due to System being too small). It will Erase system, requiring you to reinstall a ROM or restore a ROM backup.
    • If you shrink Userdata, it will ERASE DATA AND INTERNAL STORAGE COMPLETELY - but your device will stay compatible with all existing non-Treble ROM's
    • Dual boot requires Userdata shrink and works by splitting into userdata_a and userdata_b. The partition split size is customizable during the repartition process.
    • Adds a "Patches" section with the following current options:
      1. Patch the current Vendor for dual-boot capability (only required if automatic patching wasn't possible). See the 'About Dual-boot' section below for more information.
      2. Enable an insecure ADBD on boot for the current slot (i.e. enable debugging and remove authentication requirement). Useful for ROM hackers/porters.
      3. Patch the current slot to enable/disable forced userdata encryption
    • All of this info is detailed inside the Tissot Manager GUI.
    • See screenshots in post 2.



Instructions
  • Optionally boot the boot-recovery.img to get a temporary TWRP if you don't have it installed, unzipped from TWRP-boot.img-3.2.1-with-Tissot-Manager-x.x.zip:
    Code:
    fastboot boot boot-recovery.img
    Warning - do not EVER flash this img - hotboot it only.
  • Flash the TWRP Installer. Any slot, any ROM, any existing Recovery - it doesn't matter - it will be installed to both slot kernels.
  • Reboot Recovery
  • Optional - Use the "Advanced > Tissot Manager" option for repartition options and other advanced ROM patches (Aroma Installer powered GUI - a fully guided and interactive process).

If you opted to repartition for Treble, you are ready to flash a Treble ROM/Vendor pack. Reminder - check out my full guide for learning and instructions on all things Treble.

About TWRP survival

TWRP survival is a simple hook that detects if a boot.img will be installed and restores TWRP after it's flashed. [B]This only works if you have booted TWRP with Tissot Manager 2.0 from a real recovery boot - NOT from a recovery 'hot boot' (fastboot boot method).

You will see in the install log if a TWRP survival attempt is successful in the flash text output.

Automatic TWRP survival works when:
  • Flashing a ROM ZIP (or AIO) with TWRP
  • Flashing a boot.img in TWRP "Install Image" mode

Automatic TWRP survival does NOT work when:
  • Flashing a boot.img via fastboot
  • Restoring boot in a TWRP backup
  • Any other way of flashing a boot.img

In these cases, be sure the use the TWRP Installer immediately after flashing or restoring a backup - otherwise you may get the device into a confused state (especially if you restore a non-TWRP boot then try to install an AIO ROM without installing a new TWRP first).



About Dual-boot

Dual-boot on this device is relatively simple. As you know we have Slots - boot_a and _b, system_a and _b and vendor_a and _b (for Treble). This repartition splits userdata into userdata_a and _b too. You can simply change your Slot in TWRP reboot menu to change which ROM to boot.

This is designed for developers and testers - NOT for daily use. There are some significant issues with dual boot systems:
  • Any kind of security lock (PIN, fingerprint, etc.) set on one ROM will cause the other ROM to believe it has security too, but constantly fail with unlocking. This is reportedly because security info is stored on persist, which is shared between each slot (and not compatible with differing ROM's).
  • Because Userdata is split, so is Internal Storage. In TWRP, when changing slots, the MTP will remain mounted to the old slot - it must be manually disabled and renabled (Mounts menu) to update to the new slot.

I will not fix these issues - dual-boot is not designed to be for general/daily use and there may be more minor issues that I don't know about. It's intended for developers only.

In order for a ROM to be dual-boot compatible, the fstab file (information given to Android about partitions to mount) needs a small modification. This TWRP can try to do this patching automatically when you install a ROM, or it can be done manually in Tissot Manager's Patches menu (as well as single-boot patch to e.g. revert a ROM backup from a dual-boot state).

You will see in the install log if a dual-boot patch attempt is successful in the flash text output.

Automatic dual-boot patch occurs only if necessary when:
  • Flashing an AIO Treble ROM ZIP with TWRP
  • Flashing a vendor.img in TWRP "Install Image" mode

Automatic dual-boot patch does NOT work when:
  • Flashing a vendor.img via fastboot
  • Restoring vendor in a TWRP backup
  • Any other way of flashing a vendor

In any of these cases, you can manually patch Vendor for Dual Boot in Tissot Manager's Patches menu. You can also remove dualboot support the same way. It will detect the dualboot state of the current Vendor slot and present the available option. If you find that it doesn't actually change after patching, the Vendor is incompatible (please report it to me). RR AIO Vendor is tested OK.



Download


All downloads (and source code) always at:

https://github.com/CosmicDan-Android...issot/releases

...or via DevBB Downloads section.


Additional sources not able to be listed in DevBB:
Modified update_engine: https://github.com/CosmicDan-Android/android_system_update_engine_tissotmanager-mod


What's next?


See [TREBLE][GUIDE] From Stock to Treble - everything you need to know! for detailed instructions and learning on how to Treble like a pro.




FAQ


Q) After I flash TWRP, I get kicked into a Recovery loop when trying to boot the ROM!
A) This is probably because you have a kernel that does not disable dm-verity. To fix this, flash Magisk. The void kernel included in RR AIO does not have this problem and can therefore be safely used without Magisk (for e.g. GSI compatibility).

Q) After I flash TWRP, I get kicked into fastboot when trying to boot the ROM!
A) Your kernel is not Treble-compatible.

Q) How do I update TWRP?
A) Just flash the ZIP installer again, then Reboot Recovery. Note that this will erase Magisk on BOTH slots if you have it installed to either, requiring you to reflash it to one/both slots. See my Treble guide FAQ section for more info on Magisk interaction.

Q) My PC can't see the MTP (storage) device from TWRP!
A) For dualboot compatibility, MTP is automatically disabled at various points. Just enable it manually in the Mounts menu to get access.

Q) If I shrink Userdata for Treble, will stock and OTA work?
A) I have heard varying results on this. It does for some, not for others. Please assume that this will NOT work. It will definitely not work if you have shrunk system.

Q) Can I restore a non-Treble TWRP backup after I repartition for Treble? And the other way around?
A) Yes! In fact, this is the easiest way for...
  • ...using stock ROM on Treble repartition (requires Userdata shrink ONLY). May also require a custom kernel with dm-verity disabled (see Questions above regarding fastboot kick and recovery loop).
  • ...using a non-treble ROM if you shrunk System instead of Userdata since you cannot install non-Treble ROM ZIPs with a shrunk System (see next Q)
Q) I get some Error 28 when trying to install a ROM when repartitioned
A) You have shrunk System and are trying to install a non-Treble ROM. This is not possible AT ALL because the ROM ZIP expects a stock-size System. Use Userdata shrink mode instead if you want to be able to use non-Treble ROM's easily.

Q) I see "Failed to mount '/system' (Device or resource busy)" red error in TWRP after flashing a ROM
A) You can safely ignore it. You just need to reboot recovery before you can flash anything else (like Gapps) to this ROM.



Credits and Thanks
- @mohancm for the original TWRP port, I used some flags from his DT
- @ghpranav and @mountaserhalak for the RR device tree that this is built with (and random help)

XDA:DevDB Information
TWRP with Tissot Manager (Treble & Dual boot support), Tool/Utility for the Xiaomi Mi A1

Contributors
CosmicDan
Source Code: https://github.com/CosmicDan-Android..._xiaomi_tissot


Version Information
Status: Stable

Created 2018-05-29
Last Updated 2018-08-18
The Following 115 Users Say Thank You to CosmicDan For This Useful Post: [ View ] Gift CosmicDan Ad-Free
 
 
22nd May 2018, 02:02 AM |#2  
CosmicDan's Avatar
OP Senior Member
Flag Sydney
Thanks Meter: 7,683
 
Donate to Me
More
Reserved
The Following 3 Users Say Thank You to CosmicDan For This Useful Post: [ View ] Gift CosmicDan Ad-Free
22nd May 2018, 02:03 AM |#3  
CosmicDan's Avatar
OP Senior Member
Flag Sydney
Thanks Meter: 7,683
 
Donate to Me
More
Screenshots (click for slightly larger non-cropped version)


Screenshot of new TWRP button:

_______________



Main menu (stock partition map detected):

_______________



Repartition choice type when coming from stock:

_______________



Repartition wipe warning/disclaimer if chosing to shrink Userdata for Treble:

_______________



Main menu (Shrunk Userdata type Treble partition map detected):

_______________



Repartition wipe warning/disclaimer if chosing to restore Stock from Shrunk Userdata Treble mode:

_______________



Example of Repartition processing screen:
The Following 44 Users Say Thank You to CosmicDan For This Useful Post: [ View ] Gift CosmicDan Ad-Free
22nd May 2018, 02:04 AM |#4  
GamingDevilsCC's Avatar
Senior Member
Flag Canada
Thanks Meter: 496
 
More
Good job!
22nd May 2018, 02:27 AM |#5  
Chikoow1's Avatar
Member
Thanks Meter: 5
 
More
Nice work!
Did you tested treble roms with this? Aex now have treble support
22nd May 2018, 02:33 AM |#6  
CaioFerreira's Avatar
Senior Member
Thanks Meter: 27
 
More
Omg, you are the best man. @mohancm also huge thanks to u man, great devs in our XDA.
22nd May 2018, 03:12 AM |#7  
Senior Member
Flag Seoul
Thanks Meter: 165
 
More
I have never seen this kind of detailed, kind guide in XDA. You guys are awesome! Thanks for all this work!

One question : If I choose to shrink /userdata instead of /system,
1. Will I be able to flash stock rom by using MiFlash?
2. If I can, will I be able to get OTA and install them w/o issues?
3. Can I restore a TWRP backup that was made before repartitioning?(because of data on /data)
I think lots of people will be wondering about #3. If you think so too, then please add it in OP!
Thanks to all of you devs again!
The Following User Says Thank You to ddaggebi For This Useful Post: [ View ] Gift ddaggebi Ad-Free
22nd May 2018, 03:26 AM |#8  
CosmicDan's Avatar
OP Senior Member
Flag Sydney
Thanks Meter: 7,683
 
Donate to Me
More
Quote:
Originally Posted by Chikoow1

Nice work!
Did you tested treble roms with this? Aex now have treble support

This is just the repartition part, one step of Treble. You still need a Vendor pack. But yes, this enables Treble ROMs and the ROMs require repartition.

Quote:
Originally Posted by ddaggebi

I have never seen this kind of detailed, kind guide in XDA. You guys are awesome! Thanks for all this work!

One question : If I choose to shrink /userdata instead of /system,
1. Will I be able to flash stock rom by using MiFlash?
2. If I can, will I be able to get OTA and install them w/o issues?
3. Can I restore a TWRP backup that was made before repartitioning?(because of data on /data)
I think lots of people will be wondering about #3. If you think so too, then please add it in OP!
Thanks to all of you devs again!

1. If you do, it will wipe partition map back to stock. So you will need to repartition with Treble Manager TWRP again. But you can make a backup of stock ROM in TWRP and just restore it after the repartition. It should work.
2. Don't know. Needs testing.
3. Yes! I forgot to add this to the FAQ.
The Following 8 Users Say Thank You to CosmicDan For This Useful Post: [ View ] Gift CosmicDan Ad-Free
22nd May 2018, 07:04 AM |#9  
Senior Member
Flag venice
Thanks Meter: 85
 
Donate to Me
More
Has this tpwr f2fs support and working?
Since Los support It i would like ti have
22nd May 2018, 08:51 AM |#10  
Senior Member
Thanks Meter: 103
 
More
@CosmicDan

Thank you so much for your effort. I'm currently on stock and want to retain stock compatibility, so I'm going to wait until this becomes more polished before trying. I understand that Treble is not meant to be compatible with stock, so I realize my question might be out of place. Still, my question is:

Will you also release the .img file for Treble TWRP for those of us who don't want a permanent custom recovery?
22nd May 2018, 09:01 AM |#11  
Senior Member
Flag Å iauliai
Thanks Meter: 810
 
More
Quote:
Originally Posted by Filip013;76586434 [MENTION=1844875

CosmicDan

Thank you so much for your effort. I'm currently on stock and want to retain stock compatibility, so I'm going to wait until this becomes more polished before trying. I understand that Treble is not meant to be compatible with stock, so I realize my question might be out of place. Still, my question is:

Will you also release the .img file for Treble TWRP for those of us who don't want a permanent custom recovery?

It's indeed not intended to be compatible with stock ROM, but your mileage may vary, and as @CosmicDan said, it might work good enough or it won't. You can only try to see the results yourself.
This whole Treble thing is meant mainly for custom ROMS, since stock will never be Treble compatible (still, anything could happen)
The Following 2 Users Say Thank You to airidosas252 For This Useful Post: [ View ] Gift airidosas252 Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread