[GUIDE] Nexus 7 - Factory Image Restore

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
You unlocked, rooted, ROM'd, and, somewhere or another, appear to have royally screwed up your Nexus 7..... Not to fear! As a Nexus device Google has you covered with factory image packages you can use to restore your tablet to brand new out-of-the-box condition. And here's how...

[WARN]The procedure below will fully wipe of your device, internal SD included. If you are able to boot your tablet at all right now, its a good idea to copy anything you desperately need to save over to your computer, as you can move it back later. This is your last-resort fix for hacking screw ups. Niether myself nor Android Central is responsible for anything that happens to your device... but we will be here to help you as best we can[/WARN]

Here are the GENERAL INSTRUCTIONS TO RESTORE THE STOCK IMAGES. Make sure you know how to do it for your computer/setup and that ADB and fastboot is set up on your computer. Please check the guides provided by Zero Neck and Ragnarokx to ensure that you have your fastboot drivers installed correctly. Also know the exact folder containing the fastboot files you will be using and the specific name of the file, which might be "fastboot", "fastboot-windows", or "fastboot-mac" depending on which unlock method you used for your device.

In addition, make sure you know how to type the commands in for your specific setup. For example, if you're using a superboot folder for Mac, you need to make sure you understand what your "version" of the beginning of the command is (usually "./fastboot-mac" if you're using that r3-superboot folder).
For Linux/Ubuntu, be sure to put "sudo" before any and all fastboot commands, or you will get an error about insufficient permissions.

AC user SladeNoctis has provided a great video walkthrough of the entire process done on a Windows PC. While the commands you would use on a mac or linux box would be slightly different, this should give you a great idea of the overall process and what to expect. Thanks Slade!
How to return to Stock / Updating with Factory Images / Unbrick your Nexus 7 - YouTube
[INFO]
1. Download the 4.3 (JWR66V) image files to your computer. A direct download link is found here for the Wifi only Nexus 7: https://dl.google.com/dl/android/aosp/nakasi-jwr66v-factory-d341d356.tgz
The image for the GSM/HSPA+ Nexus 7 is found right here: https://dl.google.com/dl/android/aosp/nakasig-jwr66v-factory-aebc7b11.tgz
Please be careful to download the correct factory image!!
The instructions below are for the Wifi only tablet.. if you have a GSM/HSPA+ tablet your instructions are pretty much identical except for a tiny change in the filenames.. Any file that contains the word "nakasi" is instead "nakasig" for the GSM/HSPA+ tablet... As well, your files will contain the codename "tilapia" instead of "grouper" Make note of that when you type in the fastboot command to flash the factory image!

While a link to the Google page you can search on if you need, is here: http://developers.google.com/android/nexus/images

2. Extract the files from that downloaded file. This will give you a folder called "nakasi-jwr66v"... and inside of that you will see the files we are going to fastboot to your tablet. We want to place these files into the folder we located earlier which contains our "fastboot" file. Move or copy them over to that folder.
Note: On Linux/Ubuntu you may just extract them to any easily located folder.. Create a new one on the desktop or your home folder is my recommendation.
For reference, there should be 4 files, named:
bootloader-grouper-4.23.img
flash-all.sh
flash-base.sh
flash-all.bat
image-nakasi-jwr66v.zip
*radio-tilapia-1231_0.18.0_0409.img <--- IF you downloaded the image for the 3G/HSPA+ Nexus 7 you will see this file and should move it as well as the others

3. Open a command prompt inside the folder we have set up our files in. On windows this can be done by holding shift as you right-click in the folder, then select "Open command window here". On Mac or on a Linux system you want to open a terminal/command prompt and navigate to that folder using "cd" or "change directory" commands. For example if your folder is called "fastbootfiles" and it is on your desktop, you would enter:
Code:
cd desktop
Code:
cd fastbootfiles

4. Power down your tablet. Reboot into the bootloader by holding Volume Down + Power until you see the bootloader screen. In red letters toward the top of the text you will see fastboot mode. Once here, plug it into your computer.

5. Let's make sure you have your fastboot drivers installed and recognizing your device. Enter in the command prompt:
Code:
fastboot devices
For Mac:
Code:
./fastboot-mac devices
And press enter. You should see "List of attached devices" Followed by a string of numbers. If you do not see this, you do not have your drivers installed correctly! Go back to Zero Neck's Unlocking guide and grab the correct drivers, and make sure you install them correctly. You can also find the procedure during the video posted by Ragnarokx.
If you got the expected response, let's move on to fastbooting you back to stock...

6. This first command is going to wipe all your old EVERYTHING from the device. Credit to our resident AC cowboy, Jerry Hildenbrand, for pointing out to me a minor bug with the Nexus 7 bootloader that makes this a wise step to do first. Type each of these lines followed by Enter between them, waiting for one to finish before moving on to the next:
Code:
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata

