[Moto G5 Guides, News, & Discussion] TheFixItMan:
This guide is for hard bricked Moto G5 Cedric

Hard bricked means a device which can not enter bootloader mode normally

This method has now been confirmed working

Works with XT1672 XT1670 XT1671 XT1675 XT1676 XT1677 (and most likely all others and if you ask if it will work on your version I will just copy & paste this to you!)

Smaller Image

Thanks to Luka Panio, Omega, and nift4 we now have a smaller image size

Goto This github page and under assets download mmcblk0.img.gz

Extract mmcblk0.img from the zip file to PC

Previous Larger Images

Mega

Download mmcblk0.zip image from Mega

Create your own mega account and import the file into your mega account. Log into your account and download it from your own account

Extract mmcblk0.img from mmcblk0.zip to PC

Or for those of you who can't use mega or have unstable Internet I've split the large file size into smaller multiple zip files. You must download each part and then extract using an unzip tool like winrar or 7zip

Android File Host

Download mmcblk0.zip mmcblk0-part1.zip and mmcblk0-part2.zip from Android File Host

Extract mmcblk0.z01 from mmcblk0-part1.zip

Extract mmcblk0.z02 from mmcblk0-part2.zip

Extract mmcblk0.img from mmcblk0.zip (If prompted point to mmcblk0.z01 and mmcblk0.z02 but it shouldn't ask if all files are in the same folder)

Requirements

Freshly formatted microSD card 16gb if using the smaller image or at least 32gb if using the previous larger images (It needs to have at least 31.3gb free after formatting - if it displays as less you will need to buy a 64gb microSD card or use the smaller image)

7zip

Linux mint live usb/dvd

USB card reader

Method

The BEST method to flash the sdcard with mmcbk0.img file is to use LINUX!

Windows users have no need to install Linux on their PC, you can run Linux from a bootable usb-stick that is at least 8gb or a dvd

Do not run Linux as a virtual machine on Windows! Use the live USB/DVD

0) Put the Moto g5 on mains charge until you have finished flashing the sdcard so it's fully charged ready for the boot test!

1) Run Linux, preferably cinnamon or mate versions of Linux Mint

2) Insert the sdcard in pc or card reader and open "Disks" app

3) In "Disks" app select sdcard and you will see the sdcard partitions

4) Press "-" to delete the partition (delete all partitions if there is more than one)

5) Press "+" to create a new one and name it mmcblk0, set FAT(FAT32) file format and press "CREATE"

6) Press "Play" button to mount the sdcard, look to see what path the sdcard has (/dev/sd??) and then close the "Disks" app

7) Go to Desktop, open "Computer" and navigate to the location where the img file is extracted (mmcblk0.img)

8) Open the window where img file is with root (right click on window and select "open as root")

9) In root window open the Terminal (right click on window and select "open terminal")

no need to type "su" in terminal, it has root already (see notes if using Linux live usb/dvd)

10) Type in terminal the command written below and don't forget to eliminate that "1" from the sdcard path,

that "1" can make the difference between the phone booting or not!!!!!

Things to note

Linux Live dvd doesn't have open as root so just open in terminal and add sudo to the start of the commands

I've included this in the commands below

If you get a status error just remove status=progress from the terminal command below

Terminal comands

- if your sdcard is seen like " /dev/sdb1"

in terminal apply this command:

sudo dd bs=4M if=mmcblk0.img of=/dev/sdb status=progress oflag=sync

-if your sdcard is seen like " /dev/mmcblk0p1"

in terminal apply this command:

sudo dd bs=4M if=mmcblk0.img of=/dev/mmcblk0 status=progress oflag=sync

and the flashing process should start

When it finishes, test the sdcard in the phone and it should boot!

If you get a size error of the sdcard in terminal you have to change the sdcard and try again!

Thanks to @vaserbanix for the original version of this guide

Re-flash Stock Firmware

Once the phone is in bootloader mode you can flash stock firmware via fastboot

Note that in order to flash gpt the firmware MUST be the same or newer than the version currently on your phone

Firmware can be download from Here

Once you have firmware that is the same or newer than your current version you can remove the sd card and run these commands (assuming you have fastboot all setup on your pc)

If you get a security downgrade error when you try to flash gpt.bin or bootloader.img then the firmware you are trying to flash is too old!

fastboot oem fb_mode_set
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 system system.img_sparsechunk.8
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot erase userdata
fastboot oem fb_mode_clear
fastboot reboot