• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

DroidViews

  • Apps
  • Downloads
    • Android Apps
    • Themes
  • Guides
    • Root
  • ROMs
  • Reviews
  • Wallpapers

Restore Nexus 5 to Stock and Flash Factory Images (Win/ Mac/ Linux)

Rakesh | 18 Dec 2016 | Google/ Guides

Restore Nexus 5 to Stock

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.

Disclaimer

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.

Preparations:

  • 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. android 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.
  • 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”.nexus 5 usb drivers

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 commands.nexus 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 seconds.nexus 5 fastboot mode
  6. Connect your Nexus 5 to the computer using a 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-1.0.25.0.23.img
    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 the 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 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.

Tags: Google Nexus 5 How to Guides Nexus 5 Nexus 5 Tips and Tricks Restore to Stock Firmware

Related Posts

Android 8.0 Oreo Based AOSP ROM on Nexus 5

How to Install Android 8.0 Oreo Based AOSP ROM on Nexus 5

Maru OS - Desktop-like Android Experience on Nexus 5 & 7 - Droid Views

Enjoy Desktop-like Android Experience on Nexus 5 & 7 with Maru OS

Enjoy Android 7.0 Nougat on Nexus 5

Reader Interactions

Discussion

  1. Apr 10, 2016 at 1:40 AM
    luke says:
    Reply

    Hi I just wanted to say thank you so much! I have the 16gb model and I have messed around with roms and rooting. All in all, I had 10.5 gb of nothing in my storage resulting in only getting 1.5 gb of free storage (because android took about 3.5 gb for software) It had made me so mad for a while because factory resets wouldnt even solve it. This is the only way that solved it for me. Thank you again!
    -Luke

    • Oct 24, 2016 at 11:04 AM
      Rakesh says:
      Reply

      Hi, can you give me the link to the firmware image you flashed?

  2. Feb 29, 2016 at 2:45 PM
    Karmendra says:
    Reply

    Hi Rakesh,

    I am also getting write failure error via fastboot command and its for every image in Nexus 5 with 6.0.1 version.

    Thanks,
    Karmendra

  3. Jul 2, 2015 at 7:15 PM
    MM says:
    Reply

    Hi,

    I have a question: after I flash a custom ROM can I flash the radio.img from the stock google image?

    • Jul 2, 2015 at 7:29 PM
      Rakesh says:
      Reply

      Yes. Most custom ROMs modify system only.

      • Jul 3, 2015 at 7:17 PM
        MM says:
        Reply

        10x

  4. Jun 7, 2015 at 4:39 AM
    ssskom says:
    Reply

    Hi Rakesh, thanks for posting this. However, I am stuck at : “Download and setup Android SDK on your computer”. I followed your link and it brought me to the Android Studio bundle donwload page. I downloaded Standalone SDK Tools v24.2 (latest), unzipped it, but it does not contain either “eclipse” or “sdk” folder (pls see attached). May I know which SDK Tools version should I use? Appreciate your response.

    • Jun 7, 2015 at 5:57 AM
      Rakesh says:
      Reply

      Looks like the SDK file has not been extracted properly as it lacks the required files.

      Download the attached “platform-tools.zip” and extract it to the same directory as shown in your screenshot: https://dl.dropboxusercontent.com/u/84115590/platform-tools.zip

      or you can simply use the minimal ADB and Fastboot tools: https://dl.dropboxusercontent.com/u/84115590/mfastboot-v2.zip

  5. Apr 29, 2015 at 9:08 AM
    Michael French says:
    Reply

    Worked beautifully! I’ve been sitting on the lollipop dev preview for far too long. Most apps skipped over support for it, so it was high time to jump onto the real-deal. Thanks for your simple instructions! I’m bookmarking this for future updates!

    • Apr 29, 2015 at 9:16 AM
      Rakesh says:
      Reply

      Thanks for the appreciation, Michael!

  6. Apr 28, 2015 at 7:26 AM
    22Ryann says:
    Reply

    Just followed all the steps using the most current build i could find and it worked a treat! Thank you so much! – April 2015

    • Apr 28, 2015 at 7:56 AM
      Rakesh says:
      Reply

      Glad to know!

  7. Apr 25, 2015 at 3:07 PM
    Shadman Rabbi says:
    Reply

    hello i did the steps but my phone is still stuck on boot animation please help ASAP

    • Apr 25, 2015 at 4:38 PM
      Rakesh says:
      Reply

      Hold the volume down+Power buttons for a few seconds until you get into the bootloader mode. Then select recovery and wipe data factory reset.

      or

      Just flash the firmware again after a full wipe.

      Tutorial: https://www.droidviews.com/your-32gb-nexus-5-now-shows-only-16gb-here-is-how-to-fix-it/

  8. Feb 22, 2015 at 8:05 AM
    Fil Cil says:
    Reply

    Hi (again) How do I just lock the bootloader? With a non-rooted phone?

    • Feb 22, 2015 at 6:07 PM
      Rakesh says:
      Reply

      Use this command: fastboot oem lock

  9. Feb 15, 2015 at 3:28 PM
    Fil Cil says:
    Reply

    Hello,

    At the time I bought my Nexus 5 I ROOT it. It was then android kitkat. In the next update (manually initiated), the root disepeared and, as I didn’t need it anymore,
    it did not bother me. With the next updates and especially lollipop these update were done automatically.
    I am now on Android 5.0.1 and there is an android update worries because my bootloader is aleready unlocked.

    My concern is this: I would like to re-lock the bootloader without losing all the data on my smartphone.
    However, as the Nexus is no longer ROOTED, I do not have access to hidden data in the root, so I cannot save …

    Do you have a solution for me that works here? The fastboot not going to erase everything?

    Well I’m not very good so speak slowly 😉

    Thank you in advance

    PS: Oh, just one thing, the ADB drivers are already installed and “OK” (made at the root but still ok today), and, strange to say, as my Nexus 5 is no longer ROOTED,
    when I start in fastboot, it makes me:
    Poduct NAME: Hammerhead
    VARIANT hammerhead D821 (E) 32Gb
    HW Version – rev11
    Bootloader version -HHZ11k
    Baseband version – M8974A-2.0.50.2.22
    So it’s the same (except baseband version) as the picture shown in the tuto. The question are: have I the corect firmware? In the “android-inf.txt” file ity says
    “require version-bootloader=HHZ12d…argh! it’s not my version…

    HELPPP!!!

    • Feb 15, 2015 at 4:40 PM
      Rakesh says:
      Reply

      Well, unlocking and re-locking the bootloader would wipe phone’s data. Better take a backup of your apps and other data before proceeding.

      • Feb 15, 2015 at 5:14 PM
        Fil Cil says:
        Reply

        Ok thanks,
        But with the specs I wrote, do you think that if I just re-lock bootloader, it will be as a native firmware? Or is it better to flash it entierely?

        • Feb 15, 2015 at 5:27 PM
          Rakesh says:
          Reply

          Since your device has the stock firmware, yes.

          • Feb 16, 2015 at 8:33 PM
            Fil Cil says:

            cool thanks a lot for replies and reactivity

  10. Jan 13, 2015 at 4:57 AM
    Rakesh says:
    Reply

    Try flashing the images individually.

    or

    Try wiping data/factroy reset in stock recovery:

    Press and hold Volume Down and Power buttons all at the same time.
    – don’t release the buttons.

    Uelease the buttons only when the Fastboot / Bootloader Mode options appear.
    – a START text is listed at the upper part of your device’s screen,

    Use the Volume buttons to change START to Recovery Mode option.

    Press the Power button to select Recovery Mode.
    – after that you will see an Android robot tilted and showing a red warning sign.

    Now, you need to press and hold POWER, and then press once the Volume Up button.

    The Stock Recovery Mode options will now appear on your device.

    Now select “wipe data/factory reset” option and perform a wipe.

    Then reboot the device.

    • Jan 13, 2015 at 8:19 AM
      geekstay says:
      Reply

      After wiping data/factory reset, everything is wright. Thank you for your help !

      • Jan 13, 2015 at 8:36 AM
        Rakesh says:
        Reply

        Glad to know! 🙂

    • Oct 24, 2016 at 4:05 AM
      Satria Gunadharma says:
      Reply

      Hi…..i know it’s been 2 years since this were posted. I have same issue, stuck in Google logo for hours. Had done your guidance to re-flash and wipe data, but it still stuck at Google logo. Anyway, i use Nexus 5X….. Please help 🙁

  11. Jan 9, 2015 at 11:54 AM
    Rahul Nair says:
    Reply

    I’m in the same situation right now. And i have no idea what to do. Possibly did every way to reset to stock. ADB , Root tool kit and what not. Always Failed Flash write error turns up. Anybody in here think it can be a hardware kind of issue?

    • Jan 9, 2015 at 12:01 PM
      Rakesh says:
      Reply

      Do you have an unlocked bootloader?

      • Jan 9, 2015 at 12:57 PM
        Rahul Nair says:
        Reply

        Yes. Now the phone’s in Bootloop :/

        • Jan 9, 2015 at 3:27 PM
          Rakesh says:
          Reply

          Then try flashing the images again. Show me the screenshot.

          • Jan 10, 2015 at 7:40 PM
            Rahul Nair says:

            I did try again. Doesn’t switch on. Stuck at Google and with unlocked figure shown.
            As far as the screenshot is concerned, its the same error being shown as what Kamrul Hasan had uploaded in the previous comment.
            I did try to format the Cache and System , hard reset through stock recovery , but it didnt succeed. Shows failed.

          • Jan 10, 2015 at 7:41 PM
            Rahul Nair says:

            Can’t try a custom rom because its not rooted and no recovery is installed..

          • Jan 10, 2015 at 7:43 PM
            Rahul Nair says:

            As far as stock, I did try both the versions of Lollipop and 4.4.4. Still the same error turns up.

          • Jan 10, 2015 at 7:48 PM
            Rahul Nair says:

            Here’s the command window 🙂

          • Jan 10, 2015 at 6:00 AM
            Rakesh says:

            Hmm, so the device does not let flash any of the images, or the issue occurs only with the bootloader image?

          • Jan 10, 2015 at 5:12 PM
            Rahul Nair says:

            It doesn’t let any of the images. I had referred it in other websites, I got comments saying my eMMc has got fried or something.

          • Jan 10, 2015 at 5:23 PM
            Rakesh says:

            I doubt that too. That’s why I asked my previous question. Anyway, if any of the images were not flashed on the device, you should be able to boot the device normally.

            Since EMMC is corrupt, it’s not letting any files to be written on the device, resulting in error.

            https://www.droidviews.com/fix-e-cant-mount-sd-card-issue-android-devices/

          • Jan 10, 2015 at 5:35 PM
            Rahul Nair says:

            Link you’ve given, for that my phone’s USB debugging should be on. But it isn’t and i have no Recovery installed and i cant install too cos phone isnt’t rooted.

          • Jan 10, 2015 at 5:38 PM
            Rakesh says:

            So, you did not enable USB debugging before attempting firmware flashing?

          • Jan 10, 2015 at 5:49 PM
            Rahul Nair says:

            I did. But now it says Enable USB Debugging

          • Jan 10, 2015 at 6:04 PM
            Rakesh says:

            Contact us on Hangouts: [email protected]

  12. Nov 19, 2014 at 9:16 PM
    Kamrul Hasan says:
    Reply

    Adding screenshot

    • Nov 19, 2014 at 2:35 AM
      Dhananjay Bhardwaj says:
      Reply

      Hello Kamrul, first of all you need to make sure that you’ve Nexus 5 bootloader unlocked.
      Something here I would like to know is that whether you’re trying to flash the latest lollipop factory image?

      • Nov 19, 2014 at 4:03 AM
        Kamrul Hasan says:
        Reply

        Hi,
        My phone is currently bricked state. Since its not booting up, its not getting as ADB device. Yes bootloader unlocked and i am trying to flash lollipop image.

  13. Nov 19, 2014 at 9:15 PM
    Kamrul Hasan says:
    Reply

    I am getting this error FAILED in both bootloader and radio. Please help me it’s urgent

  14. Nov 8, 2014 at 6:34 AM
    L30N4KU says:
    Reply

    THANK YOU

  15. Nov 4, 2014 at 5:58 AM
    Rajesh says:
    Reply

    Hi Rakesh,
    Thanks a lot for the detailed post. I have a basic doubt, Will i be getting the OTA updates as usual once i move back to stock android ? or do i need to flash it manually every time when there is a new update ?

    • Nov 4, 2014 at 6:15 AM
      Rakesh says:
      Reply

      Yes, having flashed the stock factory images, you will get all OTAs automatically.

  16. Oct 27, 2014 at 10:07 AM
    Phong Nino says:
    Reply

    I need some help, please.
    this app can’t run on your pc windows 8 to find a version for your pc

    • Oct 27, 2014 at 6:26 PM
      Rakesh says:
      Reply

      Which app?

      • Mar 15, 2015 at 9:25 PM
        Bünyamin Tetik says:
        Reply

        When I open Command Prompt and write fastboot devices, I see a warning “this app can’t run on your pc”. I using Win 10 technical review.

        • Mar 15, 2015 at 5:27 AM
          Rakesh says:
          Reply

          Try on Windows 8.

  17. Oct 26, 2014 at 6:58 AM
    Ali Sajid says:
    Reply

    found the problem
    forgot to add .img

    • Oct 26, 2014 at 6:59 AM
      Rakesh says:
      Reply

      Hmm. I was just wondering what could be the reason. 🙂

  18. Oct 26, 2014 at 6:47 AM
    Ali Sajid says:
    Reply

    same thing with radio

  19. Oct 26, 2014 at 6:37 AM
    Ali Sajid says:
    Reply

    cannot load ‘bootloader-hammerhead-hhz11k’
    i did replace the names highlighted in red

  20. Oct 14, 2014 at 4:25 AM
    dandiGher says:
    Reply

    the other problem I have also, is that all the places I’ve tried to download Android ver.4.1.2(for SGS3_GT-I9300 XXEMC2) from is linked to HotFile account(S) & I understand they no longer exist(were bought by a predator co.) are you not able to provide a link where, we are able to download from your server pls? In U.K.Thank you for your insightful website info!

  21. Oct 14, 2014 at 4:17 AM
    dandiGher says:
    Reply

    hi Rakesh; this Tutorial is no good for myself & others when SGS3 does not get past ‘bootloop,’ to allow entry to switch on the ‘USB Debugging?’

  22. Aug 9, 2014 at 1:46 PM
    ana says:
    Reply

    hello, i’m very desperate and heartbroken- wanted to see if anyone could help me… i sent my nexus 5 to lg to fix the screen and they wiped everything without telling me, i’m pretty sure my phone wasn’t backed up since i had no idea they would do such a thing without informing me. Is there any way i can get at least my pictures and notes back? thank you so much !

  23. Aug 1, 2014 at 7:07 AM
    Séb says:
    Reply

    You have no idea how much you help me, thank you very much 🙂

    • Aug 1, 2014 at 1:11 PM
      Rakesh says:
      Reply

      Glad to know we could help you!

  24. Jul 23, 2014 at 6:22 AM
    Trevor says:
    Reply

    Thank you sooooo much!! This has really saved my life!!!

    • Jul 25, 2014 at 2:04 PM
      Rakesh says:
      Reply

      Life is much more valuable than a phone, bro!

  25. Jun 24, 2014 at 6:40 PM
    Cheri Lange says:
    Reply

    I have very sentimental photos of the last days of my dying mother’s life surrounded by her kids, grand kids and great grand kids stored on my Nexus 5. The phone is stuck in boot loop, won’t respond to hard factory reset, and my photos weren’t backed up. If I follow the instructions outlined here, am I going to lose the photos on my photos? In advance, thanks for your help!

    • Jun 24, 2014 at 7:23 PM
      Rakesh says:
      Reply

      Hi Cheri, you have made a big mistake by relying on a phone with no external storage for storing your important pictures and data.

      Anyway, try the Nexus 5 Tool to install the factory images.

      Nexus Root Tool: http://www.wugfresh.com/nrt/

      Also download the factory images.

      Open Nexus Tool, go to the Options and head over to the Flash Stock tab and tick the box next to Enable “No Wipe Mode”. This will prevent the stock images from wiping your data.

      Next, it is important to install the proper drivers which can be done in the Initial Setup menu. Simply follow the the steps and you should be good to go soon. You are now able to flash Android 4.4.4.

      Click the Flash Stock + Unroot button while having Device is on/Normal status checked. On the next screen select “Other/Browse ..” and “I downloaded a factory image myself that I would like to use instead”. In the next window you’ll be able to select the Android factory images you downloaded earlier.

      If the program asks for an MD5 number, take the correct one from Google’s factory image page. The next steps will guide you through the process and you should be done quite soon. Your Android device is now running Android 4.4.4. However, your device is not rooted anymore and does not have a custom recovery installed. Head over to step 4 to fix that.

      • Jun 24, 2014 at 7:57 PM
        Cheri Lange says:
        Reply

        Rakesh, thank you so much for the detailed instruction. I’m anxious to get home and try this. There’s a long story about the history of the phone and why it wasn’t set to Google+ Auto Backup back up, but I’ll spare you details. 🙂

    • Jun 24, 2014 at 7:25 PM
      Rakesh says:
      Reply

      You can also try flashing only the boot, recovery and system images.

  26. Jun 10, 2014 at 10:08 PM
    MichaelFarese says:
    Reply

    This worked for me. I got a little confused because I couldn’t find the SDK folder, but I eventually found it inside the adt-bundle folder… once I moved it up one level to the Android folder, all else worked perfectly. Thanks!

    • Jun 11, 2014 at 5:57 AM
      Rakesh says:
      Reply

      Great! Thanks for sharing your experience!

  27. May 30, 2014 at 5:06 PM
    Bobby Davidson says:
    Reply

    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.

    Cheers!

    • May 30, 2014 at 5:37 PM
      Rakesh says:
      Reply

      Hi Bobby, thanks for the appreciation and the suggestion. You pointed the right thing and I have made the changes you suggested.

      Keep visiting!

      Regards!

  28. May 19, 2014 at 9:24 PM
    Maliki says:
    Reply

    What if you have a locked bootloader

    • May 20, 2014 at 10:51 AM
      Rakesh says:
      Reply

      You can still flash the factory images.

Join The Discussion: Cancel reply

We never share our visitor/user details. For more info, Please read our privacy policy before submitting your comment.

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

Primary Sidebar

Ezoic

Ezoic

Footer

  • Apps
  • Downloads
    • Android Apps
    • Themes
  • Guides
    • Root
  • ROMs
  • Reviews
  • Wallpapers

© 2023 · DroidViews