yashsingh1/xdaforums huggingface dataset:
[Moto G4 Plus Guides, News, & Discussion] toppits:
[MENTION=6132305]hamidkhatri[/MENTION]

You can try to restore your Backup and install the OTA-Update, but it OTA-Update ended up failing for me and others.

After I flashed the mentioned files the OTA-Update finally was installed successfully, no problems at all. IMEI is still there, Update-Channel is still the same, no data lost, didn't wipe or anything and everything runs smooth so far.

To my understanding the XT1642 and XT1643 are practically the same device, released in different countries.
[Moto G4 Plus Guides, News, & Discussion] hamidkhatri:
[MENTION=4643647]toppits[/MENTION] i dont want to wipe data again, so i will go thru ur way.

Thanks
[Moto G4 Plus Guides, News, & Discussion] hamidkhatri:
[MENTION=4643647]toppits[/MENTION] successfully flashed mentioned rom's files and installed Nougat 7.0 via OTA update.

Thanks
[Moto G4 Plus Guides, News, & Discussion] RawSlugs:
How do I backup logo?
[Moto G4 Plus Guides, News, & Discussion] toppits:
Did you read the OP? It's described at the end of it ..
[Moto G4 Plus Guides, News, & Discussion] eta82:
Thanx ! ! !
[Moto G4 Plus Guides, News, & Discussion] TheEvilVirus:
Only very old versions for XT1602 are online and I don't get OTA notifcation afterwards. Anyone has a link to a current version?
[Moto G4 Plus Guides, News, & Discussion] ashagg:
I have my phone rooted with elementalX and twrp (stock rom though). I got the update just now and tried installing the OTA via system update... however since i have a custom recovery it didn't update and now m stuck on my twrp screen... booting the phone always redirects to my twrp... plz tell me what to do now...

I've already tried clearing cache and Dalvik through TWRP but still the same ...

dd if=/dev/zero of=/dev/block/platform/soc.0/7824900.sdhci/by-name/misc count=1 bs=32

