[Recovery] TWRP 2.8.7.x for the G925T on 5.1.1 (OF6) + [Kernel]Aou's OH6 Stock Kernel

Search This thread

Aou

Senior Member
Aug 4, 2008
794
778
Arizona
Intro:
I've put in a serious number of hours poking around my G925T that I've upgraded to the official G925TUVU2COH6 firmware, trying to get TWRP installed and working on our device. With help from @bigbiff, @_that, and several testers in this thread, we finally have something working solid for our device. Before continuing, please take a moment to read through the extremely-relevant warnings below:
WARNING: Intentionally modifying your System partition from TWRP recovery, without first flashing a custom kernel (kernel must have no "verify" mount parameter in fstab), will likely cause a soft-brick (boot-loop). Before flashing this (or any) custom recovery/kernel, it is advised that you know how to restore your phone back to OH6 stock using Odin.

Note: Flashing a custom kernel (while keeping a stock System/ROM) may cause your device to report a security threat. If you proceed without caution, the device will literally attempt to re-flash the stock OH6 kernel again. It is possible to freeze "Security Log Agent" (or uninstall it completely), and this should keep your device from reporting this problem. Other reports say that using "Smart Manager" might also report the security threat, and there are some options out there for replacing it with a patched version.

Rooted Phones: Do NOT allow "com.tmobile.pr.adapt" to obtain root permissions, EVER. This app might be something that T-Mobile uses to determine if your device has ever been rooted. I would recommend freezing/disabling this app.

Unlocked Phones: If you have unlocked your phone, you might run into problems with 5.1.1. There have been reports of phones stuck in a boot-loop when upgrading from 5.0.2 -> 5.1.1 when the phone has been unlocked or EFS/IMEI has been tampered with. Combine this with the new "FRP LOCK" (Factory Reset Protection) in 5.1.1, and you might find yourself with a complete brick with no warranty. This issue may or may not have anything to do with rooting or custom firmware.

WARNING: Flashing any custom firmware to your device will trip the KNOX Warranty Bit. At this time, this is irreversible, and might cause you problems when returning faulty devices to T-Mobile or Samsung. YMMV.
How-To-Install (The Short Version):
  1. Recognize that this will trip KNOX.
  2. Be sure you're actually already running the 5.1.1 (OH6) firmware. If you're on 5.0.2 (OCG, for example), this thread is not for you.
  3. Turn on "OEM unlocking" in Settings -> Developer options. This is the dreaded "FRP LOCK" that prohibits custom firmware from being flashed to the G925T/G920T (and maybe others) - it's something new in 5.1.1.
  4. Download and Odin-flash my v13 of TWRP 2.8.7.x.
  5. Download and Odin-flash (or TWRP-flash) my v1 build of the OH6 kernel. G920T users should use the appropriate G920T kernel for their device.
  6. (Optional): Download and TWRP-flash Chainfire's SuperSU v2.49 (.zip format).
  7. (Advice): Use Titanium Backup or some other app to freeze/disable/uninstall "SecurityLogAgent" (remove nagging about security) and "com.tmobile.pr.adapt" (remove nagging about root, helps with sleep, and may be used by T-Mobile to determine your rooted status).
  8. Enjoy TWRP + Root with an almost-completely-stock OH6 kernel/system!
Official TWRP for G925T:
It's official! Thanks to all of our hard work in this thread, plus a bunch of work getting things fine-tuned and finalized by @bigbiff, our device is now officially supported by TeamWin! Check out the official page here. Development will continue here on this thread until further notice, and I'll always be building the latest-and greatest from source and making it available in this thread (not to mention this is the go-to place to get the latest version of my kernel).
Downloads:
Here's the Odin-flashable OF6 kernel I've built:
Version 1 (6/25/15) - built from OF6 stock kernel source, no modifications
Version 2 (6/27/15) - built from OF6 stock kernel source, fixes boot-loop
Version 3 (6/28/15) - built from OF6 stock kernel source, fixes boot-loop and allows root
Version 4 (6/28/15) - built from OF6 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img
Here's the Odin-flashable OF8 kernel I've built:
Version 1 (8/10/15) - built from OF8 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img
Here's the Odin-flashable OH6 kernel I've built:
Version 1 (9/15/15) - built from OH6 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img

