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, the capability to tweak and optimize your device, and the 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 it 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 could recover my Nexus 5.
While not all Android OEMs provide stock firmware 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 images from the official site.
- Download and set up the Android SDK platform-tools 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 an administrator, check the Google USB Drivers and install it. Skip this step you have already done it.
- 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.
- 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 the 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 the Install option. When the driver is installed, your device should show in the device manager as “Android Composite ADB Interface”.
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:
- 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.
- Open the extracted factory image folder. You would find a zip file inside. Unzip it too.
- Now copy all the contents of the image directory to the Platform-tools directory under C:/Program Files/Android/sdk.
- 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 commands.
- 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 seconds.
- Connect your Nexus 5 to the computer using a USB cable.
- 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.
- 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 flash radio radio-hammerhead-m8974a-126.96.36.199.23.img
fastboot flash system system.img
fastboot flash userdata userdata.img
fastboot flash recovery recovery.img
fastboot flash boot boot.img
fastboot erase cache
fastboot flash cache cache.img
- 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 the bootloader. If you want to lock the bootloader again, issue the following command:
fastboot oem lock
- If you wish to keep your Nexus 5 with an 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 the 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)
- ./flash-all.sh (for Mac)
I hope everything goes right for you. In case you get stuck at a certain step or have a question, feel free to write a comment. Cheers!
Your 32GB Nexus 5 now shows only 16GB storage? Follow our tutorial to fix the issue.