[GUIDE] Flashing a Factory Image with fastboot / return to stock
The objective of this thread is to provide detailed instructions on flashing a factory image using fastboot rather than a toolkit. As good as toolkits can be, I recommend using adb and fastboot directly. This will allow you to see what is happening every step of the way and is a good opportunity to learn about the process. The following instructions assume some basic Windows command prompt skills.
Read all the directions before you begin and perform the steps at your own risk.
Overview
This will restore your Nexus 7 to it’s factory state. All user data will be deleted, so now is a good place to stop and backup anything you don’t want to lose.
This guide is in three parts - basic knowledge and obtaining the required software, driver installation, and flashing the factory image. This and any following verbosity is not to be condescending, but rather not to assume anything.
Basic Knowledge
This guide assumes some basic Windows command prompt skills - changing directories, etc and is written primarily for Windows users. Make sure that you have file extensions enabled in Windows Explorer.
Software Requirements
Android SDK - adb, fastboot, usb drivers
Java SE Development Kit - required by Android SDK
A Nexus 7 factory image
7-Zip - used to extract factory images from a .tgz file
Download the Nexus 7 factory image - https://developers.google.com/androi.../images#nakasi and save it somewhere you can easily retrieve it. Make sure to download the correct image for your device variant (Wi-Fi vs GSM/HSPA+; nakasi vs nakasig)
NOTE: Notice the install location. This defaults to C:\Users\<user name>\AppData\Local\Android\android-sdk the platform tools (adb, fastboot) and usb drivers will be downloaded to this location. This will be referred to from here on as your sdk directory
Run the SDK Manager
Under Tools, check the box labeled "Android SDK Platform-tools" - this provides adb and fastboot
Under Extras, check the box labeled "Google USB Driver"
Press the "Install # packages..." button and follow the on-screen instructions.
The platform tools will be installed at <your sdk directory>\platform-tools and the usb drivers will be in <your sdk directory>\extras\google\usb_driver
Driver Installation
This seems to be the most confusing part for many people. Be patient and thoroughly read all the instructions.
Enable usb debugging on your device (found under Settings > Developer Options) NOTE: Since Android 4.2 the Developer Options are hidden by default.
To enable them, go to Settings > About Phone, and tap on build number around seven times. A small dialog will appear letting you know "You are now a developer!"
Once the driver is installed open a command prompt and change directories to <your sdk directory>\platform-tools (see #2). From the command prompt run "adb devices". This will list any adb-capable devices that are connected to the computer by their serial number assuming your drivers are installed correctly. Recap:
Code:
> cd \Users\<user name>\AppData\Local\Android\android-sdk\platform-tools
> adb devices
# the following output should be returned
List of devices attached
<device serial number> device
Use adb to boot the device to the bootloader:
Code:
> adb reboot-bootloader
The device should now be in fastboot mode and Windows should be attempting to install the fastboot driver. NOTE: if you had drivers previously installed, you may need to upgrade them. This is the same procedure described at http://developer.android.com/tools/extras/oem-usb.html
You can verify that the driver has been installed by running the following command:
Code:
> fastboot devices
# the following output should be returned
<device serial number> fastboot
Do not proceed further if fastboot can not recognise your device. You are in driver hell and this must be resolved before continuing.
Extract the Factory Image
In order to extract the necessary files from the factory image archive, we will use 7-Zip because it can do this reliably. At this point you should have already installed 7-Zip and downloaded the factory image archive.
Use 7-Zip to open the factory image .tgz file. You should see a single .tar file. Open this file with 7-Zip as well.
Inside the .tar file is a directory that will resemble “nakasi-jdq39”. Open that directory and extract the contents to <your sdk directory>\platform-tools.
The extracted files should be as follows: bootloader-grouper-4.18.img, image-nakasi-jdq39.zip, flash-all.sh, flash-base.sh
Flashing the Factory Image
Put the device into fastboot mode by running the following adb command:
Code:
> adb reboot-bootloader
In order to do anything useful in fastboot, the bootloader must be unlocked. To do this, run the following fastboot command:
Code:
> fastboot oem unlock
Follow the directions on the device, using the volume and power buttons to select "Yes". NOTE: this will wipe all personal data.
In fastboot with your device's bootloader unlocked, run the commands listed in flash-all.sh in sequence, waiting for each command to finish.
Follow the commands for your device variant - Wi-Fi (nakasi) or GSM/HSPA+ (nakasig). For convenience I have them here: NOTE: you will see some messages about the archive not containing boot.sig, recovery.sig and system.sig. That is normal, dont worry.
Thank you for this tutorial! It allows us to learn how to do things via adb and learn how not to depend on a toolkit. I hope everyone that does not know how to flash things manually read this thread! Thank you for taking the time to help us learn!
Overview
This will restore your Nexus 7 to it’s factory state. All user data will be deleted, so now is a good place to stop and backup anything you don’t want to lose.
This guide is in three parts - basic knowledge and obtaining the required software, driver installation, and flashing the factory image. This and any following verbosity is not to be condescending, but rather not to assume anything.
Could I suggest adding a fourth section to you guide that you only alluded to. Backing up and restoring "anything you don’t want to lose." Detailed as your guide is, you've started with the assumption that a user knows how it back and reinstall the data they would likely want to save.
I don't even know how to do this so I'm stymied even before starting your guide.
Could I suggest adding a fourth section to you guide that you only alluded to. Backing up and restoring "anything you don’t want to lose." Detailed as your guide is, you've started with the assumption that a user knows how it back and reinstall the data they would likely want to save.
I don't even know how to do this so I'm stymied even before starting your guide.
You can always hook your phone up to your PC and copy your folders before this process. You can also make a nano back up and copy it to your computer and then drag it to the SD of your replacement phone and restore it after you get set up and rooted. Titanium back up is another good app to save your apps and data but you will still need to copy that folder to your pc before performing this and then re root your phone so you can restore from titanium back up. Best bet if you are happy with your set up is do a nano back up save that to your PC and now you have a back up to get back to where you were before.
Could I suggest adding a fourth section to you guide that you only alluded to. Backing up and restoring "anything you don’t want to lose." Detailed as your guide is, you've started with the assumption that a user knows how it back and reinstall the data they would likely want to save.
I don't even know how to do this so I'm stymied even before starting your guide.
The backup and restore of user data was intentionally left out because it is out-of-scope for this guide. You bring up a valid point about users needing direction for backing up and potentially restoring user data and files. I'd be more than happy to link to some existing guides that cover this topic in detail. I'll take a look around to see what I can find.
Thank you very much for this! Worked perfect and this gave me the confidence to do it manually and stay away from toolkits. Back to stock and locked bootloader ready to go back to the store.
I'm surprised this is just coming up. Thanks though!
I know I read your thread sorry about your loss. These tutorials help us learn how to do things manually and safe from making mistakes. Thanks again to the OP.
Just a coupe of days ago, we brought you news about a game calledAgent Sheep. In that … more
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?