Manually installing an OTA update for the Nexus 5x

In theory, your device should automatically check for an OTA (over-the-air) update, download it in the background, and then prompt you to install the update. No matter how much I manually checked, my device kept insisting it was up to date (I know Google likes to do staggered automatic rollouts, but it's just annoying when I manually initiate a check and Google still insists on not giving me the update).

These are just slightly more detailed step-by-step instructions based on Android 6.0.1 Marshmallow OTA Links for Sideloading. This GitHub page has a list of OTA updates for Nexus devices. Find the download for your device. I'm using my device (Nexus 5x) as an example. In theory, the instructions should be very similar for other Nexus devices.

Find your device's build number

There are two different 6.0 builds for the Nexus 5x (MDB08L and MDB08M). To find out which one was mine, I had to go to Settings > About phone > Build number to find out my build was MDB08L.

For the U.S. version of the Nexus 5x, the upgrade is MHC19J from MMB29Q.

Enable USB debugging

While you're in the About phone section, tap the Build number and keep tapping it until you get a notification that developer options are now enabled. Then go to Settings > Developer options and scroll down until you get to USB debugging and tap the toggle next to it to enable it.

Get the Android SDK

Google used to have an easy-to-find SDK download link. Now it points you to Android Studio instead, which you can use to install the SDK using SDK Manager if you go to Tools > Android > SDK Manager. You may, somewhere on the Android developer website be able to track down a standalone SDK download if you dig around enough.

It took me a while to find exactly where the SDK installed to. Eventually, I found it it was installed to /Users/username/Library/Android/sdk/platform-tools (I'm using a Mac—it's probably a similar path for Windows, maybe in /Users/username/AppData?).

Do the actual flashing of the OTA

Disclaimer: Uh, these instructions worked for me, but absolutely this is at your own risk. I'm not at all responsible (nor is the person who wrote the tutorial on which this is based) for any damage you might do to your device.

Open up a terminal (again, I'm using a Mac, so it's in /Applications/Utilities/; if you're using Windows, find cmd.exe and launch that up instead).

At this point, plug your device into your computer using a USB cable. You may have to switch to PTP mode to get it to work.

Change directories to where adb is:

cd /Users/username/Library/Android/sdk/platform-tools
Substitute in your actual username for username. And don't forget you can use the Tab key to autocomplete directory names instead of manually typing out the full path.

Make sure your device shows up in the list of devices:

./adb devices

Reboot to the bootloader:

./adb reboot bootloader
Use the volume down key to focus on Recovery. Once that's in focus, press the power button to select it.

You'll see what looks like an error and a dead Android lying on its back. Press the volume up key and power buttons at the same time until you get to a list of menu options.

Use the volume down key until you get Apply update from ADB into focus. Then press the power button to select it.

You should then see a message that says Now send the package you want to apply to the device with "adb sideload ."

Back on your computer, enter a command similar to this one (again, Tab completion is your friend—you don't want to manually retype the full filename of the OTA update you downloaded:

./adb sideload ~/Downloads/

You'll then see output similar to this in the terminal on your computer:

''/Users/username/Downloads/f67821b18f5a3bc6552039f0997fc9511f05c2c3.signed-Total xfer: 2.12x
with little progress percentages going up along the way.

Meanwhile, on your phone/Android device, you'll see output similar to this:

Finding update package...
Opening update package...
Verifying update package...
Installing update...
Source: google/bullhead/bullhead:6.0/MMB29Q/#######:user/release-keys
Target: google/bullhead/bullhead:6.0.1/MHC19J/#######:user/release-keys
Verifying current system...
Verified system image...
Verified vendor image...
Patching system image after verification.
Verifying the updated system image...
Verified the updated system image.
Patching vendor image after verification.
Verifying the updated vendor image...
Verified the updated vendor image.
Patching the boot image...
Writing bootloader...
Patching radio...
script succeeded: result was [1.000000]

Install from ADB complete.

When that's done, use the volume up key to highlight Reboot system now and then press the power button to select it.

After your device reboots, you should see something like Android is upgrading...
Optimising app # of 66

That's it! Your update should now be installed.


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.

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/ and type in
    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.

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