Here's the Odin-flashable TWRP recovery I've put together:
Version 13 (7/10/15) - also available as a Flashify .img

And, in case you need it, here's the stock OF8 recovery as an Odin-flashable:
OF8 Stock Recovery - No guarantees it won't trip KNOX (it shouldn't), but if you're needing this, you've probably already tripped KNOX. Sorry, I'm too lazy to package and upload a flashable OH6 stock kernel.

G920T users! I bring you a gift! I took the G920TUVU2DOH6 Samsung source, built it with the same modifications as I did the G925T kernel to allow modified System partitions (allows root w/o bootloop), and then stuck that into the G920T OH6 stock kernel provided by @icepuente (thanks!). Also, some additional thanks to @icepuente for testing it, too!
Version 1 (9/21/15) - FOR G920T - built from G920TUVU2DOH6 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img

Building this OH6 kernel from source:

  1. Setup your build environment for compiling Android.
  2. Download the latest NDK, unpack, etc., etc.
  3. Download the OH6 source code directly from Samsung.
  4. Update the Makefile's CROSS_COMPILE to use the NDK toolchain. Mine ended up looking like this: /home/aou/android/NDK/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-
  5. make exynos7420-zerolte_tmo_defconfig
  6. For some reason, gcc treats CONFIG_ALWAYS_ENFORCE as always defined, and therefore the kernel will, of course, always enable SELinux: Enforcing. This makes it "impossible" to root Android 5.1.1. There is a workaround:
    • rm -rf security/selinux
    • svn export https://github.com/glewarne/S6-UniKernel/trunk/security/selinux security/selinux (snags a copy of their security/linux folder...)
    • Go give the guys over at the UniKernel thread some "Thanks!" for making this workaround in their kernel, especially @AndreiLux - he was the one to author this change to their source that fixes this problem.
  7. Replace drivers/scsi/sd.c with Sujit Reddy Thumma's Deep Sleep fixed version, referenced in the UniKernel's source:
    curl https://raw.githubusercontent.com/glewarne/S6-UniKernel/master/drivers/scsi/sd.c > drivers/scsi/sd.c
  8. make -j#
  9. Go snag that juicy arch/arm64/boot/Image - This is your kernel zImage.
  10. Go download the official OH6 Odin package and extract the boot.img (kernel) from it.
  11. Unpack the official kernel using the mkbootimg_tools, available here, replace the kernel file in the unpacked boot.img, and then repack it into a boot.img again. This boot.img would need to be tarballed and md5summed to be Odin flashable.
    • You'll want to remove the ,verify from both of these files in the ramdisk: fstab.samsungexynos7420 and fstab.samsungexynos7420.fwup
    • At the bottom of default.prop, you'll want to add these two lines:
      Code:
      ro.securestorage.support=false
      androidboot.selinux=0

