yashsingh1/xdaforums huggingface dataset:
[Moto G4 Plus Guides, News, & Discussion] divemaster73:
your TWRP image in the same folder as your adb/fastboot programs? yes

Is your device booted into the bootloader and attached to your computer? yes

Are you able to communicate with your device using 'fastboot devices' in the ADB terminal? yes

and the file name has been written correctly.

the steps I followed are these:

1) download and install ADB and fastboot

2) enable usb debug om device

3) unlock the bootloader by code

4) download the twrp-3.1.1-athene_shreps.img file in the adb folder

5) open a dos window (cmd) in the adb folder

6) "adb devices" serial ok

"adb reboot bootloader"

"fastboot devices" serial ok

7) "fastboot flash recovery twrp-3.1.1-athene_shreps.img"

8) error: has-slot:recovery: not found

plus error related to file size to be copied (I don't remember the exact words)
[Moto G4 Plus Guides, News, & Discussion] strongst:
Please read my post above yours and see if you get the same output or not. If not please provide the full output like a screenshot or log!
[Moto G4 Plus Guides, News, & Discussion] divemaster73:
It's not the same log, now I do not have my log with me (I'm away from home) This evening (from home) I post my log

---------- Post added at 07:39 PM ---------- Previous post was at 07:07 PM ----------

This is my screen log https://ibb.co/eZMbsR
[Moto G4 Plus Guides, News, & Discussion] echo92:
Hmm, can you confirm you've unlocked your bootloader please? Those pre-flash validation and failed validation errors look like a result of having a locked bootloader still (most likely) or an incomplete TWRP image. Signs that you've successfully unlocked your bootloader include your device being erased on unlocking, the bootloader unlocked warning appearing on boot, and on your bootloader it should appear 'flashing_unlocked'.

You may wish to confirm the process with this guide here: https://xdaforums.com/showpost.php?p=67031801&postcount=2 You can use either mfastboot or fastboot.
[Moto G4 Plus Guides, News, & Discussion] strongst:
For sure you did not successfully unlocked your bootloader. Look at my attachment, it looks like the same.
[Moto G4 Plus Guides, News, & Discussion] divemaster73:
Yes I used the same post for unlock the bootloader https://ibb.co/fz3Rbm

---------- Post added at 09:45 PM ---------- Previous post was at 09:39 PM ----------

I'm sure the whole procedure went well, I followed step by step what was written here: https://xdaforums.com/showpost.php?p=67031801&postcount=2 then I confirmed by developer options https://ibb.co/fz3Rbm this is the fastboot screenshot https://ibb.co/fSGXhR
[Moto G4 Plus Guides, News, & Discussion] echo92:
Developer Options only will tell you if you are able to unlock your bootloader, not if your bootloader is actually unlocked. The OEM unlocking toggle is simply there to allow you to unlock your bootloader.

If you turn off your device and turn it back on, do you see a bootloader unlocked warning (triangle on a black screen, text warning that your device is unlocked and cannot be trusted), before the Motorola boot up screen?

Furthermore, if you boot to bootloader, do you see 'flashing_unlocked' listed on your device?

Also, did your device erase itself when you formally unlocked it?

Okay, if you're sure that you've unlocked your device bootloader, download a fresh copy of shreps' TWRP 3.1.1 from here https://moto.shreps.fr/?dir=Moto G4 (athene)/recovery Copy the image to your ADB folder and see if you can boot into TWRP (boot your device to the bootloader, connect to your computer, and in the ADB terminal, type 'fastboot boot twrp-3.1.1-athene_shreps.img' without the quotes )
[Moto G4 Plus Guides, News, & Discussion] divemaster73:
Thanks Guys, I don't know where the error was, but after repeating 2 times everything now is done. I installed twrp, from twrp I installed "SuperSU-v2.82-SR5-20171001224502.zip". Now I can use fastboot and twrp but it does't restart normally. can i solve this problem?
[Moto G4 Plus Guides, News, & Discussion] strongst:
Please tell what you want to do? If you want to root the stock rom in this thread with supersu... then you need ex-kernel before flashing the su binaries zip. Please make sure to read everything twice before proceeding and understand what you doing or just ask here in case of confusion https://xdaforums.com/moto-g4-plus/help/help-thread-question-noob-friendly-t3526598
[Moto G4 Plus Guides, News, & Discussion] echo92:
Did you flash a custom kernel before rooting? If not, then you'll have to re-flash the stock ROM (no need to re-lock the bootloader) or restore the backup you made (you did make a TWRP backup, right?)

