yashsingh1/xdaforums huggingface dataset:
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] vivek638:
I think u should try with magisk also. As i was reading mi a1 thread for oreo twrp recovery and found that if supersu get flashed the wifi and camera get break. Maybe m wrong just giving u a suggestion...
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Device bootloops with Magisk 15.2 flashed either from TWRP or via fastboot on top of a TWRP-ifyed boot image.

If starting from stock Oreo boot image, I can flash the Magisk patched_boot.img and it does boot but has broken wifi just like the SuperSU method. Stuck for now.

UPDATE: Whatever is breaking wifi is not fixed by re-flashing the stock boot.img. Interesting, as other devices have reported the "fix" as flashing a standalone kernel. It seems that on the X4 once wifi is broken by a root method, the only fix is to reflash the entire system partition from stock firmware.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kraatus90:
wait even patched boot.img is breaking wifi ? that's weird. im using same method, and wifi is perfectly fine. although i'm on retail moto x4.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
On 8.0? I just flashed back to stock retail and am going to try again.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kraatus90:
yep
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
deleted duplicate
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
I see... need to boot all the way through the setup and then drop to bootloader and flash patched_boot.img. I was just flashing it on initial boot after flashing firmware.

Now... can I take the patched image and repack it with TWRP as the recovery, format data, and then reboot with working wifi??? Stand by :)
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Unbelievable... I repacked the patched-boot.img with the TWRP ramdisk and ended up with a file that BOOTS DIRECTLY TO TWRP. Exactly what I spent weeks trying to accomplish before. Geez. Guess I will hang onto that one.

Anyhow. I tried this: flash Magisk patched_boot.img and boot phone normally/flash TWRP/Format Data/flash Magisk patched_boot.img. When it reboots, the /data partition remains unencrypted but the system is unuseable with constant acore errors and force closes.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] vivek638:
I think its kernal issue.. if we have a custom kernal maybe we can fix that
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Unfortunately we have no source for Oreo.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Updated the OP with my "accidental" fastboot-bootable TWRP image. This opens up a whole new stream of possibilities for testing, so I am flashing back to stock and will try testing some solutions with a temporarily booted TWRP (rather than a modified boot.img).

Of course, there is not much to be done with temporary TWRP as long as /data remains encrypted. But if we can either unencrypt or decrypt, it may become possible to temporarily boot TWRP to make or restore a nandroid, and otherwise leave your system 100% intact for OTAs

---

UPDATE: Partial success... from the temporarily booted TWRP, we are now able to flash SuperSU with working wifi. The bootloader also still recognized the Software Status as "Official" instead of "Modified". This is pretty cool. But unfortunately, whatever magic worked in 7.1.1 to disable forced encryption when flashing SuperSU does not work in 8.0 so the /data partition is re-encrypted on the initial boot.

---

UPDATE 2: Cellular AND wifi radios are still broken by flashing the "RemoveOreoEncryption" ZIP from temporary TWRP. This is a bummer since the ZIP file actually works and provides unencrypted /data. I can't see what is in the binary updater... need to look for source somewhere I guess.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Brownstain:
So, if I'm reading this right, I can now flash SuperSU without any other modifications. Would this work with a locked bootloader?

UPDATE: Duh, of course this doesn't work. A locked bootloader won't let you use fastboot boot boot.img

C:\platform-tools>fastboot boot twrp-x4-BOOTABLE.img

downloading 'boot.img'...

OKAY [ 0.699s]

booting...

(bootloader) permission denied!

FAILED (remote failure)

finished. total time: 0.711s
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Not sure about the bootloader. Mine was unlocked about 3 minutes after I got the phone :)

This works on a freshly flashed system... it does not play well with any other flashes or attempts at flashing, and I am not sure how it will work flashing on top of an existing system. If you decide to do it, let us know if it works.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kraatus90:
wait, so i can just flash magisk modules by booting to twrp ? no need to decrypt it ?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
I don't know. I don't use Magisk... but it installs fine with the patched boot method on a temporarily booted TWRP. If the modules reside in /data I would assume they will not work.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Was just thinking... if I were to unroot and satisfy the update engine in order to take OTA from 7.1 to 8.0, would I remain unencrypted? Or more directly: will an existing userdata partition be encrypted on first boot of Oreo?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kraatus90:
i think ota will fail if it's unencrypted.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Hadn't considered that... I thought it only verified boot state and system/oem hash. The device is such a pain!
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] rehanraza:
sorry for the off topic query but is it possible to falsh back nougat after flashing oreo?

can't live without root but i can wait for some days while root becomes stable on oreo.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Yes, you can flash back.