Building TWRP from source:

  1. Setup your build environment for compiling Android.
  2. Download the latest NDK, unpack, etc., etc. Mine ended up in ~/android/NDK.
  3. Git clone the TWRP zerolte kernel source somewhere useful. Mine was cloned into ~/android/kernel:
    git clone https://github.com/TeamWin/android_kernel_samsung_zerolte.git -b android-5.1 ~/android/kernel
    The next several steps The next several steps are performed in & relative to this path.
  4. Update the Makefile's CROSS_COMPILE to use the NDK toolchain. Mine ended up looking like this: /home/aou/android/NDK/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android- (to match my NDK path above - note I couldn't use the relative ~ path for /home/aou).
  5. make exynos7420-zerolte_defconfig (ignore warnings about 'jump')
  6. make -j# (replace # with number of CPU cores + 1)
  7. Note the location of the output kernel - you'll need it in a little bit. In my case, it would be ~/android/kernel/arch/arm64/boot/Image.
  8. Setup your Omnirom compile environment. Mine's in ~/android/omni. The next several steps are performed in & relative to this path.
  9. Git clone the TWRP zeroltetmo device source into device/samsung/zeroltetmo:
    rm -rf device/samsung/zeroltetmo && git clone https://github.com/TeamWin/android_device_samsung_zeroltetmo.git -b android-5.1 device/samsung/zeroltetmo
  10. For some reason, TWRP doesn't build too well with the Omnirom's version of busybox. Replace the whole external/busybox folder with that from cm-12.1 source:
    rm -rf external/busybox && git clone https://github.com/CyanogenMod/android_external_busybox.git -b cm-12.1 external/busybox
  11. Remember that kernel we built? Rename/copy it to replace device/samsung/zeroltetmo/kernAl. In my case:
    cp ~/android/kernel/arch/arm64/boot/Image device/samsung/zeroltetmo/kernAl
  12. At this time (7/10/15), we need to cherry-pick a change by Dees Troy from the TWRP Gerrit. This is the stuff about forcing Read-Only mode on first boot, which will help with some of the boot-loop stuff (if you still have a stock kernel). You can grab the changes fairly easily using:
    cd bootable/recovery && git fetch https://gerrit.omnirom.org/android_bootable_recovery refs/changes/15/14015/3 && git cherry-pick FETCH_HEAD && cd ../..
  13. Since we're using Omnirom source and we're going to use lunch later, we need to create device/samsung/zeroltetmo/vendorsetup.sh. We can do that like this:
    echo add_lunch_combo omni_zeroltetmo-eng > device/samsung/zeroltetmo/vendorsetup.sh
  14. Do a . build/envsetup.sh (note the space between the period and "build" - was important for my environment).
  15. lunch for omni_zeroltetmo-eng
  16. make -j# recoveryimage (again, number of CPU cores +1)
  17. Take that precious out/target/product/zeroltetmo/recovery.img and tarball/md5sum it to be Odin flashable.
  18. Flash away!

Notes about accidentally causing a boot-loop:
The OF6/OF8/OH6 kernel, out-of-the-box, checks the hash/signature of your system partition. Modifying your system partition in any way (without flashing a custom kernel that does not perform this check) will cause your device to boot-loop.
Additionally, if you decide to use TWRP to mount your System partition read-write (despite warnings), upon exiting TWRP properly, it will make some changes to your system partition for you (namely, renames /system/recovery-from-boot.p to /system/recovery-from-boot.bak to prevent some systems from re-writing over your custom recovery). This would cause the boot-loop.
You obviously have some options to avoid causing a bootloop!
Option 1a: Flash my v4 kernel above. It does not have the hash/signature checks, plus it sets SELinux to permissive (allowing root!). You'll still need to root the device manually by flashing Chainfire's SuperSU.
Option 1b: Flash a different custom kernel that does not have these checks. The S6 UniKernel seems to work fine, for example.
Option 2: Don't modify your System partition, and don't let TWRP exit properly while you have the "read-only" checkbox unchecked (in the Mount screen).


Recovering from a boot-loop:
Something go wrong? Skip a step? No big deal. To get our device back in working order, you have a couple options:
Option 1: Flash the official OH6 firmware via Odin again. In my experience, the package DOES NOT wipe your data or sdcard partitions, so it really isn't that big of a deal to do. It just takes downloading a monster-size file, and the foreknowledge on how to flash it. But, caveat, don't blame me if something goes wrong with restoring the stock firmware!
Option 2: See Options 1a & 1b in the first list above. By flashing a custom kernel that doesn't have the hash/signature checks included, it should fix the boot-loop.

More Notes:
Huge thanks to @bigbiff for reading through prior versions of this post and updating the TWRP source code to work without device without the need of heavy modification. Additional thanks to @_that for his invaluable help in this project.
 
Last edited:

Aou

Senior Member
Aug 4, 2008
794
778
Arizona
@tylerholbrook - I'm not sure what you're linking to? (broken link?)

