• First of all, download factory image for your nexus device from here
  • Step 1: Download the ADB/Fastboot files and the USB drivers for Windows based PC first.
    • Extract the contents of the ADB/Faew folder called ‘google’ on your desktop. Extract and transfer the contents of the factory image inside this folder as well. The list of files will include a ZIP file containing the codename of your Android device, two files with “flash-all” names, and a bootloader image file. All the extracted contents of the factory image should be inside the same folder as the ADB and Fastboot file, otherwise you will get a file not found error.
    • Make sure to install the ADB drivers as well if you are running a Windows based PC.

  • Step 2: Now, reboot your Nexus device in bootloader mode. This is usually done by switching off the device, and pressing the Volume down + Volume Up + Power button simultaneously. If that does not work, try the Volume down + Power button combination. After the device has booted into bootloader mode, connect it to your PC.
  • Step 3: Open a new Terminal or Command Prompt window, and navigate to the ‘google’ folder that you created in Step 1. Before we start flashing the factory image, we need to make sure that your Nexus device is being detected by the PC.
    • Execute this command:
      • fastboot devices
    • If you are using a Mac, then you need to prefix a “./” before every Fastboot command. So, the above command will look something like this on a Mac -:
      • ./fastboot devices
    • The above command should confirm if your device is indeed being detected by your PC or not. If it is, then proceed to the steps below. If not, repeat the steps above again. Make sure that you have properly installed the drivers and are inside the correct folder.

Capture2321

If you are running Windows, copy-paste the following command in the command prompt window -:

flash-all.bat

On a Mac, copy-paste the following command -:

./flash-all.sh

The script will then automatically flash the full factory image on your Nexus device. Once the factory image has been flashed, your device will automatically reboot. Keep in mind that the first boot might take some time so please be patient.

If the flash-all.sh script gives you a fastboot not found error on your Mac, open up the file in Text Edit and add a “./” before every fastboot command.

The flash-all script included in the factory image might not work for all. It has always been pretty unreliable and has only worked once for me in the last 2 years. If you are in the same boat as me, you will have to flash each partition manually on your device. This is slightly cumbersome though.

The command to manually flash a partition via fastboot is “fastboot flash partition filename.img”. In the factory image that you extracted in Step 1, you will notice there is another ZIP file. Extract the contents of that ZIP file inside the ‘google’ folder.

Capture12312

Now, its time to manually flash the partitions to your Nexus device. We will first begin with the bootloader.

fastboot flash bootloader bootloader-mako-makoz30d.img

Then, we will flash all other partitions. They don’t necessarily need to be in the same order as I have listed them below. The names of the image files in the factory image will clearly indicate the partition they are intended for as well.

fastboot flash boot bootloader-mako-makoz30d.img

fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1701.02.img

fastboot flash recovery recovery.img

fastboot flash userdata userdata.img

fastboot flash system system.img

If you want to relock the bootloader of your device after flashing the device, put the device back in fastboot mode. Then type in the following command in the Terminal or Command Window you had opened earlier -:

fastboot oem lock

This will re-lock the bootloader of your Nexus device, restoring your warranty and putting the device back to complete stock.