For rooting on stock Nougat (Motorola), you need to flash TWRP, then a custom kernel like ElementalX, then proceed to root. Failure to flash a custom kernel usually results in a bootloop that a re-flash of the stock ROM (the one in the opening post of this thread) can fix.
[Moto G4 Plus Guides, News, & Discussion] divemaster73:
I'm really stupid because in the rush to solve the problem I did't backup before and i don't flash a custom kernel.

---------- Post added at 11:05 PM ---------- Previous post was at 11:00 PM ----------

I just wanted to have root permissions, but I think now I'll have to install a new custom rom
[Moto G4 Plus Guides, News, & Discussion] strongst:
Just for gaining root access you don't need a custom rom cause most custom roms comes without implemented root. So you also need to flash root(su or magisk) to gain root access.
[Moto G4 Plus Guides, News, & Discussion] echo92:
You don't have to flash a custom ROM as mentioned by strongst. If you want to stay on stock:

1)Re-flash the stock ROM (NPJS25.93-14-13) as provided in the opening post. If you want to try to preserve your data, try the following fastboot commands when flashing:

fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash dsp adspso.bin
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot reboot

2)Once you've got your device working again, re-flash TWRP. Make a backup of your stock ROM on your device. Make a separate backup of the boot partition only (this is your stock kernel)

3)Download ElementalX 1.04 kernel (for stock Motorola ROMs) from here: https://xdaforums.com/moto-g4-plus/development/kernel-elementalx-g4-0-01-t3424836 Flash in TWRP, follow the installer instructions.

4) After ElementalX has been flashed, flash SuperSU or magisk as your root manager. Wipe Dalvik and cache. Reboot.

You should now be rooted on the stock Motorola ROM.
[Moto G4 Plus Guides, News, & Discussion] divemaster73:
I know this :) but now i don't have a backup and my device don't start. Is possible to work only with fastboot e twrp.

---------- Post added 15th January 2018 at 12:19 AM ---------- Previous post was 14th January 2018 at 11:30 PM ----------

Really thanks to everyone! Talk to you all helped me to try all the solutions:

1) Unlock bootloader, I had not enabled the function (allow oem) in developer options before fastboot command lines (solved)

2) no switch-on after installing super su, installed new kernel (ElementalX-G4-1.04), reinstalled super su (solved)
[Moto G4 Plus Guides, News, & Discussion] cooldeepak:
Error Extracting file "system.img_sparsechunk.2"

can anyone send me this file only ?
[Moto G4 Plus Guides, News, & Discussion] vishal.mamidi:
is it possible to flash stock rom with external 3rd party app as system app ??
[Moto G4 Plus Guides, News, & Discussion] SanderVisions:
Damn, tried this method but my device keeps getting bootloop in the moto logo.
[Moto G4 Plus Guides, News, & Discussion] echo92:
What device do you have and what firmware did you have before you flashed? Did all steps flash with [okay] reported in the ADB terminal?

Have you tried cache wipes or a factory reset (both should have occurred during the fastboot firmware flash)?
[Moto G4 Plus Guides, News, & Discussion] tnmsrkr:
can not lock bootloader

flash lock oem bat. but bootloader still unlock.
[Moto G4 Plus Guides, News, & Discussion] strongst:
If you modified something then better to flash the whole stock rom and lock afterwards otherwise it can fail.
[Moto G4 Plus Guides, News, & Discussion] echo92:
If you've flashed the stock ROM, then you likely need to enable OEM unlocking in Settings>Developer Options. Then you should be able to lock your bootloader if you re-flash.

For more information, have a look at this post https://xdaforums.com/showpost.php?p=74971791&postcount=497
[Moto G4 Plus Guides, News, & Discussion] billyboy2316:
Worked fine on xt1625 retail version. I did not flash the locks or fastboot flash partition gpt.bin

fastboot flash bootloader bootloader.img. Thank you
[Moto G4 Plus Guides, News, & Discussion] anoopgkris:
hello folks, could you please help me out on this please?

Posted here originally

https://xdaforums.com/android/help/error-restoring-to-stock-twrp-backup-t3736848

I followed some nonsense commands to lock bootloader after restoring TWRP backup of stock Android 7.0 on my MotoG4.

i thought that the backup would restore to stock. After rebooting in the security update it started booting to TWRP.

Is there any way to go back to stock from fastboot or TWRP?

I get the mount errors when trying to flash the 7.1.2 or 8.0 ROMs

Errors on even trying to wipe the partitions back

Is there anyway to correct the partitions from fastboot or TWRP?

I can access TWRP and Bootloader now.

I have the Stock and Android 7.1.2 backups on sdcard.

