[Nexus 7 Q&A, Help & Troubleshooting] comminus:
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

Download and install 7-Zip - http://www.7-zip.org/download.html

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)

Download and install the Java SE JDK - http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download and install the Android SDK - http://dl.google.com/android/installer_r21-windows.exe

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.

Huge thanks to [MENTION=5051515]tetakpatak[/MENTION] for taking the time to put together a video showing this process! http://www.youtube.com/watch?v=bhA5CN4335U&feature=player_detailpage..

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!"

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

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:

> 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:

> 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:

> 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-jwr66y”. Open that directory and extract the contents to <your sdk directory>\platform-tools.

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

Put the device into fastboot mode by running the following adb command:

> adb reboot-bootloader

In order to do anything useful in fastboot, the bootloader must be unlocked. To do this, run the following fastboot command:

> 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.

Wi-Fi devices (nakasi)

> 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)

> 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.

If you are sending the device in for warranty work, you may want to re-lock the bootloader

> fastboot oem lock

Finally, reboot the device

> fastboot reboot