[RECOVERY][UNOFFICIAL][TWRP 3.2.1][MOTO x4 PAYTON][7.1.1/8.0]

Search This thread

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
OFFICAL TWRP RELEASED, this thread is no longer active. 3-30-2018

https://twrp.me/motorola/motorolamotox4.html


---



UNOFFICIAL BUILDS -- USE AT YOUR OWN RISK AND KNOW HOW TO GET YOURSELF OUT OF TROUBLE IF IT ARISES. I ASSUME NO RESPONSIBILITY FOR YOUR BROKEN THINGS. :)

UPDATED 01-11-2018
There are now 7.1 based and 8.0 based builds. Obviously, be careful to select the proper download. While I don't think flashing/booting the wrong one would permanently brick the device, let's not find out :)

For now I will not be attempting to make data decryption work. It is REQUIRED that you unencrypt your device by formatting userdata, so back up your stuff first.


IMPORTANT NOTES: TWRP for OREO is a bit of a pain as it currently requires manually editing your fstab. I have tried to automate this process, but it breaks stuff. So just be aware before you begin that it is a rather time consuming process.

If you make any change to your boot partition after flashing SuperSU, you will need to reflash it or you will get a bootloop.

8.0 OREO TWRP INSTALLATION:
OREO SEEMS VERY FINICKY AND DOES NOT LIKE CHANGES TO ITS FILESYSTEM -- BE PREPARED TO REFLASH STOCK.

