[OFFICIAL&TESTS]TWRP for the Motorola Moto X4 (Payton)

Search This thread

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
TWRP-Feature-Image-810x298_c.png
Code:
#include <std_disclaimer.h>
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about doing this to your device
* YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/

Introduction:

Team Win Recovery Project or TWRP for short, is a custom recovery built with ease of use and customization in mind. We started from the ground up by taking AOSP recovery and loading it with the standard recovery options, then added a lot of our own features. It's a fully touch-driven user interface, with no more volume rocker or power buttons to mash. The GUI is also fully XML-driven and completely theme-able. You can change just about every aspect of the look and feel.

Key Features:

Touchscreen driven with real buttons and drag-to-scroll
XML-based GUI that allows full customization of the layout true theming!
Settings are saved to the sdcard and persist through reboots
Ability to choose which partitions to back up and which to restore
Ability to choose to compress backups now with pigz (multi-core processor support for faster compression times)
Onscreen keyboard
Easy selection of internal/external storage

In addition to the above new features, TWRP features a scripting engine that allows an app to send commands to the recovery for the recovery to perform during startup. We call this scripting engine OpenRecoveryScript. This engine will be put to use immediately in the GooManager app. GooManager will be able to install recoveries automatically for most supported devices. The app will also let you choose to install multiple zips from within Android, wipe, and run a backup.

We are looking for other talented developers, themers, and device maintainers if they are interested in helping with a free, open-source project.

Source Code:

GitHub - https://github.com/TeamWin/android_bootable_recovery

Gerrit Instance - http://gerrit.twrp.me

If you have made your own TWRP build for an unsupported device, please let us know. We might add your build to the list of unofficial builds. Bear in mind that we are working hard to add more devices and we may add your device to our official build list later.

Pease note! TWRP cannot currently decrypt any A12 ROM on any device. This is a known issue as AOSP changed the way encryption keys are stored. If a new workaround isn't found? TWRP may never decrypt again... We recommend removing lockscreen security, rebooting to TWRP, make your changes and then reboot to system and setup your lockscreen security again.

This is for OFFICIAL and BETA builds of TWRP for the Motorola Moto X4 (payton)



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

Test Downloads:
https://osdn.net/projects/twrp-for-payton/releases/

Sources:
Official: https://github.com/TeamWin/android_device_motorola_payton
Tests: https://github.com/ThEMarD/android_device_motorola_payton-twrp

Platform Tools (adb/fastboot):
https://developer.android.com/studio/releases/platform-tools.html#download

Installation:
  1. Make sure your bootloader is unlocked
  2. Download the recovery image (and optionally the TWRP installer zip) from above
  3. Reboot into bootloader
  4. Run this command (Change the .img to whatever the name of file is you downloaded):
    Code:
    fastboot boot twrp-3.4.0-1-payton.img
  5. Optionally at this point, if you want TWRP to be your default recovery? You can install TWRP via the TWRP installer zip. Please note that ROM upgrades overwrite boot which in turn overwrites recovery so this process would need to be repated.

Upgrade instructions
  1. Download desired TWRP installer zip version
  2. Reboot to recovery
  3. Select Install
  4. Tap on install and select the TWRP installer zip you downloaded from step one
  5. Reboot to recovery and confirm that the updated version of TWRP is installed

Nandroid backup/restore
  1. Have an available microSD Card or USB OTG drive
  2. Backup boot, dtbo, system image, vendor image and data (optionally any other partitions you want a backup of) to your external storage device of choice
  3. Once you wish to restore? Reboot to TWRP and format data (Wipe > "format data" button > type yes > keyboard checkbox)
  4. Reboot to TWRP
  5. Restore boot, dtbo, system image and vendor image
  6. Reboot to system
  7. Once it boots to system without issues? Do not set any lockscreen security and reboot to TWRP
  8. Restore data
  9. Reboot to system
  10. After it finishes boot? Your data and ROM will be restore but sometimes the UI might be incorrect, so reboot to system again

For the TEST builds of TWRP? Please let me know if this works. If so? I will submit it to Gerrit for official updates.

Credits:
  • bigbiff for helping me get setup on on gerrit.twrp.me for official status and updating official TWRP
  • kaneawk, erfanoabdi for working on TWRP for payton
  • All the users who tested my builds of TWRP
  • ok I could literally be here all day typing so essentially anyone who has worked on the Motorola sdm660-common kernel for LineageOS and TWRP
 