7. This command will flash the stock bootloader on to your device. Enter:
Code:
fastboot flash bootloader bootloader-grouper-4.23.img
And press enter. Make sure you type the command exactly as you see it.
Note: As we noted earlier, replace "fastboot" above with the exact name of the fastboot file in your folder, for your system, such as "fastboot-windows" or "fastboot-mac". Addtionally for Mac's only, the command should be entered as such
Code:
./fastboot-mac flash bootloader bootloader-grouper-4.23.img
Noting the period and forward slash before the command.
Going forward you Mac folks just remember that with the rest of the commands ;)

Now reboot the bootloader:
Code:
fastboot reboot-bootloader
Enter.

7 (b). **IF you have the 3G/HSPA+ Nexus 7 you should flash the radio file as well. Wifi-only Nexus 7's skip this step. To flash the radio file:
Code:
fastboot flash radio radio-tilapia-1231_0.18.0_0409.img
Enter.

8. This next command will both wipe your old system and flash the factory image in its place, which includes the stock system, recovery, kernel, and userdata partitions:
Code:
fastboot -w update image-nakasi-jwr66v.zip
Enter, and wait, make sure the command finishes. This might take a few minutes.

Reboot the bootloader again:
Code:
fastboot reboot-bootloader
Enter.

9. We are done with the hard part... pretty easy right? Now we're just going to lock that bootloader.
Code:
fastboot oem lock
Enter.
Yes, this step is optional but I strongly recommend it if you had issues earlier which led to this procedure. Now you can unlock again if you like, which will give your tablet that final full wipe to clear out any bad data remaining:
Code:
fastboot oem unlock
Enter.

10. Finally, reboot and setup your tablet again from scratch!
Code:
fastboot reboot
[/INFO]

That's it, we're done. You have a stock, factory Nexus 7 tablet to get right back to tinkering with to your heart's content. If you have any questions, comments, concerns, or a recommendation to make this guide clearer, please sound off and myself or someone else will be around to help you out!

Credit for much of this guide and its format also goes to AC Moderator, dmmarck. Show him the love as well!
 
Last edited:

oxymoron

It's been real...
Sep 5, 2011
781
412
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

Nice one, mang. 2 defs up
icon14.gif
icon14.gif
 
  • Like
Reactions: 2defmouze

adrian83

Member
Jul 19, 2012
6
0
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

one benefit from having nexus device is that the adb commands for all nexus device are same
 

markyoung04

Well-known member
Nov 8, 2010
104
4
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

THANK YOU! I totally hosed up messing with changing icons around using ROM TOOLBOX and if I had not run across this I would have been toast. Granted I was up until 2:00 am but hey that is part of the fun.

THANK YOU very much. Directions were simple to follow and I am unlocked, re-rooted, and ready to hose it up again.
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
one benefit from having nexus device is that the adb commands for all nexus device are same

Yep, love it, had this baby unlocked, rooted and all set up in about 10 mins yesterday, lol :)





THANK YOU! I totally hosed up messing with changing icons around using ROM TOOLBOX and if I had not run across this I would have been toast. Granted I was up until 2:00 am but hey that is part of the fun.

THANK YOU very much. Directions were simple to follow and I am unlocked, re-rooted, and ready to hose it up again.

That's awesome man, makes my day to hear that!

Sent from my Nexus 7 using Tapatalk 2
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

Guide updated... few edits for clarity and new Step 6 to fully wipe your old, possibly corrupted files and data off of the device. Thanks Jerry!
 
  • Like
Reactions: zero neck

hollip3020

Member
Dec 15, 2009
23
0
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

So, great guide, only problem is mine stops at:
sending 'system'... FAILED (unknown status code)

Also, it says the archive does not contain boot.sig, recovery.sig, or system.sig.

A little background:
I tried to change the battery image in the status bar using ROM toolbox and it killed SystemUI.apk. This led to the joy of no status bar or menu bar (hooray!), and even though I chose to back it up before I applied the battery image, the backup was nowhere to be found. I decided to just try to reflash the factory image, and now I can only boot to the bootloader.

Any ideas?
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
So, great guide, only problem is mine stops at:
sending 'system'... FAILED (unknown status code)

Also, it says the archive does not contain boot.sig, recovery.sig, or system.sig.

A little background:
I tried to change the battery image in the status bar using ROM toolbox and it killed SystemUI.apk. This led to the joy of no status bar or menu bar (hooray!), and even though I chose to back it up before I applied the battery image, the backup was nowhere to be found. I decided to just try to reflash the factory image, and now I can only boot to the bootloader.

Any ideas?

You made a backup in recovery and couldn't find it? The recovery should be able to locate automatically. Though I guess that's besides the point now if you ran the "erase" commands in step 6 already..

For now I would try redownloading the images and running the commands again. If it errors out try to get me the exact message and all details you can.

Sent from my Nexus 7 using Tapatalk 2
 

hollip3020

Member
Dec 15, 2009
23
0
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

You made a backup in recovery and couldn't find it? The recovery should be able to locate automatically. Though I guess that's besides the point now if you ran the "erase" commands in step 6 already..