0. FLASH OREO FACTORY IMAGE (may work otherwise, but we should be starting from fresh stock here)
1. Download FASTBOOT BOOTABLE TWRP for 8.0/OREO below
2. Download SuperSU 2.82 SR5 below
3. Move SuperSU to external SD or USB OTG
4. From bootloader, fasboot BOOT TWRP
5. Flash SuperSU (note: do not format /data now... not necessary and will cause errors on boot)
6. Reboot system
7. With any root file editor/text editor (Amaze, Total Commander, etc) open /system/vendor/etc/fstab.qcom as a text file for editing.
8. At the end of the /data partition entry, delete "fileencryption=ice" and replace it with "encryptable=footer".
9. Save fstab.qcom (and make sure it is actually saved properly!)
10. Reboot to bootloader and fasboot BOOT TWRP
11. Go to Wipe, hit the FORMAT DATA button, and type "yes" to format /data. This will erase your data, obviously:silly:
12. Reboot system (should now be unencrypted, verify in Settings>Security or by booting TWRP and checking /data with File Manager.

If you later choose to flash TWRP (not the bootable we used here!), you may need to flash SuperSU again to avoid bootloops.



7.1.1 NOUGAT TWRP INSTALLATION:
1. Download current TWRP for 7.1.1 build below
2. Download SuperSU 2.85 SR5 (https://forum.xda-developers.com/apps/supersu/2014-09-02-supersu-v2-05-t2868133

3. Move SuperSU to your external Micro SD card.
4. Fastboot flash the TWRP image.
5. Reboot to TWRP.
6. FORMAT data (not wipe...use the "FORMAT DATA" button and type "yes". OBVIOUSLY THIS WILL ERASE YOUR DATA)
7. Install SuperSU 2.85 SR5
8. Reboot to system (it WILL bootloop a couple times...don't panic!) and confirm that device is unencrypted by checking that SETTINGS>SECURITY>ENCRYPTION now prompts "encrypt" (don't do it).


DOWNLOADS:
TWRP FOR 7.1.1 (Nougat) DOWNLOAD: https://drive.google.com/open?id=1Et-AQgCNx7WDAwzihlI51euUa2ixKHEP

TWRP FOR 8.0 (Oreo) DOWNLOAD: https://drive.google.com/open?id=1WcVS_3rloF7jxPulj_jKxfsp3zy5pB5N

FASTBOOT BOOTABLE TWRP IMAGE (OREO BASED): https://drive.google.com/open?id=12ClviqtEjtflB63UQ1CZQNKEqkprBO0u **For temporary TWRP boot using "fastboot boot". Do not flash or you will be stuck in recovery!**


DEVICE TREE: https://github.com/mightysween/android_device_motorola_payton (NEEDS TO BE UPDATED WITH OREO BRANCH)

changelog:
BETA4
-reverted to 3.2.0 for current build (release candidate rebased to 3.2.1).
-fixed "format data" button
-finalized fstab for OTG/SD/INTERNAL mounting
-target is now UNENCRYPTED devices only (/data decrypt will not be fixed)

BETA3
-Rebased to TWRP 3.2.1
-USB OTG working
-all partitions mounting correctly
-considered working except for decrypt and MTP/ADB

BETA2
-fixed internal storage mount

BETA1
- updated source to TWRP 3.2.0

ALPHA3
- Fixed USB mounting (adb/mtp still nonfunctional) BROKEN IN BETA1

ALPHA2
- SD Card fixed

ALPHA1
- /system is now properly mounted.
- now plays nice with our working root method.
- ramdisk is patched to prevent first boot encryption once /data is decrypted (now requires flashable ZIP)


NOT WORKING:
adb/mtp/sideload
/data decryption (abandoned -- /data access requires unencryption)

CREDITS: @kraatus90 for kernel fix, @Chainfire for SuperSU, @jcadduono for no-verity-opt-encrypt scripts.



---
 
Last edited:

bombaglad

Senior Member
Dec 14, 2014
356
140
25
Bratislava
hi,
you said this is really unstable and could brick the device easily. however, you seem to be testing and experimenting with your device a lot, so i'd like to ask if you have any particual unbrick method that you use when something goes wrong.. like, a via fastboot flashable image or something simmilar...?
thanks for your work!
 

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
I am not going to provide step by step "unbrick" methods, because until the partitioning is properly set up, TWRP has potential access to things that can not be fixed.

Again, this is still highly experimental.

All that said, my entire process to protect any device remains the same: Have a backup for every partition you will be testing, make as few changes as possible at a time, test boot images before flashing (fastboot boot), and test restore methods frequently (flashing back to stock or backups), and don't do anything unless you are highly certain of the outcome.

By those standards, there is nothing to gain by installing TWRP right now, as its basic function (install/backup/restore) is not set up yet.
 

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
Found the BoardConfig flag to enable FBE (TW_INCLUDE_CRYPTO_FBE := true) but do not have the lib it is dependent on (libe4crypt) and I don't see it anywhere yet...

For reference (not sure this is most current, but it demonstrates the process)
https://github.com/nijel8/TWRP/commit/bd7492de28963b7e74e8e5d3f17ec9a5a287d9c3

I have confirmed that FBE support is present in the source, dependent on this missing module... so need to figure out where/how to enable it.

It is possible that this entire process is specific to only certain devices (i.e. Pixel, Nexus). If this is the case, we may be stuck at this point for awhile.

Obvious workaround is to not be encrypted to begin with -- but that isn't a "solution".
 
Last edited:
  • Like
Reactions: f3r.and0

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
It is possible that this entire process is specific to only certain devices (i.e. Pixel, Nexus). If this is the case, we may be stuck at this point for awhile.

This appears to be the case, unfortunately. Seems that the TWRP FBE support was built specifically for the Google implementation of FBE which was merged into kernel sources for Nexus and Pixel. Not even using the qseecomd I assumed it was... will remove on next build.

Info on FBE:
https://source.android.com/security/encryption/file-based
 
Last edited:
  • Like
Reactions: f3r.and0

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
Making good progress this morning.

Seem to have a build with properly decrypted /system, and working SD Card. I also have patched the boot.img to disable forced encryption on the first boot. But now, I can not find a safe way to fully format (not "wipe") the /data partition. As mentioned in the previous post, the "FORMAT DATA" button is missing. The fastboot command "fastboot format userdata" returns an error that it does not support RAW format.

Need to figure out why this is happening... and once I do, I believe I can reformat /data without encryption and then will have an almost fully working TWRP build. Obviously, the ideal solution would be to have TWRP work out of the gate with an encrypted /data, but until then this is going to be our best option.

Will post an updated test build in the OP soon.... needs further testing before I would recommend non-expert users to try it.

Getting very close now! :)

UPDATE: ADDED NEW BUILD TO OP
---

Also, just occurred to me that the ramdisk will need to be patched every time, so now that I have SD card support will be testing some of the existing flashable ZIPs out there that are designed specificially to prevent first-boot encryption and/or disable dm-verity.

---
 
Last edited:

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
Hey, where did the big "format data" button go in TWRP? Is that optional on compile... can't find a flag for it...

This is really the only hold up... I changed the partition from 'Advanced Wipe", but as expected, it was still encrypted on boot as it doesn't actually format the footer where encryption is stored. I can't figure out where that darn "FORMAT DATA" button ran off to, and that is exactly what we need here.
 

johnjingle

Senior Member
Jun 25, 2010
335
86
This is really the only hold up... I changed the partition from 'Advanced Wipe", but as expected, it was still encrypted on boot as it doesn't actually format the footer where encryption is stored. I can't figure out where that darn "FORMAT DATA" button ran off to, and that is exactly what we need here.

I don't know how to help except to say that using TWRP 3.1.0-MOD_1 with my XT1254 (DROID Turbo), when you go to wipe it has two buttons --- one on the left for Advanced Wipe and Format Data on the right.
 

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
I don't know how to help except to say that using TWRP 3.1.0-MOD_1 with my XT1254 (DROID Turbo), when you go to wipe it has two buttons --- one on the left for Advanced Wipe and Format Data on the right.

I have 3.1.1-0 (same version I am building here) on several other devices, and the button is there. It has to be triggered by something during compile, but I can't figure it out. Driving me nuts :)

Looking through TWRP source, and can find actions for every other button (wipe, backup, restore, install, etc) but not for format. Hmm.

I posted over on an old but semi-active TWRP flags thread, maybe someone will have some insight.
 
Last edited:

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
Wondering if I make a stock boot image without the encryption tag in fstab, and then wipe data and reboot... then flash my image. That may make it so the data partition is never encrypted in the first place and allow TWRP to work.

But that is an ugly, non-user friendly fix. Why can't we just format /data?

---

Final update for today... this seems to be a compile issue, which is a good thing. I tried to manually decrypt /data from the TWRP command line, and got this:

No crypto support was compiled into this build.

So, I must be missing something in boardconfig still... and maybe need to set up a small proprietary vendor folder with the necessary libs
 
Last edited:
Dec 15, 2011
16
1
Final update for today... this seems to be a compile issue, which is a good thing. I tried to manually decrypt /data from the TWRP command line, and got this:



So, I must be missing something in boardconfig still... and maybe need to set up a small proprietary vendor folder with the necessary libs

Thanks for doing all of this! I wish I had the time and knowledge to help.
 

mightysween

Senior Member
Feb 18, 2011
1,562
1,293
Maine/USA
Moto G Stylus
Had a few PM's checking on TWRP status, so an update.

The good news is that the X4 is using Qualcomm based decryption for /data... the bad news is that most if it seems to be closed source. This will take some time for me to figure out, but I have already made some progress by sifting through logs.

Right now, I am trying to find a device with similar decrypt scheme to have some more guidance on the process.
 

vivek638

Senior Member
Aug 19, 2013
143
24
Had a few PM's checking on TWRP status, so an update.

The good news is that the X4 is using Qualcomm based decryption for /data... the bad news is that most if it seems to be closed source. This will take some time for me to figure out, but I have already made some progress by sifting through logs.

Right now, I am trying to find a device with similar decrypt scheme to have some more guidance on the process.
dont know all about these things but maybe xiaomi mi a1 twrp can help as it is also using same a/b partition. and twrp is already there for it
 

Buob

New member
Dec 4, 2013
2
0
I'm not much of a programmer, but I can look through the files. Is there anything in particular we're searching for?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 33
    OFFICAL TWRP RELEASED, this thread is no longer active. 3-30-2018

    https://twrp.me/motorola/motorolamotox4.html


    ---



    UNOFFICIAL BUILDS -- USE AT YOUR OWN RISK AND KNOW HOW TO GET YOURSELF OUT OF TROUBLE IF IT ARISES. I ASSUME NO RESPONSIBILITY FOR YOUR BROKEN THINGS. :)

    UPDATED 01-11-2018
    There are now 7.1 based and 8.0 based builds. Obviously, be careful to select the proper download. While I don't think flashing/booting the wrong one would permanently brick the device, let's not find out :)

    For now I will not be attempting to make data decryption work. It is REQUIRED that you unencrypt your device by formatting userdata, so back up your stuff first.


    IMPORTANT NOTES: TWRP for OREO is a bit of a pain as it currently requires manually editing your fstab. I have tried to automate this process, but it breaks stuff. So just be aware before you begin that it is a rather time consuming process.

    If you make any change to your boot partition after flashing SuperSU, you will need to reflash it or you will get a bootloop.

    8.0 OREO TWRP INSTALLATION:
    OREO SEEMS VERY FINICKY AND DOES NOT LIKE CHANGES TO ITS FILESYSTEM -- BE PREPARED TO REFLASH STOCK.

    0. FLASH OREO FACTORY IMAGE (may work otherwise, but we should be starting from fresh stock here)
    1. Download FASTBOOT BOOTABLE TWRP for 8.0/OREO below
    2. Download SuperSU 2.82 SR5 below
    3. Move SuperSU to external SD or USB OTG
    4. From bootloader, fasboot BOOT TWRP
    5. Flash SuperSU (note: do not format /data now... not necessary and will cause errors on boot)
    6. Reboot system
    7. With any root file editor/text editor (Amaze, Total Commander, etc) open /system/vendor/etc/fstab.qcom as a text file for editing.
    8. At the end of the /data partition entry, delete "fileencryption=ice" and replace it with "encryptable=footer".
    9. Save fstab.qcom (and make sure it is actually saved properly!)
    10. Reboot to bootloader and fasboot BOOT TWRP
    11. Go to Wipe, hit the FORMAT DATA button, and type "yes" to format /data. This will erase your data, obviously:silly:
    12. Reboot system (should now be unencrypted, verify in Settings>Security or by booting TWRP and checking /data with File Manager.

    If you later choose to flash TWRP (not the bootable we used here!), you may need to flash SuperSU again to avoid bootloops.



    7.1.1 NOUGAT TWRP INSTALLATION:
    1. Download current TWRP for 7.1.1 build below
    2. Download SuperSU 2.85 SR5 (https://forum.xda-developers.com/apps/supersu/2014-09-02-supersu-v2-05-t2868133

    3. Move SuperSU to your external Micro SD card.
    4. Fastboot flash the TWRP image.
    5. Reboot to TWRP.
    6. FORMAT data (not wipe...use the "FORMAT DATA" button and type "yes". OBVIOUSLY THIS WILL ERASE YOUR DATA)
    7. Install SuperSU 2.85 SR5
    8. Reboot to system (it WILL bootloop a couple times...don't panic!) and confirm that device is unencrypted by checking that SETTINGS>SECURITY>ENCRYPTION now prompts "encrypt" (don't do it).


    DOWNLOADS:
    TWRP FOR 7.1.1 (Nougat) DOWNLOAD: https://drive.google.com/open?id=1Et-AQgCNx7WDAwzihlI51euUa2ixKHEP

    TWRP FOR 8.0 (Oreo) DOWNLOAD: https://drive.google.com/open?id=1WcVS_3rloF7jxPulj_jKxfsp3zy5pB5N

    FASTBOOT BOOTABLE TWRP IMAGE (OREO BASED): https://drive.google.com/open?id=12ClviqtEjtflB63UQ1CZQNKEqkprBO0u **For temporary TWRP boot using "fastboot boot". Do not flash or you will be stuck in recovery!**


    DEVICE TREE: https://github.com/mightysween/android_device_motorola_payton (NEEDS TO BE UPDATED WITH OREO BRANCH)

    changelog:
    BETA4
    -reverted to 3.2.0 for current build (release candidate rebased to 3.2.1).
    -fixed "format data" button
    -finalized fstab for OTG/SD/INTERNAL mounting
    -target is now UNENCRYPTED devices only (/data decrypt will not be fixed)

    BETA3
    -Rebased to TWRP 3.2.1
    -USB OTG working
    -all partitions mounting correctly
    -considered working except for decrypt and MTP/ADB

    BETA2
    -fixed internal storage mount

    BETA1
    - updated source to TWRP 3.2.0

    ALPHA3
    - Fixed USB mounting (adb/mtp still nonfunctional) BROKEN IN BETA1

    ALPHA2
    - SD Card fixed

    ALPHA1
    - /system is now properly mounted.
    - now plays nice with our working root method.
    - ramdisk is patched to prevent first boot encryption once /data is decrypted (now requires flashable ZIP)


    NOT WORKING:
    adb/mtp/sideload
    /data decryption (abandoned -- /data access requires unencryption)

    CREDITS: @kraatus90 for kernel fix, @Chainfire for SuperSU, @jcadduono for no-verity-opt-encrypt scripts.



    ---
    19
    Well, all attempts to make this work are still leading back to the exact same issue: /data decryption does not work. It is possible to format userdata and remove encryption, but it returns on the first boot of the system, and attempts to change fstab to prevent this have been unsuccessful. The only other SDM660 device with working TWRP is one that has a separate /recovery partition (lucky!).

    I have tried dozens, maybe hundreds of "fixes" with virtually zero change from the first day I booted TWRP on the X4. I am quite certain that the solution requires starting from 100% stock, booting a temporary recovery (fastboot BOOT), and using a ZIP installer to inject the recovery ramdisk. With that method apparently unavailable to us, we are simply stuck.

    I will be putting further work on TWRP on hold for now... not because I don't think it can be solved, but because I would rather work on other things that can help us solve this problem indirectly. For example, building out a Lineage based ROM with a custom kernel (maybe even the latter alone) will allow us to avoid the forced-encryption issue and at least have fully working TWRP for custom ROM uses.

    I will probably take one last look at what I have, clean up some stuff and push a final beta build. If a temporary-boot solution becomes available, I already have compiled a flashable ZIP file for our device.

    Going to shift now to using my limited spare time to build out the proprietary files and vendor tree. This is what we really need in order to jumpstart custom ROM development. I may also make a custom stock-based flashable ZIP (there is nothing stopping us from using TWRP to flash ROMS !)

    ---
    14
    I think moto x4 is not that popular rit now. But i can definitely say that its a best budget phone in sub 20k.. But nowadays only people are getting attention of 18:9 ratio phone. Whether it have something good inside or not.. Atleast in india i am not seeing any phone which comes close to this device with this much specs n ip68...

    I have two people from India helping me on development, which is great! Once TWRP is fully functional for all variants, we will see increased interest in this device. Went through this with the original Moto G 3-4 years ago... took us forever to get all unlockable variants built. But that old device has TWRP and bleeding edge custom Oreo support now. This device will be a great one to hold onto in the long run.

    Still struggling with the final stage of TWRP implementation... as are many other newer A/B devices. I feel like this is the week (though I have felt that way for a month) :)
    11
    Hi guys i built new TWRP, oreo and N with encryption
    img : https://androidfilehost.com/?fid=962187416754469184
    installer zip : https://androidfilehost.com/?fid=746010030569962775

    please try if everything worked i'll go for official

    ****** Don't swap slots if you don't have firmware on your slot B, this will brick the device and you have to use blankflash to unbrick

    Tree : https://github.com/erfanoabdi/android_device_motorola_payton
    11
    Not having much luck preventing forced encryption on first boot. Looking at some other devices that are taking this route, and the same fixes for those do not seem to apply to us.

    In other news I did get USB OTG working again in my latest build, and I have been in touch with a couple other people who are interested in both helping get TWRP decrypt fixed and working out the rest of the tree/blobs for building LineageOS.