Last edited:
  • Like
Reactions: Organics

aIecxs

Senior Member
Feb 17, 2016
1,642
464
gitlab.com

i have seen you are trying to fix encryption in recovery.fstab - please note the file is overwritten from twrp.fstab during runtime, so either remove twrp.fstab or do the changes in there

for working encryption the flags should be written completely, afaik there is no autocomplete in twrp (like in android)
fileencryption=ice:aes-256-cts

---

furthermore i recommend /system_root instead of /system to keep things in line with other devices (although most flashable zips meanwhile can detect SAR)

to avoid `mount /system` (perhaps silently) fail instead of symlink i recommend bind mount (not standard so far, at least haven't seen that in official builds)

Code:
/system_root  ext4  /dev/block/bootdevice/by-name/system  flags=display="System Root";backup=1;wipeingui;slotselect
/system       auto  /system_root/system                   flags=fsflags="bind";backup=0;usermrf;ignoreblkid

---

another change what seems official now and (in request of user @lowerhater) you may include /data/media/0 aka Internal Storage for backup purposes (decision is up to you, external storage is required for backup location)

Code:
/storage  auto  /sdcard  flags=fsflags="bind";display="Internal Storage";backup=1;usermrf;ignoreblkid
 
Last edited:

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
Heyyo @aIecxs , thanks for the suggestions! For the fstab change before erfan was saying that's optional as mentioning ice was the only important part, but I can definitely put the full description in for payton. FBE decryption on payton is fixed already as I used the same commits that I did to fix it on nash since sdm660 and msm8998 are the exact same CAF tags.

For the /system_root thing? Afaik that was for devices with A-only SAR that use the pie SAR implementation as it doesn't look like beyond1lte is an A/B device like Motorola sdm660 devices are. berkeley would be another example of A-only SAR device using pie's SAR implementation, but sadly though it seems they haven't had TWRP updates since 2019... Tbh I don't really know any other devices like that offhand...

As for that last suggestion? Yes we can implement that too. (y)
 
Last edited:
  • Like
Reactions: aIecxs

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
Heyyo @DARK EMP3ROR , unfortunately it seems Motorola devices are super picky... For me? It wouldn't work on my Windows 10 PC or Ubuntu Mate 20.04 either... My wife's old Windows 7 notebook it worked fine though, so you might need to setup a USB Live Boot for Windows 7 or something to get it going
 
  • Like
Reactions: DARK EMP3ROR

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
Heyyo, I have TWRP 3.6.1_11 test10 build up. It's rebased on TWRP-11 branch with source-built bootctrl HAL and libgptutils.

Please note! This will decrypt Android 11 ROMs, but can't decrypt Android 12.x ROMs unless you remove your lockscreen security first within the ROM before rebooting to TWRP. Currently TWRP does not have a method to decrypt A 12.x ROMs so this isn't a bug specific to payton. :(

 
Last edited:
  • Like
Reactions: arya_23 and aIecxs

jtnc

Member
Dec 4, 2012
35
14
Your test 3.6.1_11 test 10 build with lineageOS 19.1 does boot when I use 'fastboot boot <file>', but it cannot unencrypt the drive like 3.5.0_9 was doing on lineageOS 18.1. this is the same behavior I see with the default 3.6.0_9.img file from twrp.me for Payton. All the 3.5.x versions of twrp get stuck booting and I never get far enough to enter a pin. I can't compare against the lineage recovery from the 19.1 test build, as whenever I try a fastboot of that img file, it just boots lineageOS rather than recovery, which seems weird given it works for twrp.
 

Dukenukemx

Senior Member
Jul 24, 2008
1,115
50
Jersey

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
Heyyo @jtnc , the twrp.img file is only meant for temporary use (fastboot boot) and then install the twrp-installer.zip to install TWRP to both slots. Please check the installation instructions. Installing the twrp.img will overwrite your kernel which will break the installed ROM.

It didn't decrypt LOS 18.1 for you? That's odd, other users confirmed it did.

@Dukenukemx I confirmed on my payton it works. As I mentioned, the problem before with TWRP builds was the prebuilt bootctrl HAL and libgptutils.

Here is the latest pre-official TWRP test builds from their build server.

TWRP image:

TWRP installer zip:

Please test these. If they are confirmed as working? I will ask for a new official TWRP build for payton.
 

jtnc

Member
Dec 4, 2012
35
14
I understand the .img file is only for temporary use (fastboot) and that was all I was using it for. I could fastboot with the twrp 6.1 test10 image fine, but it would not decrypt. As such I did not bother installing it and stayed on 3.5.0_9. I did eventually realize my sdcard was not encrypted (d'uh!) and was able to flash the lineage recovery w/o a problem. I can't see the bulitin storage with lineage, so I'm assuming it's not decrypting either (nor did it prompt).

Using fastboot boot (so .img files for all), I saw:
twrp < 3.6 -- hangs on the twrp boot screen
twrp 3.6 -- fails to decrypt, but boots fine otherwise
lineeageOS recovery (any) -- boots to OS not to recovery when running 'fastboot boot lineage....recovery.img

I will try the official build you just posted later today when I can get back to my old laptop.
 

jtnc

Member
Dec 4, 2012
35
14
I just tried out the 3.6.1_11-0-payton.zip version of twrp on the official build server you pointed me at. It had the same results as with your test build, namely it does not decrypt internal storage for me. Probably worth someone else validating - assuming others are encrypted.

Since all the 3.5 series hang for me, I tried rolling back to an older version that used to work with encryption, namely a 3.3.3_1 version by Syberhexen, but it too failed decryption. I haven't looked at how encryption works, but it makes me wonder if something changed in 19.1 related to it.

18.1 encrypted worked fine with 3.5.0_9. I can't recall if I was running 3.5.0_9 or the 3.3.3_1 syperhexen version with 17.1/HavocOS.

Depending on how time goes this weekend, I might try rolling back to 18.1 and see if your build will decrypt that or not.
 

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
@jtnc, just to check, are you using FBE and not FDE for encryption methods? I just formatted the data on my payton and wiped dalvik and flashed LOS 18.1 and tested both via fastboot boot twrp-3.6.1_11-0-payton.img and adb sideload twrp-installer-3.6.1_11-0-payton.zip and both booted fine and I could PIN decrypt my LOS 18.1 ROM

Screenshot_2022-04-23-01-42-41.png

Screenshot_2022-04-23-01-42-44.png


It does take a minute or three to boot into TWRP, so I do recommend giving it a bit of time for decryption to work.

As I mentioned above though, TWRP cannot currently decrypt A12.x ROMs, so users MUST remove lockscreen security in the ROM before rebooting to TWRP.
 

woodpe

Member
Jan 2, 2022
5
3
Will there some time be a chance to decrypt A12 ROMs with lockscreen security by TWRP?
Thanks for an answer.
 

ThE_MarD

Recognized Developer
Dec 10, 2014
3,199
3,681
Grande Prairie
LeEco Le Max 2
Moto X4
Heyyo @woodpe, from my understanding? Android 12.1 changes the way security key storage works, so the path that TWRP usually uses for decryption does not exist... so unless a new solution is found? Potentially TWRP might never decrypt lock screen security ever again...
 

woodpe

Member
Jan 2, 2022
5
3
I'm using lineageos19.1 in combination with the pre-offical TWRP.
All works fine, but no decryption.
 

jtnc

Member
Dec 4, 2012
35
14
Heyyo @woodpe, from my understanding? Android 12.1 changes the way security key storage works, so the path that TWRP usually uses for decryption does not exist... so unless a new solution is found? Potentially TWRP might never decrypt lock screen security ever again...

I think this is the problem I've been seeing then. I think I was hoping your test build fixed that problem! All my decryption issues with TWRP have occurred after moving to LineageOS 19.1. I did not have a chance to roll back to 18.1 and revalidate the 3.6.1 build you posted over the weekend, but given the above comment and your experiment on 18.1 I'd expect it to work fine for me.

Removing the lock screen pin and rebooting to recovery worked fine with 19.1 and TWRP 3.6.1_11, I have not tried it on TWRP 3.5.0_9. It's a bit annoying that you have to redo fingerprints every time you remove the lock screen security (at least for PIN, I assume that's true for any).

But given that TWRP 3.6.1 is not expected to work well PIN and 19.1, I'd say go ahead and make 3.6.1_11 official. The only thing I haven't tried is a complete ROM install but I was able to flash recover and other zips from it fine.

Question, would it be worth adding a note to maybe the second post of the lineageOS 19.1 thread indicating TWRP + 19.1 + lockscreen PIN does not currently work?
 
Last edited:

Top Liked Posts

  • 2
    Short answers:
    1: It's not necessary to reinstall GAPPS if you use the built-in updater.
    2: Yes
    1
    @ThE_MarD, @wkn000, @jtnc - Thanks guys!
    Updating TWRP using ADB was easy, but it's mandatory to lose fingerprints, since you have to set your "login security" to "none".
    Ok, I was able to upgrade to latest L.OS - but then I got problems with some Google Apps (Gmail, Play store were not opening anymore). So I decided to format my device (using TWRP to do that), reboot to recovery - got into L.OS Recovery and used that to reinstall.
    It works great! Was able to install L.OS and reboot to recovery to install GAPPS without problems.

    But now I have another questions (probably my last two haha):
    1 Am I obliged to reboot to recovery in order to reinstall GAPPs every time LOS updates???
    2 Will I be able to use LOS Recovery without setting my login security options to "none"??


    Thanks in advance!
  • 2
    My way is to have Lineage Recovery installed permanent and boot only temporary to TWRP, when i really "needed" or feel more "comfortable" doing something with it.
    2
    Lineage Recovery is installed automatically with Lineage OS. Just reboot to recovery from the phone. Also used during OTA updates from System / Updater. At the moment it has less functionality compared with TWRP, but all in what normally needed.

    Temporary TWRP is accessed by "adb reboot bootloader" and "fastboot boot twrp-xxx.img".
    2
    Short answers:
    1: It's not necessary to reinstall GAPPS if you use the built-in updater.
    2: Yes
    1
    LOS19 is great! But I tried to go to recovery mode and got stuck on splash screen.
    Is there any solution to that? Tks!!!!
    You will need to install the latest TWRP (3.6.1_11). Since you're stuck booting into TWRP, it will need to be done via fastboot and then sideload. See the first post or the TWRP docs for detailed steps.
    1
    My way is to have Lineage Recovery installed permanent and boot only temporary to TWRP, when i really "needed" or feel more "comfortable" doing something with it.
    Hnnn!!! How do I get (or access) Lineage Recovery? I only use twrp to update LOS, if there's a "official" and permanent recovery, I can live without twrp easily...
    Tks in advance!
  • 2

    i have seen you are trying to fix encryption in recovery.fstab - please note the file is overwritten from twrp.fstab during runtime, so either remove twrp.fstab or do the changes in there

    for working encryption the flags should be written completely, afaik there is no autocomplete in twrp (like in android)
    fileencryption=ice:aes-256-cts

    ---

    furthermore i recommend /system_root instead of /system to keep things in line with other devices (although most flashable zips meanwhile can detect SAR)

    to avoid `mount /system` (perhaps silently) fail instead of symlink i recommend bind mount (not standard so far, at least haven't seen that in official builds)

    Code:
    /system_root  ext4  /dev/block/bootdevice/by-name/system  flags=display="System Root";backup=1;wipeingui;slotselect
    /system       auto  /system_root/system                   flags=fsflags="bind";backup=0;usermrf;ignoreblkid

    ---

    another change what seems official now and (in request of user @lowerhater) you may include /data/media/0 aka Internal Storage for backup purposes (decision is up to you, external storage is required for backup location)

    Code:
    /storage  auto  /sdcard  flags=fsflags="bind";display="Internal Storage";backup=1;usermrf;ignoreblkid
    2
    Lineage Recovery is installed automatically with Lineage OS. Just reboot to recovery from the phone. Also used during OTA updates from System / Updater. At the moment it has less functionality compared with TWRP, but all in what normally needed.

    Temporary TWRP is accessed by "adb reboot bootloader" and "fastboot boot twrp-xxx.img".
    2
    Short answers:
    1: It's not necessary to reinstall GAPPS if you use the built-in updater.
    2: Yes
    2
    Heyyo, I have TWRP 3.6.1_11 test10 build up. It's rebased on TWRP-11 branch with source-built bootctrl HAL and libgptutils.

    Please note! This will decrypt Android 11 ROMs, but can't decrypt Android 12.x ROMs unless you remove your lockscreen security first within the ROM before rebooting to TWRP. Currently TWRP does not have a method to decrypt A 12.x ROMs so this isn't a bug specific to payton. :(

    2
    My way is to have Lineage Recovery installed permanent and boot only temporary to TWRP, when i really "needed" or feel more "comfortable" doing something with it.