And, to update everyone following this post, I've just uploaded v7 and a custom OF6 kernel, and replaced my DIY instructions with what I've done this time around. MUCH simpler with 2.8.7.0!

Also:

Ips7YdN.png


Is this proof enough for anyone that 5.1.1 does NOT lock the bootloader? ;)
 
  • Like
Reactions: Adizzzle

tylerholbrook

Senior Member
Feb 20, 2011
918
204
@tylerholbrook - I'm not sure what you're linking to? (broken link?)

And, to update everyone following this post, I've just uploaded v7 and a custom OF6 kernel, and replaced my DIY instructions with what I've done this time around. MUCH simpler with 2.8.7.0!

Also:

Ips7YdN.png


Is this proof enough for anyone that 5.1.1 does NOT lock the bootloader? ;)

http://xdaforums.com/galaxy-s6/sams...-stockmod-kernel-t3100395/page50#post61551321

try that one,, sorry, on my computer now. Its in the unified development section for the unified kernel.. They have a working TWRP for the non edge and there is a patched kernel that should give root for us when flashed in odin. If I read correctly. I'm still on 5.0.2 or I would test it, I just dont want to upgrade and it not work and be stuck having to flash the whole factory image. I need root for tethering ect..

---------- Post added at 08:34 AM ---------- Previous post was at 08:30 AM ----------

http://xdaforums.com/galaxy-s6/sams...-stockmod-kernel-t3100395/page50#post61551321

try that one,, sorry, on my computer now. Its in the unified development section for the unified kernel.. They have a working TWRP for the non edge and there is a patched kernel that should give root for us when flashed in odin. If I read correctly. I'm still on 5.0.2 or I would test it, I just dont want to upgrade and it not work and be stuck having to flash the whole factory image. I need root for tethering ect..
@Aou somehow Sunderwear got another mysterious update OTA that was prerooted to my understanding... more info on that is in the TMobile galaxy s6 thread in the general section.
 

Aou

Senior Member
Aug 4, 2008
794
778
Arizona
http://xdaforums.com/galaxy-s6/sams...-stockmod-kernel-t3100395/page50#post61551321

try that one,, sorry, on my computer now. Its in the unified development section for the unified kernel.. They have a working TWRP for the non edge and there is a patched kernel that should give root for us when flashed in odin. If I read correctly. I'm still on 5.0.2 or I would test it, I just dont want to upgrade and it not work and be stuck having to flash the whole factory image. I need root for tethering ect..

---------- Post added at 08:34 AM ---------- Previous post was at 08:30 AM ----------


@Aou somehow Sunderwear got another mysterious update OTA that was prerooted to my understanding... more info on that is in the TMobile galaxy s6 thread in the general section.

I'll have to mess with those tomorrow. Thanks!

(okay, now I really need to go to bed! Work in the morning...)
 
  • Like
Reactions: Adizzzle

tylerholbrook

Senior Member
Feb 20, 2011
918
204
I'll have to mess with those tomorrow. Thanks!

(okay, now I really need to go to bed! Work in the morning...)

Ha yeah no problem. Really hoping it works for us but they had success on the 920x versions as well as a fully working TWRP that could probably be used to branch and get yours fully working. Fingers crossed :good: Thanks for your hard work!
 
  • Like
Reactions: Adizzzle

ktetreault14

Senior Member
Feb 12, 2012
4,268
1,805
Largo
Did you see bigbiff released a TWRP for the other guys where everything works. Should I test out v7? I just don't want a bootloop lol
 
  • Like
Reactions: Adizzzle

Aou

Senior Member
Aug 4, 2008
794
778
Arizona
Well I can't take a backup but it doesn't screw my boot up

Really? It didn't screw up your boot? Interesting...

In any event, the v7 I had uploaded last night was not actually v7. It was some bastardized hybrid of v6 and v7. I re-uploaded the REAL v7.

Still breaks System at this time, but I'm working on it. The TWRP for the international S6 seems to have pretty much all the same source as mine, at least what they're showing right now. I'll double check and verify some stuff.

