Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE] Flashing a Factory Image with fastboot / return to stock

OP comminus

27th September 2012, 08:43 AM   |  #1  
comminus's Avatar
OP Senior Member
Flag Vancouver
Thanks Meter: 568
 
620 posts
Join Date:Joined: Jul 2011
More
Notice: If you are going to flash the nakasi android 4.3 JWR66Y factory image, you will need to download the bootloader from JWR66V and replace the one from the factory image. The bootloader in JWR66Y will fail flashing with a signature mismatch error on the device and InvalidState on fastboot.

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
  1. Download and install 7-Zip - http://www.7-zip.org/download.html
  2. 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)
  3. Download and install the Java SE JDK - http://www.oracle.com/technetwork/ja...ads/index.html
  4. Download and install the Android SDK - http://dl.google.com/android/installer_r21-windows.exe
  5. 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
  6. Run the SDK Manager
  7. Under Tools, check the box labeled "Android SDK Platform-tools" - this provides adb and fastboot
  8. Under Extras, check the box labeled "Google USB Driver"
  9. Press the "Install # packages..." button and follow the on-screen instructions.
  10. 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.

Huge thanks to @tetakpatak for taking the time to put together a video showing this process! http://www.youtube.com/watch?v=bhA5C...yer_detailpage..
  1. 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!"
  2. Install the abd driver - detailed instructions for installing or upgrading and existing driver on your version of Windows can be found at http://developer.android.com/tools/extras/oem-usb.html
  3. 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
  4. Use adb to boot the device to the bootloader:
    Code:
    > adb reboot-bootloader
  5. 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
  6. 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
  7. 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.
  1. 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.
  2. Inside the .tar file is a directory that will resemble ďnakasi-jwr66yĒ. Open that directory and extract the contents to <your sdk directory>\platform-tools.
  3. The extracted files should be as follows: bootloader-grouper-4.23.img, image-nakasi-jwr66y.zip, flash-all.sh, flash-base.sh

Flashing the Factory Image
  1. Put the device into fastboot mode by running the following adb command:
    Code:
    > adb reboot-bootloader
  2. 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
  3. Follow the directions on the device, using the volume and power buttons to select "Yes". NOTE: this will wipe all personal data.
  4. 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.

    Wi-Fi devices (nakasi)
    Code:
    > fastboot erase boot
    > fastboot erase cache
    > fastboot erase recovery
    > fastboot erase system
    > fastboot erase userdata
    > fastboot flash bootloader bootloader-grouper-4.23.img
    > fastboot reboot-bootloader
    > fastboot -w update image-nakasi-jwr66y.zip
    GSM/HSPA+ devices (nakasig)
    Code:
    > fastboot erase boot
    > fastboot erase cache
    > fastboot erase recovery
    > fastboot erase system
    > fastboot erase userdata
    > fastboot flash bootloader bootloader-tilapia-4.23.img
    > fastboot reboot-bootloader
    > fastboot flash radio radio-tilapia-1231_0.18.0_0409.img
    > fastboot reboot-bootloader
    > fastboot -w update image-nakasig-jwr66y.zip
    After the final command completes, the device will reboot.
  5. If you are sending the device in for warranty work, you may want to re-lock the bootloader
    Code:
    > fastboot oem lock
  6. Finally, reboot the device
    Code:
    > fastboot reboot
Last edited by comminus; 5th October 2013 at 12:48 AM.
The Following 319 Users Say Thank You to comminus For This Useful Post: [ View ]
27th September 2012, 01:05 PM   |  #2  
El Daddy's Avatar
Forum Moderator
Flag Roseville, MN
Thanks Meter: 4,588
 
3,956 posts
Join Date:Joined: May 2008
More
Fantastic work!
The Following 2 Users Say Thank You to El Daddy For This Useful Post: [ View ]
28th September 2012, 05:11 AM   |  #3  
Senior Member
Flag Bay Area California
Thanks Meter: 861
 
3,183 posts
Join Date:Joined: Sep 2011
More
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!
29th September 2012, 11:25 AM   |  #4  
Member
Thanks Meter: 4
 
33 posts
Join Date:Joined: Aug 2012
Quote:
Originally Posted by comminus

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.
29th September 2012, 05:30 PM   |  #5  
Senior Member
Flag Bay Area California
Thanks Meter: 861
 
3,183 posts
Join Date:Joined: Sep 2011
More
Quote:
Originally Posted by Pariah3000

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.
29th September 2012, 07:45 PM   |  #6  
comminus's Avatar
OP Senior Member
Flag Vancouver
Thanks Meter: 568
 
620 posts
Join Date:Joined: Jul 2011
More
Quote:
Originally Posted by Pariah3000

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.

Sent from my Nexus 7 using Tapatalk 2
The Following 3 Users Say Thank You to comminus For This Useful Post: [ View ]
8th October 2012, 04:15 AM   |  #7  
Senior Member
Flag Bay Area California
Thanks Meter: 861
 
3,183 posts
Join Date:Joined: Sep 2011
More
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.
8th October 2012, 05:55 AM   |  #8  
sikagoon7's Avatar
Senior Member
Flag Stockbridge, GA
Thanks Meter: 193
 
433 posts
Join Date:Joined: Aug 2012
I'm surprised this is just coming up. Thanks though!
9th October 2012, 06:12 AM   |  #9  
Senior Member
Flag Bay Area California
Thanks Meter: 861
 
3,183 posts
Join Date:Joined: Sep 2011
More
Quote:
Originally Posted by sikagoon7

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.
The Following User Says Thank You to Travisdroidx2 For This Useful Post: [ View ]
10th October 2012, 02:39 PM   |  #10  
peoples_flip's Avatar
Senior Member
Flag Toronto
Thanks Meter: 71
 
589 posts
Join Date:Joined: Apr 2011
More
Excellent work comminus.... very well written!

Post Reply Subscribe to Thread

Tags
back to stock, factory image, fastboot, return to stock
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes