Categories
Uncategorized

Unrooting (returning to stock) the Moto X 2013

Some Background

I did my first proper unroot of my Moto X 2013 recently, and I learned something interesting in the process. In the past, when I've rooted and unrooted my Moto X 2013, I'd request/download the factory image straight from the Motorola website and restore that back.

unsuccessful
Recently, though, I tried to take an OTA (over-the-air) update from Motorola, and it would download the update, try to install the update, and then error out. I'd then get a message about how the update was unsuccessful. I tried reflashing the recovery and the system. Reflashing everything, clearing the cache, clearing the user data. The OTA update (from Motorola, mind you) did not like the factory image from Motorola's website.

The only way I could get it to work (big shoutout to mastarifla from the XDA forums for the tip) was downloading a factory image from a third-party website. Then the OTA update (from Motorola) liked it and installed the update successfully. Go figure.

Some of you all may be skeptical about downloading "factory images" frmo third-party websites, and that's fine, but this was the only one that I could get an official OTA from Motorola to install on properly. Your mileage may vary.

Prerequisites and Files to Download

Before you begin, make sure you do the following:

  1. Back up any important data—either to the Cloud or your computer's hard drive or both. This includes but isn't limited to photos, music, apps, bookmarks.
  2. Download the appropriate moto-fastboot files for your operating system from the first post in this thread. For some reason, the regular fastboot can't do some of the larger files, so a special moto-fastboot has to be used.
  3. Download the appropriate factory build files for your model of Moto X.

Note for Windows users

I don't use Windows, but I've heard that you can use RSD Lite to restore the phone instead of running the commands below. Unfortunately, I can't walk you through those steps. You can find details here.

Actual Steps

I'm basing these off of what I did on Mac OS X. There's a terminal in Windows and one in Linux, too, so similar principles will apply, but the exact steps may be slightly different.

  1. Once the factory build is downloaded, double-click it to unzip it.
  2. Move the unzipped moto-fastboot file into the unzipped folder. For Macs, that would be moto-fastboot-x64.
  3. Open up the /Applications/Utilities/Terminal.app and type in
    cd
    with a space at the end
  4. Drag the factory build unzipped folder to the terminal, and then hit Enter. Your terminal should now be focused on that directory.
  5. With your phone unplugged, hold down the power button until it prompts you to power off. Then power it off when prompted.
  6. While holding the volume-down key, tap the power button and wait for it to boot up. It should boot into something called "fastboot mode" with a black screen and some colored text.
  7. Keeping the phone in fastboot mode, connect it to your computer via USB.
  8. Run the following commands (note: it may be better to copy and paste them one by one than to do them all at once in a script or to retype them manually).
    ./moto-fastboot-osx64 erase cache
    ./moto-fastboot-osx64 erase userdata
    ./moto-fastboot-osx64 flash partition gpt.bin
    ./moto-fastboot-osx64 flash motoboot motoboot.img
    ./moto-fastboot-osx64 flash logo logo.bin
    ./moto-fastboot-osx64 flash motoboot motoboot.img
    ./moto-fastboot-osx64 flash logo logo.bin
    ./moto-fastboot-osx64 flash boot boot.img
    ./moto-fastboot-osx64 flash recovery recovery.img
    ./moto-fastboot-osx64 flash system system.img
    ./moto-fastboot-osx64 flash modem NON-HLOS.bin
    ./moto-fastboot-osx64 erase modemst1
    ./moto-fastboot-osx64 erase modemst2
    ./moto-fastboot-osx64 flash fsg fsg.mbn
    ./moto-fastboot-osx64 erase customize
    ./moto-fastboot-osx64 erase clogo
    ./moto-fastboot-osx64 oem fb_mode_clear

It's possible that erasing userdata may not be necessary. More details in XT1053 222.27.5 Stagefright OTA Update Guide.

successful
After that, when you reboot your Moto X, it should be back to factory settings and able to take OTA updates.

Categories
Uncategorized

Installing a custom rom on an unlocked Moto X 2013

I've been rooting and installing custom roms on Android phones since 2009. In general, it's been a fairly standard procedure. With the Moto X 2013 (and this may apply to the 2014 as well—I don't know—I can vouch only for the 2013), the procedure is slightly different.

Unlock bootloader
Get Motorola's fastboot
Get TWRP
Get the custom rom you want
Flash TWRP recovery to phone
Flashing the rom (and Google Apps)

Unlock bootloader

Go to the Motorola website to request to unlock your phone's bootloader. If you got a phone not locked to a carrier, there should be no issue with this.

The first time you unlock your bootloader, it will erase everything on your phone. Back up important stuff before you unlock the bootloader!

Get Motorola's fastboot

I'm not sure why, but apparently Motorola has its own fastboot, so you're supposed to use that one instead of the regular fastboot you'd find in the Android SDK (Google has also switched things up so if you go to get the Android SDK, you'll get an Android IDE app instead of just the raw files).

The weird thing is it's very difficult to find this Moto Fastboot anywhere on the Motorola website. I've found it only via third parties.

Here you can find a link to the Mac version.

And here you can find a link to the Windows version.

I wasn't able to track down Linux versions, but they supposedly exist.

Get TWRP

Next, you want to download the TWRP (Team Win Recovery Project) recovery for the Moto X 2013 (codenamed ghost). You can find the latest version on the TWRP website.

Get the custom rom you want

For this example, I'm going to recommend the Nexus Experience, but you can pick whatever rom you want. Unless you know you don't want Google Apps, be sure to download not just the rom but also the Google Apps .zip.

So one file should look something like Android5.1.1_NX_R9.4_MotoX2013.zip and another something like NX-GAPPS_L_Release3.3_Full.zip.

Plug your phone into your computer, and then copy those two files to the top-level /sdcard directory on your phone.

Flash TWRP recovery to phone

I'm sure there's a Windows equivalent for this using DOS, but I've done this only on a Mac, so I'm not 100% sure on the Windows procedure.

For Mac, put the TWRP file (something like twrp-2.8.6.0-ghost.img) in the same directory as your moto-fastboot-osx64 file (may be slightly different for Windows and Linux users, of course). For simplicity's sake, rename the TWRP file to be twrp.img.

Turn your Moto X 2013 off. Unplug it from your computer. Then, while holding the volume-down button down, press the power button. Don't let go of the volume-down button until your phone boots into fastboot mode.

Then, plug your phone back into your computer via USB.

In the Terminal.app (similar but different for Windows and Linux), navigate to the directory where your moto fastboot and twrp .img files are. If you don't know how to do that, type cd in the terminal (with a space after it), and then drag the folder over to the terminal. Then hit Enter.

Then, run the commands

./moto-fastboot-osx64 flash recovery twrp.img

Flashing the rom (and Google Apps)

You should still be at the fastboot screen, press the volume-down button once to highlight Recovery, and then press the volume-up button once to select it.

You should then see the teamwin logo.

After that, you'll get some touch-screen options.

First, select Wipe to wipe your current installation (you already backed up before unlocking the bootloader, right?). Then do a swipe to factory reset.

Once you're done, hit the back button to go back to the main menu. Next, select Install. Find your main rom (e.g., Android5.1.1_NX_R9.4_MotoX2013.zip) and flash that.

Go back to Install and flash Google Apps if you want (e.g., NX-GAPPS_L_Release3.3_Full.zip). If you don't know if you want Google Apps, flash it, just to be safe.

Then, go back to the main menu and select Reboot and then System.

It may take a while for your rom to boot up the first time, but then you're all set to use your custom rooted rom!