This is what my current bootloader screen shows (attached)
[Moto G4 Plus Guides, News, & Discussion] echo92:
The TWRP backup would only restore your system (modified unless you did the backup before letting TWRP allow modifications), OEM and kernel, plus some other partitions. You'd still have TWRP (and a custom logo.bin) so an OTA is not recommended. You need full stock recovery, oem, system, kernel and logo partitions at the very least to use OTA updates.

I agree with smitharro in the other post that trying to lock with a bootloader requires a clean stock ROM flash, you cannot re-lock with TWRP - the re-lock would either fail or your device would brick as a locked bootloader stringently checks the key partitions - recovery, boot (kernel) and system for example - and if the partitions don't match, it'll block your boot cycle. In other words, not a good idea to re-lock at the moment! Pre-flash validation errors are from attempting to flash a stock ROM older than what you have available.

Looking at your baseband and bootloader version, if you want matching firmware, have a look at the NPJS25.93-14-8 stock firmware (June 2017): https://androidfilehost.com/?fid=889764386195918175

However, I would suggest getting the getvar info from your device, so we have an idea of the last stock firmware on there and guide you better:

1)Boot your device to the bootloader. Connect to your computer via USB.

2)Open the ADB terminal and type 'fastboot getvar all' without quotes. Press Enter.

3)Copy the output from that command into a post here. You may wish to remove your IMEI from the output.
[Moto G4 Plus Guides, News, & Discussion] anoopgkris:
Thanks for the help.

My getvar all details are as below

C:\Users\Anoop>fastboot getvar all

(bootloader) version: 0.5

(bootloader) version-bootloader: moto-msm8952-B1.06

(bootloader) product: athene_13mp

(bootloader) board: athene_13mp

(bootloader) secure: yes

(bootloader) hwrev: P2A

(bootloader) radio: 5

(bootloader) storage-type: emmc

(bootloader) emmc: 16GB MICRON Q3J96R RV=08 PV=10 FV=0000000000000054

(bootloader) ram: 2GB MICRON LP3 DIE=8Gb M5=FF M6=01 M7=00 M8=1F

(bootloader) cpu: MSM8952

(bootloader) serialno: ZY22463HD4

(bootloader) cid: 0x0032

(bootloader) channelid: 0x1b

(bootloader) uid: D2176B0200000000000000000000

(bootloader) securestate: flashing_unlocked

(bootloader) iswarrantyvoid: yes

(bootloader) max-download-size: 536870912

(bootloader) reason: Reboot mode set to fastboot

(bootloader) imei: xxxxxxxxxxxxxxxxxx

(bootloader) meid:

(bootloader) date: 06-05-2017

(bootloader) sku: XT1621

(bootloader) battid: SNN5970A

(bootloader) iccid:

(bootloader) cust_md5:

(bootloader) max-sparse-size: 268435456

(bootloader) current-time: "Mon Jan 23 16:25:53 UTC 2017"

(bootloader) ro.build.fingerprint[0]: motorola/athene/athene:7.0/NPJS25.

(bootloader) ro.build.fingerprint[1]: 93-14-8.1-1/1:user/release-keys

(bootloader) ro.build.version.full[0]: Blur_Version.25.231.1.athene.reta

(bootloader) ro.build.version.full[1]: il.en.US

(bootloader) ro.build.version.qcom: LA.BR.1.3.6-01710-8976.0

(bootloader) version-baseband[0]: M8952_70030.25.03.62.01R ATHENE_LATAM_

(bootloader) version-baseband[1]: DSDS_CUST

(bootloader) kernel.version[0]: Linux version 3.10.84-gbee11f1 (hudsoncm

(bootloader) kernel.version[1]: [MENTION=387459]ilc[/MENTION]lbld35) (gcc version 4.8 (GCC) ) #1

(bootloader) kernel.version[2]: SMP PREEMPT Mon Aug 28 09:52:18 CDT 2017

(bootloader) sbl1.git: git=MBM-NG-VB1.06-0-g57d1343

(bootloader) rpm.git: git=MBM-NG-VB1.06-0-ga970ead

(bootloader) tz.git: git=69dd24b-dirty

(bootloader) hyp.git: git=69dd24b-dirty

(bootloader) keymaster.git: git=69dd24b-dirty

(bootloader) cmnlib.git: git=69dd24b-dirty

(bootloader) aboot.git: git=MBM-NG-VB1.06-0-g0edfb0d

(bootloader) qe: qe 0/0

(bootloader) frp-state: no protection (142)

(bootloader) ro.carrier: retla

all: listed above

finished. total time: 0.359s