Still nothinig :(
[Moto G4 Plus Guides, News, & Discussion] Adarsh balu:
Use flashfire app

First download the update do not install it jsut yet.

Go to flashfire app and you can find an option for the ota over there ..just do it done
[Moto G4 Plus Guides, News, & Discussion] dragos240:
So I flashed all of the stock firmware files (boot, system, recovery, and logo) and it's still giving me an "error" when I try installing via the normal method (using the update service). I also tried sideloading it via adb and that didn't work either. I'm confused. Is it because my bootloader is unlocked? I can't think of anything else and I would rather not relock my bootloader because when I unlock it again, my device will be formatted :/.
[Moto G4 Plus Guides, News, & Discussion] echo92:
Hmm, flashing stock firmware should be okay... What device do you have, and which update are you trying to apply via OTA? Bootloader status shouldn't matter, only if the OTA is detecting modifications to your system, kernel and recovery it'll fail, but seems like you've done all that!
[Moto G4 Plus Guides, News, & Discussion] dragos240:
I have a normal Moto G4 (XT1625), not a Moto G4 Plus. The same steps *should* apply, but not sure why it's not working. Trying to install the new Nougat update.
[Moto G4 Plus Guides, News, & Discussion] abhi212b:
It's damn easy!

When on twrp screen press and hold power and volume down for 3-4 seconds.. It will take you to bootloader, use normal start from their to boot the device..
[Moto G4 Plus Guides, News, & Discussion] Ambu93:
Worked perfect for me, thanks!
[Moto G4 Plus Guides, News, & Discussion] calinb7:
Can I just use my twrp backup system files?

Thanks, Bender1987!

I used your excellent guide for systemless root on my XT-1644:

https://xdaforums.com/moto-g4-plus/how-to/root-systemless-rooting-supersu-2-74-2-t3405772

Now I need to update to Nougat to try to get 4G working with my new Verizon service (long story) so I must unroot my phone and take the Nougat update.

When I rooted, I did not install TWRP permanently. (I just booted the .img). Before rooting, I backed up everything TWRP can back up.

Can I just restore my original system files backup by booting the TWRP .img again, instead of flashing files with fastboot? I don't want to download the full 1GB ROM and of course I trust the integrity of my own TWRP system files backup more than a web-hosted ROM image. Maybe there is a way to use my TWRP backup files with fastboot too, but I don't think so.

Unfortunately, I did overwrite the stock logo so I will have to find a download of the original logo and restore it. (I did not realize that TWRP does not back up the logo when all the TWRP backup boxes are checked). I have not found a copy of the stock logo yet so I may have to download the entire ROM just to get the logo anyway. :crying:

Also, some Moto G4 Plus owners have had to return their phones to Moto/Lenovo under warranty to get 4G working on Verizon. If I have to return my phone, will Moto/Lenovo be able to tell that I ever rooted my phone, if I restore AND relock the bootloader? Yes--I know Motorola supplied my bootloader unlock code, but that doesn't mean I ever used it and I don't think they bother to check such records. (Fingers crossed!)

Best Regards and thanks again,

-Cal
[Moto G4 Plus Guides, News, & Discussion] calinb7:
Ready to root again!

A second update got me to NPJS25.93-14-4 and clicking "Settings" >> "About Phone" >> "System updates" says "Your device's software is up to date." :victory:

Honoring my pledge to archive all OTA install zip files, I used fastbooted TWRP and used its file manager to browse to /data/data/com.motorola.ccc.ota/app_download, as described in the OP (which worked for the Nougat update), but did not find the latest OTA "security" update! :crying::confused:

Fortunately, it was easy to find in /cache and I copied it to sdcard for side loading and archiving on my computer via MTP. :cool::cool: No root has been required to copy these two OTA zip files using TWRP, BTW.

Update (FYI): Unfortunately, the MTP interface no longer works in Nougat (I could browse to the file in my GNU/Linux MTP ap but the download failed, and yes, I did check the box for MPT file transfers). Fortunately, it still works in TWRP so I had to boot TWRP to save my latest OTA zip file.

That's the latest update on my saga. Time to root again!
[Moto G4 Plus Guides, News, & Discussion] ruderus:
I feel you!

But I have a concern... once I revert to stock and get the OTA to Nougat, I won t be able to root again using the superSU 2.78 method... right?

So, Is there already another way to root a G4 Plus (Xt1644) on Android 7.0?
[Moto G4 Plus Guides, News, & Discussion] echo92:
Once you've updated to Nougat, you won't be able to use the same method - if you attempt to root with the stock Motorola kernel you'll likely bootloop as you'll be tripping the enforced anti-rooting security in the Nougat kernel.

However, a way around that is to flash a custom kernel (ElementalX or vegito, for example) which will allow you to root with SuperSU 2.82 (which is the latest SuperSU).

Here's a guide for rooting on Moto G4/Plus devices on Nougat : https://xdaforums.com/moto-g4-plus/how-to/guide-root-moto-g4-plus-supersu-android-t3587918

Also, depending on which build of Nougat you update to, downgrading - if you choose to - is very risky with the March and especially June 2017 stock updates (NPJS25.93-14-4 and NPJS25.93-14-8), be aware.
[Moto G4 Plus Guides, News, & Discussion] ruderus:
Thanx Echo92! Actually, I just upgraded to NPJS25.93-14-4... Do I need to downgrade in order to root using the ElementalX/supuerSU method?
[Moto G4 Plus Guides, News, & Discussion] echo92:
No need to downgrade whatsoever. Flash TWRP, then back up, then flash ElementalX before rooting with SuperSU.

I've only put that warning there if you decided to revert back to full stock in future, e.g. if you wanted to take an OTA update. If you wanted to be on the latest update, you could flash the TWRP flashable when someone makes the file, else you'd have to revert back to stock and this have to be careful in flashing the latest stock fastboot ROM.
[Moto G4 Plus Guides, News, & Discussion] flroots:
I am in the process of unrooting so that i may install OTA NPJ25.93-14.5 on my XT1644. I have unrooted via SuperSU command. Next I wish to flash stock logo.bin. For some reason adb works fine, but the fastboot command simply returns 'waiting for device' while in fastboot mode? Here are the commands I issue from PC's terminal window:

Any suggestions on what may be wrong would be appreciated. Thanks.
[Moto G4 Plus Guides, News, & Discussion] flroots:
Update: got fastboot working by installing MDmanager.

After completing all steps I'm now getting failure: "system partition fails to recover". This is despite flashing all specified files. Any ideas?
[Moto G4 Plus Guides, News, & Discussion] Mikeandrd2292:
I'm pretty sure I did everything right and it's not working. Help please!
[Moto G4 Plus Guides, News, & Discussion] toppits:
Nobody will be able to help you if you give literally no information besides "it's not working". Not sure what you expect.
[Moto G4 Plus Guides, News, & Discussion] soccerref80:
First I have confirmed correct ROM details for my xt1625 and have the right files in MIN ADB

When flash Boot and Recovery get error message :- Image not signed or corrupt................

Had to do restore from TWRP to go out of boot errors.

am lost. I would love to have 7.1.1 but this is a mess
[Moto G4 Plus Guides, News, & Discussion] pastorbob62:
Not sure why this happened to you. I do know that flashing TWRP gives the "Image not signed or corrupt" error but I just ignore it and it works fine. I had no issues after that. I don't recall (it has been months) if I saw that error while flashing stock boot and recovery. I am preparing to flash the latest firmware with he September security update and let you know.
[Moto G4 Plus Guides, News, & Discussion] abhi212b:
This is not an error... Even if the line says... Image signed with a bad key... Is not an error... Just let the bat file work... It will reboot automatically...and will work normal
[Moto G4 Plus Guides, News, & Discussion] soccerref80:
I was trying to go back to stock using this method so that I could update:confused: via OTA to 7.1.1. That is the problem. NOT with TWRP.

SO using MIN ABD and flash codes produced the errors. Had a boot loop and dead android with RED not available w trying to get back to recovery.

Hence the re-flash of TWRP and restore.

@ abhi212b . Just let the bat file work... It will reboot automatically...and will work normal.

No idea what .bat file you are referring to. I issue the commands from MADB. so ?????
[Moto G4 Plus Guides, News, & Discussion] pastorbob62:
He is talking about flash.bat. I just did the -10 update and had no issues at all flashing everything using this procedure:

https://xdaforums.com/moto-g4-plus/how-to/stock-rom-npjs25-93-14-4-march-1-t3608138

Not sure why you are seeing problems getting stock recovery to flash.
[Moto G4 Plus Guides, News, & Discussion] soccerref80:
Probably as I have a modified recovery, installed TWRP. That created problems with OTA.

SO if I get this correct.

DO the backup with TWRP now.

Do the flash.oem bat from within MADFB with loaded files. That will wipe and install the NPJ25-93 (7.1.1) android update..............Does that also wipe the SD, if so I would have to save the TWRP backp to PC

Then re-root and restore Only data with TWP?????????

I did not get there were 2 different threads being referred to .

\Many thanks for the clarification.
[Moto G4 Plus Guides, News, & Discussion] pastorbob62:
It shouldn't wipe the SD but just to be safe I always do my backup then switch to a different SD Card until everything is flashed and I am back up running. That saves having to copy to the PC. I would also do a Titanium backup to the SD Card before flashing. You will also have to reinstall TWRP after flashing the stock ROM.
[Moto G4 Plus Guides, News, & Discussion] flroots:
My current build is NPJ25.93-14.5 and I just started receiving OTA notices for NPJ25.93-14.7. I can't find the stock firmware for NPJ25.93-14.5 to download before updating the OTA. Can anyone point me in the right direction? Also, I'm confused because I see references to more recent OTA's that others have received eg, 14-14-8 and14-10. For reference I have the XT1644 located in the US. Thanks in advance for any help.
[Moto G4 Plus Guides, News, & Discussion] ____Mdd:
Here is latest one(14.7) (you can find 14.5 in uploader's profile if you want) : https://androidfilehost.com/?fid=817906626617945295

Edit:: Echo92 has replied better in another thread, read XDA rules / post your questions only once..
[Moto G4 Plus Guides, News, & Discussion] flroots:
Thanks. I found the stock firmware for 14-5 under Profile as you suggested. This is the correct firmware to flash, correct? I'm still wondering why the references to 14-8 and 14-10 if 14-7 is the latest. Are they for other geographical areas?
[Moto G4 Plus Guides, News, & Discussion] Garvitmathur99:
I installed ota on my rooted device, now everytime it boot it opens twrp. I don't know how to reckver my phone ..Please help!!!!!!
[Moto G4 Plus Guides, News, & Discussion] lloco73:
You must reinstall stock recovery

Enviado do meu Moto G4 Plus através do Tapatalk
[Moto G4 Plus Guides, News, & Discussion] hc803:
Just used OP's instructions to update from Marshmallow to Nougat and was successful but lost root. Head's up to anyone else doing it.
[Moto G4 Plus Guides, News, & Discussion] echo92:
Generally, re-flashing the stock ROM will cause you to lose root and TWRP - the custom modifications are over-written by the stock ROM flash. You can however flash TWRP and proceed to re-root on your newly updated device.

Bear in mind that rooting on stock Nougat requires flashing a custom kernel, such as ElementalX, before rooting. Unlike on stock Marshmallow, attempting to root the stock kernel likely results in a soft bootloop (presumably as you've tripped the anti-rooting protections in the kernel, which are more strictly enforced in stock Nougat).

If you still wish to root, boot/flash TWRP, then backup your device in TWRP. Flash ElementalX v2.0 (or vegito), then your root manager of choice. Wipe cache/Dalvik, then reboot.
[Moto G4 Plus Guides, News, & Discussion] calinb7:
I think I can finally answer my own question. I found the cause of the problem here on the TWRP site:

https://twrp.me/faq/whattobackup.html

On most devices shipping with Android 6.0 or higher, the device maker has enabled dm-verity as a security measure. The device will signature check blocks of data on the system partition during boot at the block level. The usage of dm-verity prevents TWRP from being able to successfully restore a normal system backup. On most of these devices, you will see an option on the backup page for System Image. A system image backup takes up more space than a regular system backup, but the system image backup is a bit-perfect backup that, when restored, will not break dm-verity (assuming that you don't break dm-verity before making the backup).

I have TWRP 3.0.2-0, 3.1.1-0, and 3.2.1-0 and only 3.2.1-0 supports system image backups, which my Moto G4 Plus appears to need to permit an OTA update. Furthermore, Flashfire warns that mounting the system partition read/write, instead of read-only, only once can break future OTA updates. See the "Mount /system read/write" checkbox warning here:

[IMG="Flashfire Screen Warning"]https://img.xda-cdn.com/7eLqKtqe_WNuYVfBNbD13OFWDYY=/http%3A%2F%2Fxdaforums.com%2Fattachment.php%3Fattachmentid%3D3877131%26stc%3D1%26d%3D1474039589[/IMG]
[Moto G4 Plus Guides, News, & Discussion] echo92:
Hmm, so for both procedures, seems that in order for a backup to be possibly OTA friendly, you'd have to take an exact partition copy before 'swipe to allow modifications' or anything else that would change the read-only flag/modify the system in any way, and even then dm-verity causes headaches. That makes sense, as the block based OTAs check the cryptographic signatures of the /oem, /system, and other partitions prior to flashing. If the OTA checks reveal a partition not reporting the correct signature (e.g. read-write system partition) then the OTA will fail. https://twrp.me/faq/officialota.html https://source.android.com/devices/tech/ota/nonab/block

Mind you, these checks are likely necessary as the OTA updates for our devices are block based - not many full files to save space. Else, attempting to patch a device with blocks not in the expected position or with unexpected contents would likely lead to severe corruption of the system.

Seems that the easiest route to revert back to stock and ensure your device is OTA friendly is to re-flash the same stock ROM as the build you currently have, whilst removing TWRP, ElementalX, magisk and other modifications. Most if not all the stock firmware we have should be cryptographically signed by Motorola, else the bootloader would likely reject the firmware if you tried to flash unsigned firmware (especially an unsigned bootloader). Furthermore, if the firmware is signed with release keys, these are usually only provided by Motorola or someone with access to their private keys. Whilst someone could try to interfere with the chain of trust by altering the bootloader, that may brick devices as the bootloader may not be verifiable by the hardware key/primary bootloader burnt into the device. If you see users being able to lock and boot their devices with a certain firmware, it's likely genuine for the aforementioned reasons. If someone was able to compromise Motorola's private keys and sign builds in their authority, that could mean OTA updates would no longer be safe.

Unless you can guarantee that your TWRP backup was made without modifications - i.e. a system image made with official v3.2.1 , in which case you may be able to use the backup on an unlocked bootloader (but dm-verity might give you hassle!)
[Moto G4 Plus Guides, News, & Discussion] calinb7:
Yes. I think your conclusions are correct, echo. Another pitfall scenario to ponder: I assume that Android uses a Linux/POSIX "accessed" file date/time stamp. If a filesystem is mounted r/w and even a single file is merely read but once (even by the system), would not that action also break the cryptographic signature check and OTA?

Thanks for the links. I have been reading the entire TWRP FAQ repeatedly and trying to fully understand all the points myself over the last day or so.

Agreed, but I believe the main difficulty is Lenovo/Motorola only releases the original ROM image. New ROMs are created with OTA updates and the entire chain of them must be applied each time a user wishes to revert back to stock and update. I suspected that this might be the case when I rooted for my second time and I archived all the OTA in the chain to that point.

From the TWRP FAQ:

Though the OEM trust feature and mechanism is always broken as soon as we root (particularly with the need for a 3rd party kernel), I believe there are greater security hazards in following the above advice instead of rebuilding the entire chain of OEM OTAs, updating with newly released ones, and then re-rooting with the minimum un-trusted software as possible!
[Moto G4 Plus Guides, News, & Discussion] calinb7:
Wow and thanks! I was not aware of this hazard so I guess the only safe way to get OTA updates on a rooted or modified phone (in the manners we've been discussing) is to do a factory reset and only then re-install the entire OTA update chain and rooting process.

Yes. I think 3rd party re-worked and rooted stock ROM images (as suggested on the TWRP FAQ) or a custom ROM are in my future!
[Moto G4 Plus Guides, News, & Discussion] echo92:
Factory resets only should wipe your data and apps. It may not restore your device to a stock firmware configuration (i'm not sure if our devices even have a restore partition). One way to restore back to OTA friendly stock status, as similarly described in the first post, would be to re-flash the system, OEM, logo, kernel and recovery partitions from a stock ROM of the same build. Though you'd remove TWRP, root and any other modifications, your device should be clean and still have your data. Furthermore, your device should then be on the same patch level (including your bootloader) as you only flashed the same firmware as what was on your device, so your device should be ready for OTA.

Alternatively, you can fully flash a newer stock firmware (ensuring it's for your region), without locking your bootloader and without fastboot erase userdata. Afterwards, restore TWRP/ElementalX/root.
[Moto G4 Plus Guides, News, & Discussion] calinb7:
The OP doesn't cover the issue of downgrading while retaining a non-downgraded bootloader (and it doesn't instruct the reader to flash bootloader.img from the original ROM in step 2. Restore the stock ROM images).

Would it always be safe to downgrade to the original stock ROM images, as described in the OP step 2, if bootloader.img is also flashed? Is there any downside in always downgrading the bootloader in the process of restoring the original /system, boot.image, recovery.img, and logo.bin in preparation for installing an OTA series of updates?

Thanks for you explanation of factory reset WRT /data and /system.. Wiping data doesn't seem to be a necessary step in a safe OTA update method. Given that I'm just about certain that dm-verity will fail again if I just restore /system from TWRP backups (as it did the first time I unrooted and had to follow this guide to take OTA updates), would it be safe for me to follow this guide again, but make sure I flash bootloader.img this time? BTW, I unlocked my bootloader a couple of rooting-update-re-rooting sessions ago and I've never locked it since.

I'm trying to decide whether to try to downgrade my system to the original ROM again and then update via OTAs to December 1 level and re-root, or just install a non-stock ROM or perhaps a 3rd party packaged and already updated ROM.
[Moto G4 Plus Guides, News, & Discussion] calinb7:
Okay--let's see if your tutelage is finally working on me, echo! :fingers-crossed: It seems like a basic underlying concept or rule or two should be sufficient to keep me out of trouble!

The OTA update system is designed and intended for step-wise, forward-direction updates only. At times, it will block regression in the interest of precluding the installation of an outdated and insecure bootloader (as you described and warned). It is also dangerous to go around the OTA step-wise behavior and "flash ahead" to a ROM revision that embodies more than a single OTA step, because an older installed bootloader may not be compatible with newer ROM content.

If the above is not quite right, at least I hope I am getting close to correctness and truth, and I very much appreciate your patience with me!

What is the difference between NPJ... and NPJS...? Are "S" ROMs for Europe? From reading the xda forums, I believe AMZ_NPJ is a ROM for India.
[Moto G4 Plus Guides, News, & Discussion] calinb7:
If the bootloader exhibits this behavior (blocking an older bootloader), it seems like some 3rd party software should be able to flash the old bootloader along with the down-rev ROM images while the phone is still rooted. Upon boot, everything would be safely restored to the desired and un-rooted downgraded level.

My thinking was the bootloader plays a role in updates and blocks older bootloaders so perhaps it might have a similar problem with update attempts that are not step-wise.

Again, it seemed to me that this upgrade situation is the same as when downgrading with a full flash of a down-rev ROM. In both cases the bootloader image is compatible with the full copy image set, but I now understand the difference is the bootloader will permit flashing a newer bootloader in the upgrade case, but not the older bootloader in the downgrade case.

That's what I thought and I had no trouble when following the guide of the OP without un-rooting. Thanks for answering all my other questions too!