One of the fascinating things about Android is that it lets you unleash your adventurous self. If you are just a basic or average user, you could explore millions of apps in the Play Store to make the most of your device. However, if you are even a little passionate about the phone or tablet you own and have rooted it, the possibilities are immense. You can try and experiment custom ROMs and mods that can be easily found around the web if Googled.

Rooting lets you enjoy some really good apps and ROMs that help you get better battery life, capability to tweak and optimize your device, and option to customize your device in a plethora of ways. As you know, any adventurous feel involves the element of risks too. You might root your Android device, try a mod or kernel, or might go for a custom ROM, but there might be certain situation when you would either wish to return to the stock firmware of your device, or be forced to flash stock ROM as the ultimate resort to recover your device to normal state in case its is caught into bootloop.

The reason why I decided to write this tutorial is a little mishap that took place yesterday when I was going to install a ROM. I copied the ROM and GApps file to phone, backed up the old ROM, and then while wiping data, cache and system, I also selected internal SD card. The result was catastrophic and it was by flashing the factory image back that I cold recover my Nexus 5.

While not all Android OEMs provide stock firmwares of their device for public download, there are a few like Google and Motorola who have been pretty good at making them available to users. So, if you own a Nexus 5 and wish to restore it to stock firmware by flashing the official factory image, you can follow our detailed tutorial below and do it within minutes. Though this guide is meant for Nexus 5, it can be used on any Nexus device. The only important thing is, you must have the appropriate image file.


The procedure described below has been well tested but its success depends on how good you are while following it. The method is pretty easy to follow but it involves a few ADB and Fastboot commands.Read all steps a couple of times, make all preparations and do them carefully.


  • Download the latest Nexus 5 factory image from the official site: Click Here to Download
  • Download and setup Android SDK on your computer. To do this, download the SDK zip and extract its contents to the following path: C:/Program Files/Android (create this folder first). If you use Windows 8, extract the SDK files to Program Files (x86). Then run the SDK Manager.exe as administrator, check the Google USB Drivers and install it. Skip this step you have already done it. To get ADB and Fastboot working  properly, read our sdk location
  • Enable USB Debugging option on your phone: Settings> Developer options> USB Debugging. If you do not find the developer options, you’ll have to make it visible manually. See the instructions here.
  • Download and install the latest Google USB Driver on your Windows PC. Since the USB drivers is not an executable file but a zip, it requires special steps to install it. Download and extract the zip on your desktop. Connect your device to computer. Press Windows+X keys on the keyboard and click on Device Manager option. Now click on the “Other Devices” expander button. Right click on Nexus 5 (with yellow triangle sign) and select “Update Driver Software”. Then click on “Browse My Computer for Driver Software”. Locate the “latest_usb_driver_windows” folder and select Install option. When the driver is installed, you device should show in device manager as “Android Composite ADB Interface”.nexus-5-usb-driver

Restore Nexus 5 to Stock: The Steps

Having made the required preparations and downloaded the correct factory image for your Nexus 5, you can now proceed to flash it. Here are the steps to restore Nexus 5 to stock firmware:

  1. Unzip the downloaded factory image file with .tgz extension. Please note that downloaded with some browsers, the factory image file is saved to your computer as a .tar file. In that case, you should change the file extension to .tgz so that you might extract it.
  2. Open the extracted factory image folder. You would find a zip file inside. Unzip it too.
  3. Now copy all the contents of the image directory to the Platform-tools directory under C:/Program Files/Android/sdk.
  4. Also copy the contents of the zip file to the same directory. See the screenshot below to get a clearer idea of the path of the files and also the image files that need to be flashed using fastboot 5 factory image files
  5. Now it’s time to turn off your device and boot it into Bootloader/Fastboot mode. You can do it by holding the Volume Down+Power buttons for 2-3
  6. Connect your Nexus 5 to computer using USB cable.
  7. Now open the platform-tools folder where you have copied the factory image files and launch a command window. You can do this by pressing the Shift+Right-click on the mouse at an empty space from within the platform-tools folder.restore nexus 5 to stock-factory-image-flash
  8. It’s time now to begin the flashing business. Start typing the following commands one by one, allowing each to finish before moving onto the next. If you are a Mac user, make sure to add ./ in front of all commands (eg.- ./fastboot flash boot boot.img). Note: do not forget to replace the file names highlighted in red to replace with the ones that you have downloaded.
    fastboot flash bootloader bootloader-hammerhead-hhz11k.img
    fastboot reboot-bootloader
    fastboot flash radio radio-hammerhead-m8974a-
    fastboot reboot-bootloader
    fastboot flash system system.img
    fastboot reboot-bootloader
    fastboot flash userdata userdata.img
    fastboot flash recovery recovery.img
    fastboot flash boot boot.img
    fastboot erase cache
    fastboot flash cache cache.img
  9. When the Nexus 5 factory images are installed to your phone, it will be on 100% stock firmware, like when you bought it. However, it’ll still have unlocked bootloader. If you want to lock the bootloader again, issue the following command:
    fastboot oem lock
  10. If you wish to keep your Nexus 5 with unlocked bootloader, skip Step 9 and press the Power button on phone when its screen shows START.

Most Nexus factory images come with some flash scripts. By running them, you can easily install all required files to your phone in a single hit. However, we still recommend that you use the fastboot command method given above. If you choose to use the flash scripts you can launch a command prompt window and issue the following command:

  • flash-all.bat  (for Windows)
  • ./  (for Mac)

I hope everything goes right for you. In case you get stuck at certain step or have a question, feel free to write a comment. Cheers!

Your 32GB Nexus 5 Now Shows Only 16GB Storage?

See Here How to Fix It!


  1. You have written a wonderful tutorial! I was able to follow each step with ease and I am now back to stock, and I thank you for that.

    There was only one moment where I felt lost and I feel I should explain in case anyone else runs into this…

    When connecting my Nexus 5 to my PC(Windows 7 64bit) the device manager showed that it had already installed a driver of its own and my phone was showing up under “Mobile devises” as simply a “Nexus 5” (a quick check of the properties showed that it was using a Microsoft driver from 2006) and I could not for the life of me update the driver and get it to use the Google USB Driver.
    It wasn’t until after I placed the phone into “Developer mode” that my PC would let me install the Google USB Driver.

    So I would suggest re-arranging your tutorial to instruct users to “Enable USB Debugging” prior to downloading and installing the Google driver.


This site uses Akismet to reduce spam. Learn how your comment data is processed.