[Moto G Q&A, Help & Troubleshooting] elmimmo:
My Moto G 1st Gen 2013 (XT1032) is stuck at the first boot screen even after wiping user data and reflashing it with stock firmware.

It was an untampered model (non-rooted, with “Status Code: 0” factory-locked bootloader, no-carrier, non-SIM-locked), with whatever latest OTA update Motorola ever shipped (Lollipop, I believe), officially updated all the way from whatever the first Moto Gs sold at Amazon.es shipped with—4.something. Out of the blue, one day it rebooted and stayed in the screen with the blue marble with an M on it.

To fix it, I have repeatedly tried:

wiping the cache

wiping user data

unlocking the bootloader

reflashing stock 4.4.4, 5.0.2 and 5.1

wiping cache + user data yet again

All those tasks complete without seemingly meaningful errors, but after that the phone will still just light up into, now, the “warning bootloader unlocked” screen and just stay there. If, from Recovery, I power down while connected to the computer by USB, it will restart into what will be now be a flat-color version of the circled M with “Powered by Android” below it, but still stay there. Force-restarting it, will bring back the “warning…” screen, and not get past that just as well. I've left it there for hours, both the first time it got stuck on the blue marble screen and with the other two startup screens.

The specific firmwares I tried were:

RETAIL_XT1032_4.4.4_KXB21.14-L1.61_cid9_CFC.xml.zip

XT1032_FALCON-RETEU_5.0.2_LXB22.46-28.1_1_cid7_CFC_1FF.xml.zip

XT1032_FALCON_RETEU_5.1_LPBS23.13-56-2_cid7_CFC.xml.zip

I flashed those firmwares by booting into Fastboot Flash mode. I got fastboot on Mac OS X 10.10 by installing Homebrew and running brew install android-platform-tools.

As per each firmware's XML file, these are the commands I used to flash, for instance, stock-5.0.2:

fastboot flash partition gpt.bin
fastboot flash motoboot motoboot.img
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 modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot erase userdata

and these for stock-5.1:

fastboot getvar max-sparse-size
fastboot oem fb_mode_set
fastboot flash partition gpt.bin
fastboot flash motoboot motoboot.img
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 modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot oem fb_mode_clear

After flashing, I re-wiped cache and user data by booting into Fastboot mode again, from there going to Recovery, and there chosing wipe data/factory reset.

What else can I attempt? How can I even attempt to diagnose what is wrong at all?

EDIT: Just tried reflashing 5.1 for the 25th time, this time using mfastboot instead of fastboot (downloaded from the thread at Moto G General [GUIDE] Moto G - Restore stock firmware, linked as mfastboot-v2.zip and actually named osx-fastboot when uncompressed). After rebooting into the “warning…” screen and leaving it there for some minutes, it changed into the animated blue marble M logo (with concentric waves as like from water drops) and finally booted into the “Welcome” wizard!