C:\Users\Anoop>
[Moto G4 Plus Guides, News, & Discussion] sawless:
ROM Functionality Report

Just installed over my device and it's working well, my device model is: XT1626. That's it, friends! Good job :good: ;)
[Moto G4 Plus Guides, News, & Discussion] anoopgkris:
Downloaded this ROM and tried. Get the same preflash validation error on flashing gpt.bin partition.

C:\Anoop\Dev\MotoG4\AtheneNPJS25.93-14-8>fastboot flash partition gpt.bin

target reported max download size of 536870912 bytes

sending 'partition' (32 KB)...

OKAY [ 0.000s]

writing 'partition'...

(bootloader) Security version downgrade

(bootloader) Image primary_gpt failed validation

(bootloader) Preflash validation failed

FAILED (remote failure)

finished. total time: 0.063s
[Moto G4 Plus Guides, News, & Discussion] tomcat-:
Hi there,

I have gone from LineageOS with unlocked bootloader to stock ROM and locked bootloader flashing 25.93.14-13 from this thread on my XT1642

However when i attempt to go to recovery (power-volume down-recovery) it looks like i don't have a stock recovery and comes up as "no instruction"

would you know if i have to flash the stock recovery separately please?

Thanks for your help
[Moto G4 Plus Guides, News, & Discussion] echo92:
If you've locked your bootloader then you have to have the stock recovery, else your device would fail to boot.

By no instruction, do you mean 'no command' and a fallen android on the screen?

If so, that screen is normal, have a look at this thread on how to access the stock recovery when you're at that no command screen https://xdaforums.com/moto-g4-plus/help/command-stock-recovery-xt1642-t3484616
[Moto G4 Plus Guides, News, & Discussion] anoopgkris:
Seems like i went into murkier depths with this stock install thing :(

Looking at another post to install the blankflash i tried to uninstall the drivers for the Android device (Motorola ADB) that i was seeing in my Device Manager, since even the driver version was mentioned to look like 2.0.8.7. Mine was at 2.0.2 something.

Next problem was that now after connecting to with USB cable in fastboot the device shows up as "Fastboot athene_13mp S" (see attachment).

Even after reinstalling all drivers using the QUalcommdrv and Motorola device manager the drivers are just installed but the phone is not recognised.

Cannot now detect it using "fastboot devices". It just comes back blank.

C:\Users\Anoop>fastboot devices

C:\Users\Anoop>fastboot devices

C:\Users\Anoop>

Think i shouldn't have gone for the Android security update, don't remember seeing the date on it and it was all in Latin. Problems started after i rebooted in the Android Security updated after restoring to stock from TWRP.

This stock back up was taken on 27th December before going to Android 7.1.2.

Any inputs on what i can do on this one before i plan to show a to a service center?

At least on making the device show up in the fastboot commands.

I have the below working:

Bootloader

TWRP

Backups of stock Android 7.0 and 7.1.2

LineageOS versions 14.1 and 15 on External sdcard

Not working:

Device not detected in fastboot but it shows as connected on phone

Wipe using TWRP (shows mount errors for data and cache)

gpt.bin partition install

boot install
[Moto G4 Plus Guides, News, & Discussion] tomcat-:
Indeed it is no command, thanks for that I will try it
[Moto G4 Plus Guides, News, & Discussion] echo92:
1)Apologies about the incorrect firmware link, seeing your getvar all, you have the NPJS25.93-14-8.1 retla specific build, which has the same bootloader version and baseband version, but evidently is not compatible.

2)Did you use the blankflash? Having fastboot athene_13mp S suggests that the blankflash was used and that you have a basic bootloader, which is presenting itself to your computer as such. Try unplugging your device from your computer and connecting it again, see if it loads the drivers. If not, you may have to manually find the drivers, or try a computer reboot to see if that reloads the drivers.

EDIT - on my device, the Motorola ADB drivers are reporting as v2.0.2.

3)Any idea what build the OTA was? Unfortunately there seems to be little information on retla builds past the NPJS25.93-14-8.1 build.