Root is working fine in Oreo with both SuperSU and Magisk. Use the BOOTABLE twrp in this thread with "fastboot boot" to flash SuperSU, or use Magisk Manager (switch to BETA channel!) to patch stock boot.img and flash it.

I will update root OP with instructions over the next day or two
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Doranku:
Backup system image fails

Running the bootable twrp image, and trying to backup all partitions, backup fails for the system image part to an otg device.

Haven't looked into what it is used for, is it needed for full restores?

Device is a xt1900-7 (reteu) running the november update (was stupid enought to update before reading the thread closely)

Backing up System Image...
I:Reading '/dev/block/bootdevice/by-name/system_b', writing '/usb-otg/TWRP/BACKUPS/x/1970-01-19--05-28-40/system_image.emmc.win'
Truncating string cache entries.
Truncating string cache entries.
Truncating string cache entries.
I:TWFunc::Set_Brightness: Setting brightness control to 5
I:TWFunc::Set_Brightness: Setting brightness control to 0
I:TWFunc::Set_Brightness: Setting brightness control to 90
I:Set overlay: ''
Truncating string cache entries.
Truncating string cache entries.
Truncating string cache entries.
Truncating string cache entries.
I:TWFunc::Set_Brightness: Setting brightness control to 5
I:TWFunc::Set_Brightness: Setting brightness control to 0
I:TWFunc::Set_Brightness: Setting brightness control to 90
Truncating string cache entries.
Truncating string cache entries.
I:Error writing destination fd (Operation not permitted)
Backup Failed. Cleaning Backup Folder.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] bombaglad:
a little off topic but i have to ask.. has anyone tried flashing the new oreo xposed from this? or do you know any reason why i shouldn't attempt that?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
I would guess that just backing up System is enough as "system_image" is just a mount point, not a writeable partition. In future versions, I will take a look at fstabs to only allow backup of necessary partitions
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
For anyone who is trying to test unencryption here is some important info:

In Nougat, when you go to Settings>Security, under the Encryption entry it will say "Encrypted" if it is encrypted, and "Encrypt" if it is not.

In Oreo, however, the same entry ALWAYS says "Phone Encrypted". When you click on it, if the phone is unencrypted it will bring you to a screen to enable encryption. So, don't assume you are encrypted by reading "Phone Encrypted" -- either click it to see if it prompts for encryption, or boot TWRP and check /data with the File Manager to see if it is unencrypted.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Today's test:

1. From bootloader, fasboot BOOT TWRP

2. Flash SuperSU (note: do not format /data now... not necessary and will cause errors on boot)

3. Reboot system

4. With root file editor, manually edit fstab.qcom to remove forced encryption

5. Reboot to bootloader

6. Boot TWRP

7. Format Data

8. Reboot system

RESULT= SUCCESS

Thanks, [MENTION=1829889]vache[/MENTION] for the simple suggestion... I was making it too complicated :)

WILL UPDATE OP FOR THIS AND ROOT THREAD TOMORROW!
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] vache:
You should disable verity too. (that verify flag on /system partition)
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Will remove them from fstab as well. Thanks again

Not sure why these same edits break radios with a simple flashable ZIP. Perplexing...
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
OK, back to working on TWRP now that we can be unencrypted on both 7.1 and 8.0.

Things I know are broken (or need to be revisited):

1. adb/mtp/sideload

2. Time Zone

3. USB OTG backups on BOOTABLE TWRP (working, but some wonky behavior)

Please add to the list if you find anything, and include logs if possible.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Doranku:
Guessed something like that and went to rooting right after posting the error. fastboot boot twrp and installing supersu went straight forward. Thank you for the hard work to root this device. I hope you will get encryption working some day.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Brownstain:
I only did steps 1-3 from above right after I unlocked my bootloader. I can confirm that this worked very smoothly for me to gain root access. I got the Oreo OTA a couple weeks ago, but did not otherwise flash anything before taking these steps. Everything seems to be working great. Thanks for all the work you've done here mightysween!
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Tommylee567:
A Working TWRP OR Magisk

Dear [MENTION=3683732]mightysween[/MENTION],

Appreciate your hard work on the X4 for the past months since its release. And thank you for coming up with the root method and TWRP method.

I took this as a challenge and wanted to root and install TWRP on my X4 which is a

Retail India 1900-2, Oreo OTA updated version, APAC CUST

One thing was confusing though, you have mentioned in two different posts the methods of rooting and installing TWRP.

So I thought of gathering the data from you and see what I can do with it in one shot.

Kindly confirm by doing these steps and if it works please put it in a single post to avoid confusion.