For now I would try redownloading the images and running the commands again. If it errors out try to get me the exact message and all details you can.

Sent from my Nexus 7 using Tapatalk 2

No, ROM Toolbox asked if I wanted to backup SystemUI.apk and framework-res.apk and I said yes. Apparently, the built-in backup for ROM Toolbox doesn't work though.

I tried a fresh download of the factory image and I also tried a "flash stock + unroot" using the Nexus Toolkit (even though it uses the same process). Both result in the same error. Here it is in its entirety:
C:\r3superboot>fastboot-windows -w update image-nakasi-jrn84d.zip
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: 3.34
Baseband Version.....: N/A
Serial Number........: 015d2109ce440c1a
--------------------------------------------
checking product... OKAY
checking version-bootloader... OKAY
sending 'boot' (4884 KB)... OKAY
writing 'boot'... OKAY
sending 'recovery' (5228 KB)... OKAY
writing 'recovery'... OKAY
sending 'system' (432360 KB)... FAILED (unknown status code)​
 

hollip3020

Member
Dec 15, 2009
23
0
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

An update:

Just tried to flash the system and userdata partitions manually to no avail:

Code:
C:\r3superboot>fastboot-windows flash system system.img
sending 'system' (432360 KB)... FAILED (remote: (Nv3pBadReceiveLength))

C:\r3superboot>fastboot-windows flash userdata userdata.img
sending 'userdata' (104285 KB)... FAILED (remote: (Nv3pBadReceiveLength))
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
No, ROM Toolbox asked if I wanted to backup SystemUI.apk and framework-res.apk and I said yes. Apparently, the built-in backup for ROM Toolbox doesn't work though.

I tried a fresh download of the factory image and I also tried a "flash stock + unroot" using the Nexus Toolkit (even though it uses the same process). Both result in the same error. Here it is in its entirety:
C:\r3superboot>fastboot-windows -w update image-nakasi-jrn84d.zip
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: 3.34
Baseband Version.....: N/A
Serial Number........: 015d2109ce440c1a
--------------------------------------------
checking product... OKAY
checking version-bootloader... OKAY
sending 'boot' (4884 KB)... OKAY
writing 'boot'... OKAY
sending 'recovery' (5228 KB)... OKAY
writing 'recovery'... OKAY
sending 'system' (432360 KB)... FAILED (unknown status code)​

Hmm.. That's odd that it's failing there, even with the toolkit. I'm going to ask around a bit and research on my own and see if we can get past that. Fwiw I am SURE we can, so as we say, don't panic. I'll get back to you ASAP, sometime tomorrow after I get some info!

Sent from my Nexus 7 using Tapatalk 2
 
  • Like
Reactions: zero neck

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Just a quicky thought, try it with the tablet connected to a different USB port (one in the back if you're on a PC is preferred). Might not help but just a thought while I'm looking around for you.

Sent from my Nexus 7 using Tapatalk 2
 

hollip3020

Member
Dec 15, 2009
23
0
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

Just a quicky thought, try it with the tablet connected to a different USB port (one in the back if you're on a PC is preferred). Might not help but just a thought while I'm looking around for you.

Sent from my Nexus 7 using Tapatalk 2

Yeah, I'll try that. In the meantime though, another update.

If I do all the commands manually (e.g. fastboot-windows flash userdata userdata.img) I can get all of them sent and written, except system of course. Here's what I get:

Code:
C:\r3superboot>fastboot-windows flash system system.img
sending 'system' (432360 KB)... OKAY
writing 'system'... FAILED (command write failed (Unknown error))

Aren't unknown errors awesome!
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Yeah, I'll try that. In the meantime though, another update.

If I do all the commands manually (e.g. fastboot-windows flash userdata userdata.img) I can get all of them sent and written, except system of course. Here's what I get:

Code:
C:\r3superboot>fastboot-windows flash system system.img
sending 'system' (432360 KB)... OKAY
writing 'system'... FAILED (command write failed (Unknown error))

Aren't unknown errors awesome!

Lol so awesome! Haha

We'll get this squared away there is definitely something odd but obvious here, lol. I'm calling it a night but I'll be looking into it tomorrow more, and obviously keep me posted if you're able to figure it out.

Also going forward remember to make full nandroid backups in recovery before you try to tweak anything in the system ;)

Sent from my Nexus 7 using Tapatalk 2
 

hollip3020

Member
Dec 15, 2009
23
0
0
Visit site
Re: [GUIDE] Factory Image Restore for your Nexus 7

So, good news is it's fixed. Bad news is I didn't think to switch to a rear USB port before wasting so much time. I should know the simplest solution is usually the right one. Oh well, thanks for the help 2defmouze.

Also going forward remember to make full nandroid backups in recovery before you try to tweak anything in the system

Luckily I was still able to get to CWM to make a backup before I started this whole process (but after SystemUI.apk got borked), so now I'm in the process of restoring that and I'm going to grab the apk from the system dump posted on xda (what I should've done in the first place).