You could try flashing the NPJS25.93-14-10 (Sept 2017 firmware) or the December 2017 NPJS25.93-14-13 firmware linked in the opening post, which appear to flash okay on XT1621 devices (and there's reports in this thread of that: https://xdaforums.com/showpost.php?p=75098107&postcount=518 ). This should be newer than what you have and may get your device running. However, due to the lack of information on retla devices, I do not know if flashing these Sept 2017 or Dec 2017 firmwares will keep you on the retla OTA update path. Just be careful.

September 2017 NPJS25.93-14-10 firmware is here: https://drive.google.com/file/d/0B9tngVBGIajVQkQtLUUxR2NOTnc

If you do flash either firmware, flash the GPT/bootloader as per the following commands, then you can opt to re-lock your bootloader as per the instructions in the opening post:

fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img
fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash dsp adspso.bin
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot erase userdata
fastboot reboot

Of course, this will delete your data, so ensure your backups are on your SD card and off your device. If your SD card is adopted as internal storage (and encrypted), back up your SD card as this process will likely erase the encryption key for the SD card, unless the encryption key is backed up as well.
[Moto G4 Plus Guides, News, & Discussion] anoopgkris:
I'd tried the blankflash yesterday but never saw the bat command loading the files to the phone. This was before the driver problem started. After that i couldn't further try any of the other relock commands.

No idea on what the OTA was but think i saw something like Dec mentioned somewhere on it.

I have both the Sep and Dec 17 ROM versions ready on my laptop, but now the fastboot is not recognizing the phone, phew!

Tried all kinds of install-uninstall-install, boot-reboot. Trying to find another PC to check.

---------- Post added at 10:39 AM ---------- Previous post was at 09:43 AM ----------

Hey, new update.

I reinstalled the fastboot (minimal adb fastboot) and finally found the phone connected as ADB device.

Then loaded the exact commands you mentioned above.

After the reboot command a smaller fallen android came up with a red exclamation with the title 'Error'. Thought that was the final straw, and i was having a brick on my table.

Held the power button down for about 10 seconds and it rebooted to stock MotoG4 OS!

Couldn't believe my eyes so rebooted it several times. Glad to hear that "Hello Moto" tone.

So maybe that blankflash and the latest version you mentioned above made things go ahead.

Thanks a lot! I appreciate all your help. Finally got the nice moto camera working.

All the other cameras on the modded ROMs were not at all fast to use.

Some more questions. I did not lock the bootloader in the command above. What more command can i run now to lock it now?

Do i need to follow all the commands again including the oem lock?

Can i lose the no-trust error screen on doing the lock (doesn't look very nice) ?

Will i get all OTAs after that? And is it safe to go with that?
[Moto G4 Plus Guides, News, & Discussion] anoopgkris:
Thank you for the very detailed explanation. This has been very helpful from the start. I think I'll then keep the bootloader unlocked so that i can go back to any of the really good ROMs out there.

Reading the thing about the blankflash was also interesting ;)
[Moto G4 Plus Guides, News, & Discussion] rohitrockon17:
Any way to get the signed version of boot.img from this ROM? I am currently on this ROM however when I try to re-lock my Bootloader, it says signed boot.img required.

Thanks in advance!

Update: Re-flashed the ROM again with the re-lock commands and it went through successfully this time :)

So I'm good here.
[Moto G4 Plus Guides, News, & Discussion] echo92:
Oh, XT1642 can be added to the list in the opening post - flashed the firmware (including GPT and bootloader, as I was upgrading) with no issues over NPJ25.93-14 (Dec 2016)

Then proceeded to root with ElementalX/magisk :)
[Moto G4 Plus Guides, News, & Discussion] Shonilchi:
[MENTION=7682274]TywinnLannister[/MENTION]7 Whats the difference between this and your Revivor 2.0 ROM - https://xdaforums.com/moto-g4-plus/development/rom-npjs25-93-14-4-deodexed-debloated-t3587180 Sorry, if i dont understand. The title states fastboot version - so is this the same stock ROM that can be flashed via fastboot instead of TWRP? Could you please clarify?
[Moto G4 Plus Guides, News, & Discussion] lCrD512:
ReviverOS is an optimized or modified version of the same NPJS25.93-14-4. Reviver can be flashed through TWRP. For these 93-14-4 stock images you'll have to use the fastboot method.:)
[Moto G4 Plus Guides, News, & Discussion] Sharp404:
Which one is better ??!! :victory:
[Moto G4 Plus Guides, News, & Discussion] ivan290:
So? Did you fix the lag??
[Moto G4 Plus Guides, News, & Discussion] Sharp404:
Hello X D I A N S

Currently I am in Resurrection Remix latest build by [MENTION=2614020]jeel[/MENTION]blanch...Thinking about reverting to stock nougat..Please conform the steps I.e is it right approach or not..

Step 1 : WIPE everything from TWRP,

Step 2: ADB and fastboot setup and following steps given in OP

This way no lag will appear and seamlessly use Nougat...

Please conform these steps

Thanks
[Moto G4 Plus Guides, News, & Discussion] rajatgupta1998:
The wiping will be done automatically by the fastboot method... No need to do it in TWRP.