Below are the methods from your posts which I am copy pasting here for easiness.

Assuming you are on OREO

0. UNLOCK BOOTLOADER (Please mention this on your post on the first point)

(Now the slate is clean)

(Below is from the Root Post which you shared)

OREO ROOT METHOD #1:

1. Download Magisk 15.3 patched boot image: https://drive.google.com/file/d/1uM5E7thwPu4kps4i53Y8PHPFZgRcXzJ-/view

2. From bootloader (Vol Down + Power), flash patched boot image with

fastboot flash boot <name of file>

3. Reboot and check if Magisk Manager is installed (sometimes it fails...). If not, download and install latest Magisk Manager and check that Magisk is properly installed and running.

(This is from TWRP post)

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!)

Encryption is zero now on the phone! Verified even after multiple userdata erasing.

My version below

10 Start bootloader (Vol down + Power),

type - fastboot erase userdata,

then reboot.

11 Repeat steps from 1 2 and 3 above to get Magisk.

OR

12 Get TWRP from this (MightySween's link)

https://drive.google.com/file/d/1WcVS_3rloF7jxPulj_jKxfsp3zy5pB5N/view

fastboot flash boot twrp_3.2.1_OREO_x4.img

Finally TWRP works but no Magisk :(
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
I guess I am not understanding... these steps would install Magisk twice (steps 2 and 11) and remove/break it twice (steps 10 and 12).

There are two separate posts for root and TWRP because some people may want root without TWRP, or TWRP without root. Some want SuperSU and not Magisk, and some Magisk instead of SuperSU.

There is no bootloader unlock step because some people may want to leave it locked, which is possible in certain configurations.

Your step 9 says encryption is removed, but it is not until data is formatted. Sometimes "fastboot erase" does not format the footer of the userdata, and "fastboot format" is not allowed. This is why my instructions for unencryotion use TWRP "Format Data" instead.

And as for putting the button combos for bootloader reboot in each step... I assume that people who are not at least familiar with booting to bootloader should not be flashing boot partitions :)
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Tommylee567:
Thank you Sir for that.

I did install Magisk twice cause after formatting data partition i had to reinstall the whole thing.

I am not sure why this is caused but few times i had rebooted and tried over and over again. Sorry for me being silly but there were things which I didn't understand during my process.

Step 9, looks like i had to put it after the last three steps (sorry).

Now no more encryption for me. After meddling with it for about 3-4 hours I have finally got the phone make use of it normally.

But the out come is clear, use either TWRP or Magisk
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
TWRP and Magisk are both boot images, they can't be flashed over each other.

The Magisk flashable ZIP method was broken in 15.2. I have not tried in 15.3...it may work

The bootable TWRP can always be booted when needed.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Tommylee567:
Yes flashing the Magisk doesn't work or even boot when using TWRP.

Flashing img file directly works. Am running Magisk 15.3 right now.

Works! :o :D
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] DarkLara:
When you deactivate the encryption, can the micro SD be used as internal storage?

thanks..

sorry for my english
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] boladaso:
7.Root file editor/text editor ....

I recommend using the "Root Browser" and it is necessary use "busybox" or you will not be able to save the edited file.

-Root Browser

https://play.google.com/store/apps/details?id=com.jrummyapps.rootbrowser.classic

-Busybox

https://play.google.com/store/apps/details?id=stericson.busybox
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
I have used Amaze and Total Commander (w/built in text editors) without installing Busybox... but whatever works :)
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] skinnywaffles:
So quick recap for me: I can have Magisk or TWRP (not both, both are boot imgs) That's fine for now, don't need TWRP that much. So I have Magisk and the bootable TWRP, but I can't flash anything due to the encryption (right?). Is there anyway to stay with the Magisk patch normally and for the bootable TWRP to not be encrypted? I basically just want to have the patched Magisk unless I need to use TWRP. Do I have to do this, flash everything I need to, and return to magisk (and have to do this again anytime I need to flash something) or do I just need to do this once and that be it? Thanks. Asking because I mainly need Magisk but it is kinda pointless if I cant flash anything
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Yes, you can unencrypt, return to stock and then install Magisk and use bootable TWRP
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] skinnywaffles:
Won't that encrypt my system again if I flash stock?. If not, great I need magisk
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
I guess I should have wrote that the other way... flash stock and then unencrypt. :)
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] skinnywaffles:
Not a prob, just wished I knew that before flashing stock and doing the su way last night. Looks like I'm wiping again ?. FYI, I have the A1 version found stock on afh. I would add instructions for magisk in the OP bc this device's forums are kinda poorly written. Thanks for all your hard work tho.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] oscarando:
can you share the link of the A1 version?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] skinnywaffles:
Here. This is basically all the X4 firmwares from N to O. The prefixes before the build numbers correspond to the version (AMZ=Amazon. FI= A1, N/A= moto version). You can follow the steps in OP and use those commands or use the ones the ones i did here . I used minimal adb and fastbooot and extracted the files there. if you also want the decryption i used the Root Explorer/Busybox method in an above to edit my fstab because only that worked for me. Wish you the best.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Slickademo:
For some reason twrp won't flash. Are you supposed to flash img to boot inside bootable twrp or flash with command window on computer? I edited the file for encryption but I'm not sure if it worked? Not sure what I'm doing wrong. I easily obtained root but for some reason I'm having issues figuring out recovery. Hopefully these screen shots help give some info. If I plug in the phone and go to the encryption settings, it has the option to encrypt. I'm assuming that I am successfully unencrypted. Not sure what my next step is?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Hmmm... "poorly written"? The instructions seem pretty clear in the OP... maybe you just skipped some steps???

