Carlos Spitzer bio photo

Carlos Spitzer

Senior Consultant at Red Hat

Email Twitter Facebook Google+ LinkedIn Github

Recently I was “unbricking” my brother in law moto G device. I wondered how to recover the Moto G factory stock image and I found several posts with partial information. So I decided to publish one with the entire stock information :-)

First you should find out which device version you have and download the right stock ROM Also, you should have the fastboot application installed on your linux OS. How to do it? Installing “android-tools” package, easy:

$  yum info android-tools
Loaded plugins: langpacks, refresh-packagekit
Installed Packages
Name : android-tools
Arch : x86_64
Version : 20130123git98d0789
Release : 2.fc20
Size : 297 k
Repo : installed
From repo : fedora
Summary : Android platform tools(adb, fastboot)
URL : http://developer.android.com/guide/developing/tools/
License : ASL 2.0 and (ASL 2.0 and BSD)
Description :
: The Android Debug Bridge (ADB) is used to:
:
: - keep track of all Android devices and emulators instances
: connected to or running on a given host developer machine
:
: - implement various control commands (e.g. "adb shell", "adb pull", etc.)
: for the benefit of clients (command-line users, or helper programs like
: DDMS). These commands are what is called a 'service' in ADB.
:
: Fastboot is used to manipulate the flash partitions of the Android phone.
: It can also boot the phone using a kernel image or root filesystem image
: which reside on the host machine rather than in the phone flash.
: In order to use it, it is important to understand the flash partition
: layout for the phone.
: The fastboot program works in conjunction with firmware on the phone
: to read and write the flash partitions. It needs the same USB device
: setup between the host and the target phone as adb.

Then, you must put the following script in the same un-zip’ed stock image folder:

#!/bin/bash

# Author: Carlos Spitzer (me@carlos-spitzer.com)

# First you must download Stock images here: http://www.filefactory.com/folder/c6cdedc45a775d27
echo ">>>>>> Repartitioning..."
fastboot flash partition gpt.bin
fastboot flash motoboot motoboot.img
fastboot flash logo logo.bin
fastboot flash boot boot.img
echo
echo
echo ">>>>>> Installing recovery..."
fastboot flash recovery recovery.img
echo
echo
echo ">>>>>> Formating...."
for file in $(ls ./system.img*); do fastboot flash system $file; done
echo
echo
echo ">>>>>> Flashing modem...."
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
echo
echo
echo "Erasing cache & user data...."
fastboot erase cache
fastboot erase userdata
echo
fastboot reboot

Finally, execute it and let the magic flows…