The day is upon us. Android 6.0 Marshmallow has graced us with its presence, introducing features like Doze, native fingerprint support and Now on Tap. While you can wait for the OTA update, Google has released the factory images for its latest Nexus devices, allowing us to flash the software manually instead. While most Android geeks will know what to do, not everyone is familiar with a .tgz. Don’t worry, we’ve made a video detailing how to flash stock Android on your Nexus device.
Computer Set Up
First things first: we’re going need to head to the Google factory image page and grab the appropriate download for your device. In this case, I’m flashing my Nexus 6, so I’ll grab the Marshmallow build for Shamu.
While we’re at it, let’s also go download the Android SDK. If you already have Fastboot and ADB set up on your computer, you can skip this step. If I’m speaking jibberish to you, pay attention. ADB is the Android Debug Bridge. It allows you to run commands on your device from your computer. Fastboot allows you to do the same, but while your device is in Fastboot mode. This allows you to flash, or install, new software on your device’s partitions while it’s actually running.
Once you’ve downloaded the SDK, we’ll need to run the ‘android’ executable located in the platform tools folder. From here, we’ll select the most recent SDK and tools. If you’re on a Mac and you upgraded from Mavericks to Yosemite, you may need to download the Java runtime from Apple. Without this patch, the Android executable may not work.
Device Set Up
While that’s all downloading, let’s make sure our device is ready to go. Go ahead and head into your Settings, tap on About, and tap on the build number until you become a developer. Congratulations! Now you can develop apps. Just kidding, this just enables the developer options. Head into the developer options and verify that USB debugging is enabled.
Okay, grab a USB cable and plug that sucker into your computer. Now, I’m going to be doing this on a Mac, but you can absolutely do this on a PC as well. You just need the right drivers, and you can omit the ./ at the beginning of the commands that we’ll get to in just a minute.
Pop open Terminal or a shell prompt if you’re on Windows. If this is where you get a little light headed, stay calm. This isn’t terribly hard, and if you’ve never done it before it’ll be a great learning experience for you. Just follow the instructions, and you’ll be running Marshmallow in no time.
While you can install ADB and Fastboot on your computer, we’re doing to do it the harder way here. It’s important to learn what you’re doing so you don’t brick your device. All your computer is doing is issuing terminal commands. We’re just cutting out the middleman here. While we’re not going to install ADB and Fastboot, let’s at least make our lives a little easier.
In Finder, move your new Android SDK folder to your applications folder. Then, make a new folder on your desktop. Call it anything you like. Here, we’ll call it Marshmallow. Move your stock image into it, then open up your Android SDK folder and copy ADB and Fastboot to your Marshmallow folder.
Now we need to make sure Terminal is looking at the right folder. So, in your prompt, type:
CD will change the directory. Now let’s make sure we’re looking in the folder. Type:
ls is a unix command that will list the files in the current directory. If you see your image, adb & fastboot, you did it! Great job! Almost there. Now that we know we’re in the right place, let’s make sure our computer can see our device. Type:
If the computer can see your phone, you’ll see a device in this list. If not, make sure you’re running the correct drivers on windows, and that USB debugging is turned on on your device. If you see the device, let’s move on.
Now, decompress the .tgz file and you’ll find: a bootloader image, flashing scripts, the update image, and the radio image.
Go ahead and shut off your device. While off, boot it into Fastboot mode by pushing and holding the volume down and power buttons until you see the Android with his belly open.
Ignore the flash files in the folder that got decompressed. We’re going to flash these one by one. From here, we’ll be dragging files into the terminal window for ease of use.
First, we’ll need to make sure your bootloader is unlocked. If it isn’t, this command will unlock it and wipe your device in the process. On your device’s screen, check on the bottom. If it says device is UNLOCKED, you can skip this step.
Making sure that your terminal window is always pointing at the Marshmallow folder, type:
./fastboot oem unlock
After each command, we’ll reboot the bootloader by typing:
You can get to this command quickly by accessing your previous commands in terminal by pushing the up arrow.
First, we’ll flash the bootloader:
./fastboot flash bootloader /Users/YOURUSER/Desktop/Marshmallow/shamu-mra58k/bootloader-shamu-moto-apq8084-71.15.img
Next up, we’ll flash the radio:
./fastboot flash radio /Users/MarkB/Desktop/Marshmallow/shamu-mra58k/radio-shamu-d4.01-9625-05.27+fsg-9625-02.104.img
Now we’ll flash recovery type:
./fastboot flash recovery /Users/YOURUSER/Desktop/Marshmallow/shamu-mra58k/image-shamu-mra58k/recovery.img
You can also drag the file in as I mentioned from the decompressed image folder.
Now we’ll flash the boot partition:
./fastboot flash boot /Users/YOURUSER/Desktop/Marshmallow/shamu-mra58k/image-shamu-mra58k/boot.img
Finally, we’ll flash the system:
./fastboot flash system /Users/YOURUSER/Desktop/Marshmallow/shamu-mra58k/image-shamu-mra58k/system.img
You can see all the things Fastboot can do by just running ./fastboot without any other commands. We didn’t wipe the device, so if you want to do a ‘dirty’ install, this will keep your data. If you want to wipe your device, just append a -w before the command that you want to wipe the contents of the partition for. For example, let’s wipe our device’s system and userdata before we flash a new version of Android. Just remember, this will wipe your device clean.
./fastboot erase userdata
./fastboot -w flash system /Users/YOURUSER/Desktop/Marshmallow/shamu-mra58k/image-shamu-mra58k/system.img
You’re all done! Now just type:
And enjoy your new sweet treat. It will take a while to boot the first time, but don’t worry. It’s doing some work under the hood. If it gets stuck at the boot screen, wipe everything clean using what you’ve learned and try again and make sure to follow the steps.
If you’re interested in learning more about the command line, I highly recommend checking out the Command Line Crash Course by Zed Shaw. It’s totally free and you’ll feel more prepared the next time you’re looking to flash stock Android or a custom ROM.