The instructions use SuperSU because it is recovery flashable. Magisk is not. You will need to make your own boot image.

I would much rather see someone start a thread to deal with Magisk than turn this into a Magisk thread.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Slickademo:
I just flashed Img to boot.... Works great! Lol
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Yes, you appear to have done everything right.

You can continue to use the bootable TWRP as needed, or download the TWRP for OREO image in the first post and flash with fasboot (to the boot partition, obviously).
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Slickademo:
I was under the impression there was supposed to be a recovery partition, that's what confused me. Can't wait for Roms to show up! ?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
In other news, there is a TWRP for the Xiaomi M1 (tissot) that has working decrypt on a very similar device to ours.

DM is not working so hoping [MENTION=7969941]pl_blaze[/MENTION] will see this tag and be able to provide a device tree and/or description of his solution... if it makes sense for X4, I may reopen attempts to make a version that supports decrypt
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] pl_blaze:
You most likely need to relink the qseecomd binary to use the proper path in the twrp recovery...see the provided twrp script on how to do it.. Good luck! :D
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kiyip:
I am getting an error when I try to flash twrp. I want to make sure I am doing it right

in the linux terminal I typed this

adb reboot bootloader

then

fastboot flash recovery twrp-3.2.1-motorola-x4.img

then I got this error

target reported max download size of 536870912 bytes

sending 'recovery' (19276 KB)...

OKAY [ 0.447s]

writing 'recovery'...

(bootloader) Invalid partition name recovery

FAILED (remote failure)

finished. total time: 0.453s

has anyone else run into this problem. Am I doing something wrong?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
You need to flash to boot, not recovery (there is no recovery partition).
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kiyip:
so just to be clear i should type

fastboot flash boot twrp-3.2.1-motorola-x4.img
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Sorry, missed this... yes, that is correct.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kiyip:
All good, I figured it out! Thanks tbough
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] Neffy27:
::deleted:: someone already answered
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] steveeJ:
I can't get TWRP to flash zip files and actually alter /system. I suspect that there is something wrong with mounting of the filesystems, as TWRP is also not able to read the filesystem of /sdcard clearly. The files in /sdcard have names like hash strings.

I've attached the log from my last attempt to flash the fdroid privileged extension zip.

Fortunately the SuperSU zip was able to patch boot file so root works great, thank you! :)
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Are you decrypted?? This build of TWRP does not support encrypted filesystems...
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] darkdaemon32:
I'm having the same issue root works fine under magisk manager but my phone still says encrypted even after editing fstab.qcom and wiping data twice using bootable twrp. I followed all the steps from the OP and my phone still says encrypted under security and settings. But it still give me the option to encrypt the phone?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] darkdaemon32:
Attaching screenshots of security options
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] kraatus90:
that means it's not encrypted.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] darkdaemon32:
I get that part. My point was that I followed the OP and my phone was still encrypted but root was working. Same as the other use who posted before me. Obviously editing that file doesn't work or isn't enough.

ALSO: Its NOT encrypted, i can access files fine from twrp.
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] darkdaemon32:
TWRP Flashed just fine, but i can't however flash xposed, because i get errors when trying, also can't use flashfire until its updated for the new magisk 15.2 version...
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
If you have the "Encrypt Phone" option, your device is decrypted...

Can someone having this issue send a recovery log from the advanced menu in TWRP?
[Moto X4 ROMs, Kernels, Recoveries, & Other Develop] mightysween:
Wait, I am getting confused. So there is no encryption issue? What was the problem?

As for xposed not installing, I have no idea... anything in the log?