As for root, great! I'm looking into baking the same thing into my kernel, so those who want to say closer to TMO stock can do so without fear. It's possible that the SuperSU flashable zip would work on 5.1.1 if we just set SEAndroid to "permissive" which is what I see that those guys are doing, primarily. The rest is just convenience - taking advantage of:
a) some emergency-flash feature that samsung has baked in (lets the device flash or execute something on boot, if it needs to), and
b) some modified int.rc script and injecting root and starting it with every boot.

I'm looking into this, and fixing my TWRP. Also looking into the feasibility of flashing/repairing the System partition from my existing v7 broken TWRP...
 
  • Like
Reactions: jrbxx7

ktetreault14

Senior Member
Feb 12, 2012
4,268
1,805
Largo
Really? It didn't screw up your boot? Interesting...

In any event, the v7 I had uploaded last night was not actually v7. It was some bastardized hybrid of v6 and v7. I re-uploaded the REAL v7.

Still breaks System at this time, but I'm working on it. The TWRP for the international S6 seems to have pretty much all the same source as mine, at least what they're showing right now. I'll double check and verify some stuff.

As for root, great! I'm looking into baking the same thing into my kernel, so those who want to say closer to TMO stock can do so without fear. It's possible that the SuperSU flashable zip would work on 5.1.1 if we just set SEAndroid to "permissive" which is what I see that those guys are doing, primarily. The rest is just convenience - taking advantage of:
a) some emergency-flash feature that samsung has baked in (lets the device flash or execute something on boot, if it needs to), and
b) some modified int.rc script and injecting root and starting it with every boot.

I'm looking into this, and fixing my TWRP. Also looking into the feasibility of flashing/repairing the System partition from my existing v7 broken TWRP...

