How to Flash Factory Image on Any Nexus Device to Return to Stock for Windows and Mac
Google has released the Android 4.4 KitKat factory images for Nexus 4, Nexus 7 both 2012 and 2013 and the Nexus 10. The factory images can reset your Nexus handset and put it back to stock. Factory images are available for download since the day the device was up for sale on the Play Store.
If you have flashed a custom ROM or have rooted your Nexus device and simply want to go back completely to stock, you can follow the step-by-step guide below. This process will wipe out any data on your Nexus so make sure to backup. You will also need to have an unlocked bootloader to flash a factory image.
Step 1: Download the ADB/Fastboot files and USB drivers for a Windows based PC. The most recent factory image for Nexus devices can be downloaded directly from Google's website.
- ADB/Fastboot - Mac, Windows
- USB drivers for Windows
Extract the contents of the ZIP file ADB/Fastboot inside a new folder named "Google" on the desktop. Extract and transfer the factory image contents inside this folder, too. The list of files include a ZIP file that contains two files named "flash-all," the codename of your Android device and a bootloader image file. The extracted contents of this factory image will be inside the same folder as the Fastboot and ADB file - if not, you will get a "file not found" error. Install the ADB drivers if you are running a Windows based computer.
Step 2: Reboot the Nexus device in bootloader mode. Do this by switching off your device and simultaneously pressing the volume down - volume up - power button. If it doesn't work, try the power button - volume down combination.
Connect your device to the computer after it has booted into bootloader mode.
Step 3: Open a new command prompt or terminal window and navigate to the "Google" folder you created in Step 1. Make sure your Nexus device is detected by the PC before you start flashing the factory image.
fastboot devices
If you use a Mac, you need to prefix a "./" before each fastboot command. The above command will look like this on a Mac:
./fastboot devices
This command will confirm your device is detected by the computer or not. If it is, proceed to the following steps. If not, repeat the abovementioned steps. Make sure you have installed the drivers properly and all are inside the right folder.
Copy paste the following command in the command prompt window: flash-all.bat
On a Mac, it should look like this: ./flash-all.sh
The script will flash the full factory image automatically on your Nexus device. Once the factory image is fully flashed, the device will reboot automatically. The first boot will take some time so be patient.
The flash-all script in the factory image might not work for everyone. If it doesn't work for you, you need to flash each partition manually on the device.
The command to manually flash a partition through flashboot is "fastboot flash partition filename.img." In Step 1, the factory image you extracted will have another ZIP file. Extract all contents of the ZIP file inside the "Google" folder.
To manually flash the partition to the Nexus device, start with the bootloader.
fastboot flash partition filename.img
Then flash all other partitions. No need to be in the same order and the image file names in the factory image will indicate the partition they are intended for.
fastboot flash boot filename.img
fastboot flash radio filename.img
fastboot flash recovery filename.img
fastboot flash userdata filename.img
fastboot flash system filename.img
To relock the bootloader of the device after flashing it, put the device in fastboot more then type the following command in command or terminal window you had opened earlier:
Fastboot oem lock
This should re-lock the bootloader of the Nexus device, restoring warranty and putting the device back completely to stock.