[Moto G5 Questions & Answers] mattwhite7102:
WARNING: DO NOT FLASH THE GPT.BIN OR THE BOOTLOADER.IMG/MOTOBOOT.IMG ON A NEWER FIRMWARE WHEN DOWNGRADING, BECAUSE IT CAN HARD BRICK YOUR DEVICE E.G. DO NOT FLASH THE GPT.BIN OR THE BOOTLOADER.IMG/MOTOBOOT.IMG MADE FOR 7.0 ON 8.1.0 EVEN IF THE FILES IN THE FOLDER BUT ITS FINE IF YOU FLASH THE SAME FILES MADE FOR ANDROID 8.1.0 AVOID FLASHING THESE FILES AT ALL TIMES

I AM NOT RESPONSIBLE FOR ANY DAMAGE CAUSED TO YOUR DEVICE, DO THIS AT YOUR OWN RISK

so a little backstory,

i unlocked my bootloader because i wanted to downgrade back to android 7.0, and then my imei broke on me, so i attempted to upgrade back to android 8.1.0 but then everytime i rebooted my phone i see;

"your device is unlocked and cant be trusted

ID: bad key

your device will reboot in 5 seconds"

then would just loop into the bootloader

and when flashing the logo back it will just say "bad key" when editing logo.bin (changing the logo_unlocked to logo_boot)

with this guide i will tell you how to revert your device back to OOB state (OOB means out of box for all those idiots out there :rolleyes:)

THIS WAS TESTED ON MY XT1675 IT WILL BE DIFFERENT FOR EACH DEVICE

1) grab your stock firmware, for me its "XT1675_CEDRIC_RETGB_SS_8.1.0_OPP28.85-19-4-2_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml"

2) install minimal ADB and fastboot

3) then once you installed the adb and fastboot drivers we are really just focusing on the fastboot.exe, i will be linking the platform-tools at the bottom of this post

4) extract the firmware to a place and make sure there are no spaces (e.g. C:/Users/Example/Desktop/moto g5 downgrade otherwise cmd will assume its another path to another folder)

5) the most important file is oem.img because this is the signed file by motorola that we will need to relock the bootloader but it should come in the firmware folder, if not PM me and will try my best to find the matching oem.img

6) once you get all your files type these commands to reload the firmware onto the device

fastboot flash gpt gpt.bin

fastboot flash bootloader bootloader.img

fastboot flash dsp adspso.bin

fastboot flash logo logo.bin

fastboot flash boot boot.img

fastboot flash recovery recovery.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 system system.img_sparsechunk.8

fastboot erase modemst1

fastboot erase modemst2

fastboot flash fsg fsg.mbn

fastboot erase cache

fastboot erase userdata

fastboot reboot

what you will find now is it will at least boot into the setup screen

we are not done yet!

7) now if you reboot into the bootloader screen the options will be seriously messed up (they will overlap if you press up and down on the volume keys, i think this tells motorola that you tampered with your device)

8) now still on the bootloader screen connect up your device with cmd still open, then type these commands

fastboot oem lock

fastboot oem lock (you have to type it twice)

fastboot flash oem oem.img (you need this to relock the bootloader)

fastboot flash gpt gpt.bin

fastboot flash bootloader bootloader.img

fastboot flash recovery recovery.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 system system.img_sparsechunk.8

fastboot flash boot boot.img

fastboot oem lock

now it will say (lock complete! flash signed images after reboot if needed)

type in

fastboot reboot

now when you reboot your device you will get a black screen then it will show the motorola logo, to fix this go into the bootloader mode and reflash your original bootlogo

you got your device up and running like it did OOB!

LINKS:

Minimal adb and fastboot: https://xdaforums.com/showthread.php?t=2317790

platform tools: https://developer.android.com/studio/releases/platform-tools

if your getting "image signed with key bad key when flashing the boot.img and the recovery.img, i found this really helpful tutorial, just do not flash the files on the G5, this is made for the G5 plus but the bootloader commands works for the G5 as well as the G5 plus

Link: https://xdaforums.com/g5-plus/how-to/solution-to-flash-stock-romfactory-t3691396

also if you get "still requires signed system.img and/or boot.img flash all the system sparsechunk files