Yeah it didn't break system. It also didn't let me backup. Though. Haven't tried other yet.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 51
    Intro:
    I've put in a serious number of hours poking around my G925T that I've upgraded to the official G925TUVU2COH6 firmware, trying to get TWRP installed and working on our device. With help from @bigbiff, @_that, and several testers in this thread, we finally have something working solid for our device. Before continuing, please take a moment to read through the extremely-relevant warnings below:
    WARNING: Intentionally modifying your System partition from TWRP recovery, without first flashing a custom kernel (kernel must have no "verify" mount parameter in fstab), will likely cause a soft-brick (boot-loop). Before flashing this (or any) custom recovery/kernel, it is advised that you know how to restore your phone back to OH6 stock using Odin.

    Note: Flashing a custom kernel (while keeping a stock System/ROM) may cause your device to report a security threat. If you proceed without caution, the device will literally attempt to re-flash the stock OH6 kernel again. It is possible to freeze "Security Log Agent" (or uninstall it completely), and this should keep your device from reporting this problem. Other reports say that using "Smart Manager" might also report the security threat, and there are some options out there for replacing it with a patched version.

    Rooted Phones: Do NOT allow "com.tmobile.pr.adapt" to obtain root permissions, EVER. This app might be something that T-Mobile uses to determine if your device has ever been rooted. I would recommend freezing/disabling this app.

    Unlocked Phones: If you have unlocked your phone, you might run into problems with 5.1.1. There have been reports of phones stuck in a boot-loop when upgrading from 5.0.2 -> 5.1.1 when the phone has been unlocked or EFS/IMEI has been tampered with. Combine this with the new "FRP LOCK" (Factory Reset Protection) in 5.1.1, and you might find yourself with a complete brick with no warranty. This issue may or may not have anything to do with rooting or custom firmware.

    WARNING: Flashing any custom firmware to your device will trip the KNOX Warranty Bit. At this time, this is irreversible, and might cause you problems when returning faulty devices to T-Mobile or Samsung. YMMV.
    How-To-Install (The Short Version):
    1. Recognize that this will trip KNOX.
    2. Be sure you're actually already running the 5.1.1 (OH6) firmware. If you're on 5.0.2 (OCG, for example), this thread is not for you.
    3. Turn on "OEM unlocking" in Settings -> Developer options. This is the dreaded "FRP LOCK" that prohibits custom firmware from being flashed to the G925T/G920T (and maybe others) - it's something new in 5.1.1.
    4. Download and Odin-flash my v13 of TWRP 2.8.7.x.
    5. Download and Odin-flash (or TWRP-flash) my v1 build of the OH6 kernel. G920T users should use the appropriate G920T kernel for their device.
    6. (Optional): Download and TWRP-flash Chainfire's SuperSU v2.49 (.zip format).
    7. (Advice): Use Titanium Backup or some other app to freeze/disable/uninstall "SecurityLogAgent" (remove nagging about security) and "com.tmobile.pr.adapt" (remove nagging about root, helps with sleep, and may be used by T-Mobile to determine your rooted status).
    8. Enjoy TWRP + Root with an almost-completely-stock OH6 kernel/system!
    Official TWRP for G925T:
    It's official! Thanks to all of our hard work in this thread, plus a bunch of work getting things fine-tuned and finalized by @bigbiff, our device is now officially supported by TeamWin! Check out the official page here. Development will continue here on this thread until further notice, and I'll always be building the latest-and greatest from source and making it available in this thread (not to mention this is the go-to place to get the latest version of my kernel).
    Downloads:
    Here's the Odin-flashable OF6 kernel I've built:
    Version 1 (6/25/15) - built from OF6 stock kernel source, no modifications
    Version 2 (6/27/15) - built from OF6 stock kernel source, fixes boot-loop
    Version 3 (6/28/15) - built from OF6 stock kernel source, fixes boot-loop and allows root
    Version 4 (6/28/15) - built from OF6 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img
    Here's the Odin-flashable OF8 kernel I've built:
    Version 1 (8/10/15) - built from OF8 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img
    Here's the Odin-flashable OH6 kernel I've built:
    Version 1 (9/15/15) - built from OH6 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img

    Here's the Odin-flashable TWRP recovery I've put together:
    Version 13 (7/10/15) - also available as a Flashify .img

    And, in case you need it, here's the stock OF8 recovery as an Odin-flashable:
    OF8 Stock Recovery - No guarantees it won't trip KNOX (it shouldn't), but if you're needing this, you've probably already tripped KNOX. Sorry, I'm too lazy to package and upload a flashable OH6 stock kernel.

    G920T users! I bring you a gift! I took the G920TUVU2DOH6 Samsung source, built it with the same modifications as I did the G925T kernel to allow modified System partitions (allows root w/o bootloop), and then stuck that into the G920T OH6 stock kernel provided by @icepuente (thanks!). Also, some additional thanks to @icepuente for testing it, too!
    Version 1 (9/21/15) - FOR G920T - built from G920TUVU2DOH6 stock kernel source, fixes boot-loop, allows root, and fixes Deep Sleep - also available as a TWRP-flashable .zip or Flashify .img

    Building this OH6 kernel from source:

    1. Setup your build environment for compiling Android.
    2. Download the latest NDK, unpack, etc., etc.
    3. Download the OH6 source code directly from Samsung.
    4. Update the Makefile's CROSS_COMPILE to use the NDK toolchain. Mine ended up looking like this: /home/aou/android/NDK/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-
    5. make exynos7420-zerolte_tmo_defconfig
    6. For some reason, gcc treats CONFIG_ALWAYS_ENFORCE as always defined, and therefore the kernel will, of course, always enable SELinux: Enforcing. This makes it "impossible" to root Android 5.1.1. There is a workaround:
      • rm -rf security/selinux
      • svn export https://github.com/glewarne/S6-UniKernel/trunk/security/selinux security/selinux (snags a copy of their security/linux folder...)
      • Go give the guys over at the UniKernel thread some "Thanks!" for making this workaround in their kernel, especially @AndreiLux - he was the one to author this change to their source that fixes this problem.
    7. Replace drivers/scsi/sd.c with Sujit Reddy Thumma's Deep Sleep fixed version, referenced in the UniKernel's source:
      curl https://raw.githubusercontent.com/glewarne/S6-UniKernel/master/drivers/scsi/sd.c > drivers/scsi/sd.c
    8. make -j#
    9. Go snag that juicy arch/arm64/boot/Image - This is your kernel zImage.
    10. Go download the official OH6 Odin package and extract the boot.img (kernel) from it.
    11. Unpack the official kernel using the mkbootimg_tools, available here, replace the kernel file in the unpacked boot.img, and then repack it into a boot.img again. This boot.img would need to be tarballed and md5summed to be Odin flashable.
      • You'll want to remove the ,verify from both of these files in the ramdisk: fstab.samsungexynos7420 and fstab.samsungexynos7420.fwup
      • At the bottom of default.prop, you'll want to add these two lines:
        Code:
        ro.securestorage.support=false
        androidboot.selinux=0

    Building TWRP from source:

    1. Setup your build environment for compiling Android.
    2. Download the latest NDK, unpack, etc., etc. Mine ended up in ~/android/NDK.
    3. Git clone the TWRP zerolte kernel source somewhere useful. Mine was cloned into ~/android/kernel:
      git clone https://github.com/TeamWin/android_kernel_samsung_zerolte.git -b android-5.1 ~/android/kernel
      The next several steps The next several steps are performed in & relative to this path.
    4. Update the Makefile's CROSS_COMPILE to use the NDK toolchain. Mine ended up looking like this: /home/aou/android/NDK/android-ndk-r10e/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android- (to match my NDK path above - note I couldn't use the relative ~ path for /home/aou).
    5. make exynos7420-zerolte_defconfig (ignore warnings about 'jump')
    6. make -j# (replace # with number of CPU cores + 1)
    7. Note the location of the output kernel - you'll need it in a little bit. In my case, it would be ~/android/kernel/arch/arm64/boot/Image.
    8. Setup your Omnirom compile environment. Mine's in ~/android/omni. The next several steps are performed in & relative to this path.
    9. Git clone the TWRP zeroltetmo device source into device/samsung/zeroltetmo:
      rm -rf device/samsung/zeroltetmo && git clone https://github.com/TeamWin/android_device_samsung_zeroltetmo.git -b android-5.1 device/samsung/zeroltetmo
    10. For some reason, TWRP doesn't build too well with the Omnirom's version of busybox. Replace the whole external/busybox folder with that from cm-12.1 source:
      rm -rf external/busybox && git clone https://github.com/CyanogenMod/android_external_busybox.git -b cm-12.1 external/busybox
    11. Remember that kernel we built? Rename/copy it to replace device/samsung/zeroltetmo/kernAl. In my case:
      cp ~/android/kernel/arch/arm64/boot/Image device/samsung/zeroltetmo/kernAl
    12. At this time (7/10/15), we need to cherry-pick a change by Dees Troy from the TWRP Gerrit. This is the stuff about forcing Read-Only mode on first boot, which will help with some of the boot-loop stuff (if you still have a stock kernel). You can grab the changes fairly easily using:
      cd bootable/recovery && git fetch https://gerrit.omnirom.org/android_bootable_recovery refs/changes/15/14015/3 && git cherry-pick FETCH_HEAD && cd ../..
    13. Since we're using Omnirom source and we're going to use lunch later, we need to create device/samsung/zeroltetmo/vendorsetup.sh. We can do that like this:
      echo add_lunch_combo omni_zeroltetmo-eng > device/samsung/zeroltetmo/vendorsetup.sh
    14. Do a . build/envsetup.sh (note the space between the period and "build" - was important for my environment).
    15. lunch for omni_zeroltetmo-eng
    16. make -j# recoveryimage (again, number of CPU cores +1)
    17. Take that precious out/target/product/zeroltetmo/recovery.img and tarball/md5sum it to be Odin flashable.
    18. Flash away!

    Notes about accidentally causing a boot-loop:
    The OF6/OF8/OH6 kernel, out-of-the-box, checks the hash/signature of your system partition. Modifying your system partition in any way (without flashing a custom kernel that does not perform this check) will cause your device to boot-loop.
    Additionally, if you decide to use TWRP to mount your System partition read-write (despite warnings), upon exiting TWRP properly, it will make some changes to your system partition for you (namely, renames /system/recovery-from-boot.p to /system/recovery-from-boot.bak to prevent some systems from re-writing over your custom recovery). This would cause the boot-loop.
    You obviously have some options to avoid causing a bootloop!
    Option 1a: Flash my v4 kernel above. It does not have the hash/signature checks, plus it sets SELinux to permissive (allowing root!). You'll still need to root the device manually by flashing Chainfire's SuperSU.
    Option 1b: Flash a different custom kernel that does not have these checks. The S6 UniKernel seems to work fine, for example.
    Option 2: Don't modify your System partition, and don't let TWRP exit properly while you have the "read-only" checkbox unchecked (in the Mount screen).


    Recovering from a boot-loop:
    Something go wrong? Skip a step? No big deal. To get our device back in working order, you have a couple options:
    Option 1: Flash the official OH6 firmware via Odin again. In my experience, the package DOES NOT wipe your data or sdcard partitions, so it really isn't that big of a deal to do. It just takes downloading a monster-size file, and the foreknowledge on how to flash it. But, caveat, don't blame me if something goes wrong with restoring the stock firmware!
    Option 2: See Options 1a & 1b in the first list above. By flashing a custom kernel that doesn't have the hash/signature checks included, it should fix the boot-loop.

    More Notes:
    Huge thanks to @bigbiff for reading through prior versions of this post and updating the TWRP source code to work without device without the need of heavy modification. Additional thanks to @_that for his invaluable help in this project.
    6
    Another quick update:

    I narrowed down what's causing the bootloop, or at least part of it. In the OF6 kernel, fstab.samsungexynos7420 and fstab.samsungexynos7420.fwup mount /system with some extra flags: support_scfs,verify

    By removing the verify flag, the device gets past the first bootloop. However, unfortunately, it has some sort of panic or something, and it reboots later in the boot process. It vibrates several time, sticks on the T-Mobile screen, and then eventually reboots. I'm trying to retrieve some sort of log, but I'm having difficulty. Perhaps I should just upload this version, have someone try it, and they can tell me what's going wrong? :p

    Edit: Oh! I remember this behavior! This is what happened when we tried flashing SuperSU 2.49 on the leaked 5.1.1 rom ... I think I have some ideas!

    Edit2: Yeah, it was the root. I went back to stock, flashed TWRP and flashed my v2 kernel (without the verify flag) and it's booting just fine - even after booting TWRP and exiting correctly.

    Now, it's just a matter of building a kernel that allows root...
    6
    Thanks for your efforts guys. I am trying to build a device tree for Aou and once the build works I will make a twrp page on our site using this thread as the maintenance page.

    I would be grateful if you guys could test http://build.twrp.me/twrp/twrp-2.8.7.1-zerolte.img.tar to see if it boots and works OK on this device.

    I might have to update the prop file for zeroltetmo if you guys want to do that.
    5
    Thanks for your efforts guys. I am trying to build a device tree for Aou and once the build works I will make a twrp page on our site using this thread as the maintenance page.

    I would be grateful if you guys could test http://build.twrp.me/twrp/twrp-2.8.7.1-zerolte.img.tar to see if it boots and works OK on this device.

    I might have to update the prop file for zeroltetmo if you guys want to do that.

    D'oh! I have a private message hanging in my mailbox. Sorry, @bigbiff. I just flashed it, and it hangs at the boot logo. I'll try to replace the kernel inside with my v4 kernel and see if that lets it boot.

    Edit: Yes, replacing the kernel inside indeed let the device boot into recovery. I'll send you a PM with the details.
    5
    Forgot to mention that ADB is working well with the new source. Thanks again!

    Once all testing is done I will push the build out to dl.twrp.me. Are you OK with being the maintainer for this thread?

    Please test http://build.twrp.me/twrp/twrp-2.8.7.1-zerolte.img.tar

    I added the ability to backup system as emmc instead of tar so that you will not change lifetime writes.