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

Search This thread

comminus

Senior Member
Jul 29, 2011
640
626
Vancouver
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/android/nexus/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/java/javase/downloads/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=bhA5CN4335U&feature=player_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:

Travisdroidx2

Senior Member
Sep 9, 2011
3,699
976
Bay Area California
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!
 

Pariah3000

Member
Aug 16, 2012
33
4
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.
 

Travisdroidx2

Senior Member
Sep 9, 2011
3,699
976
Bay Area California
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.
 

comminus

Senior Member
Jul 29, 2011
640
626
Vancouver
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
 

Travisdroidx2

Senior Member
Sep 9, 2011
3,699
976
Bay Area California
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.
 
Help help help!!! Lol

im running into problems..... fastboot wont work.... i have unlocked using fastboot no problem and can also use erase commands no problems.

however when it comes to " flash" or "update" commands, all i get is sending data and the size of what it is sending, but nothing happens. it just hangs there and nothing flashes up on my tablet either. the device hasnt hung as can still use vol keys to change options.

can anybody help me out with a solution here because im going insane!!

---------- Post added at 02:46 PM ---------- Previous post was at 02:31 PM ----------

im running into problems..... fastboot wont work.... i have unlocked using fastboot no problem and can also use erase commands no problems.

however when it comes to " flash" or "update" commands, all i get is sending data and the size of what it is sending, but nothing happens. it just hangs there and nothing flashes up on my tablet either. the device hasnt hung as can still use vol keys to change options.

can anybody help me out with a solution here because im going insane!!
 

piobeer

Senior Member
Mar 6, 2008
144
6
Thanks for this guide I am following it for installing stock image. I'm getting until the last stage but when doing the fastboot -w update xxx.zip file I'm getting error messages saying 'image does not contain recovery.sig, image does not contain system.sig, image does not contain boot.sig' and then it fails to install.

Any idea what I'm doing wrong here?

Thanks

Edit: got it to work using a different windows machine - probably a driver issue somehwere it must have been
 
Last edited:

Eeprom78

New member
Nov 11, 2011
1
1
Thanks for the excellent explanation. Got my N7 working again. (messed up the upgrade to 4.1.2)

Also got the error 'image does not contain recovery.sig, image does not contain system.sig, image does not contain boot.sig' but installation still worked.
 
  • Like
Reactions: comminus

comminus

Senior Member
Jul 29, 2011
640
626
Vancouver
Thanks for the excellent explanation. Got my N7 working again. (messed up the upgrade to 4.1.2)

Also got the error 'image does not contain recovery.sig, image does not contain system.sig, image does not contain boot.sig' but installation still worked.

I will update the instructions to mention that this is normal. Glad to hear you were able to get you N7 working again!
 
  • Like
Reactions: dadeo1111

dcgraphicworks

New member
Oct 24, 2012
1
0
Great Sticky..

Thanks for the work on this.. my N7 was acting strange with one of the installed ROMs and
this guide helped me restore the device easily. :good::good::good::good::good::good:
 

mertzi

Senior Member
Jul 8, 2011
629
112
This guide is great, I did a factory flash some weeks ago just to see how the procedure works and it is pretty easy if you know this stuff, but as a galaxy S3 owner I wonder why there's nothing equivalent to odin for the nexus 7? Afaik odin works for the gnexus. Odin makes reflashing stock images ridiculously easy.

Sent from my Nexus 7 using xda app-developers app
 

comminus

Senior Member
Jul 29, 2011
640
626
Vancouver
This guide is great, I did a factory flash some weeks ago just to see how the procedure works and it is pretty easy if you know this stuff, but as a galaxy S3 owner I wonder why there's nothing equivalent to odin for the nexus 7? Afaik odin works for the gnexus. Odin makes reflashing stock images ridiculously easy.

Sent from my Nexus 7 using xda app-developers app

Thanks for the comments. Once someone has their computer set up to work with fastboot the process is just as simple as using Odin. The factory image archive contains batch and shell scripts which allow you to flash the images in one command - arguable just as easy as using Odin or Heimdall. But then, it's all personal preference anyway :p
 

kinhbang1989

Member
Oct 14, 2012
15
0
What if I can't go to fastboot because my nexus now only can be booted in cwr :(. Do you have any solutions regarding my matters?

Thanks,
 

Top Liked Posts

  • There are no posts matching your filters.
  • 341
    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/android/nexus/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/java/javase/downloads/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=bhA5CN4335U&feature=player_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
    4
    Hi there. Having some trouble, hoping nothing serious. Read the guide twice and even went through the first 20 pages on this thread to see if any extra notes could be made.

    Basically, let me start off by asking if its a problem installing google usb driver for nexus 7 v1 instead of the asus driver? I used the google driver that came with sdk tools and since everything seemed to work, i proceeded with command prompts.

    2) When you extract bootloader-grouper-4.23.img, image-nakasi-jwr66v.zip, flash-all.sh, flash-base.sh to sdk platform tools, there is an omitted fifth file (.dat file). Should that not be included with everything else?

    3) Heres where my actual problem seems to start.
    Where your told to " fastboot flash bootloader bootloader-grouper-4.23.img" I get this error message:

    Failed (remote: (invalid state)

    4) Now the invalid state error seems connected to next command "fastboot -w update image-nakasi-jwr66v.zip" ( i had to rename to jwr66y.zip as thats what the zip file was called)
    which resulted in this message:


    "archive does not contain boot sig
    archive does not contain recovery sig
    not contain system.sig

    bootloader version 4.18
    baseband na
    serial number ......

    checking product...
    checking version bootloader
    failed

    device version bootloader is 4.18
    update requires 4.23
    finished total time 0.210s


    Not sure why this is happening because im 99% sure that followed commands to the letter. Seems tied up with bootloader not updating.
    Ive really committed here and kind of sweating at this point :s

    Everyone has been reporting that the 4.23 bootloader from nakasi build JWR66Y is not flashing. The bootloader from JWR66V is also 4.23 and I've posted it to Google Drive.

    bootloader-grouper-4.23.img.gz

    Just decompress it and flash normally
    Code:
    fastboot flash bootloader bootloader-grouper-4.23.img
    4
    Thanks for the reply bro, i got it flashed back to stock with WUG's tool so yet again I have escaped the need to learn ADB and ADK etc :eek:
    Again thanks for the reply and making it sound fairly easy, now I wanna try it just for the next time I act like a moron and wipe a little too much before a new ROM install.:(
    You can run for now, but you can't run forever, you still have to learn fastboot and adb at some point of time unless you stop messing around.

    Beamed from my Grouper.
    3
    Fantastic work!
    3
    Nexus 7

    "1.Enable usb debugging on your device (found under Settings > Developer Options)"

    I don't see this option under settings, I think recent update of android to jop40c has made it vanish unless in a new location. :confused:

    Settings > About tablet > Build number (tap 7 times and the option will appear under settings)