[GUIDE] Nexus 4 - Factory Image Restore

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Nexus 4 Factory Image Restore

Hit a wall while hacking away on your unlocked Nexus 4? Don't Panic!! Whether you think you bricked your device, desire a clean slate to start over, or just want to play with some fastboot commands.. Nexus devices are the recipients of full Factory Images straight from Google, ensuring that we can recover from even the ugliest of situations and restore our device to brand new, out-of-the-box condition at any time. You will need a few files and a little familiarity with entering commands in a terminal / command prompt, but mostly just the ability to read and follow instructions. It's so easy, your grandma could do it! [WARN]Restoring the Factory Images will wipe EVERYTHING on your device, including the internal sdcard partition. If you can boot it up at all right now, you may wish to copy your photos, music, etc to your computer before we begin, else they will be lost. We are not responsible for your device and anything you do to it, but we will do our best to help[/WARN]
dontpanic_large.jpg
Intro
A few items you will need before we begin..
1. Factory Image The latest Factory Image for your device -- 4.3 (JWR66V) -- direct download link from Google: https://dl.google.com/dl/android/aosp/occam-jwr66v-factory-08d2b697.tgz
A link to the page where you can find the files yourself, if for some reason the direct link is not working: https://developers.google.com/android/nexus/images
Please check the md5 checksum after downloading. If you get anything other than: 9d33973a61fa9266244fc43397888703 -- you should redownload. If you don't know how to check an md5 on your operating system, Google it! :)

2. ADB and fastboot files Unless you used some kind of toolkit when you originally unlocked/rooted your device, you should have these already. They may be located in your Android SDK /platform-tools directory if you have that installed, or wherever you downloaded them to before. Make sure you know where they are. If you need to grab them again, I totally stole these from smarter people than me (namely PaulOBrien) and just took out stuff we don't need, and renamed it to avoid confusion for you guys. Download from here: https://dl.dropbox.com/u/47300967/nexus4-adb-fastboot.zip
*Mac users: Some Mac users have reported freeze-ups and other issues when the process gets to sending the system.img over to the device. AC users bshimrak and andr0idralphie were able to solve this by using updated adb and fastboot files, and bshimrak was kind enough to provide me those files, which I am mirroring here: https://dl.dropboxusercontent.com/u/47300967/android-MAC.zip
Mac users may need to use these adb and fastboot files. The steps should remain the same.

3. Drivers If you are on a Windows system (linux and mac need not bother with these): Universal Naked Driver 0.72.zip
Warning: Uninstall any previous driver package's you may have installed and also manually remove drivers by attaching your phone and going to Windows device manager and right click the entry for your phone and select "Uninstall" on the next prompt make sure to select "Delete the driver software for this device" then hit OK and reboot before installing these drivers
HUGE thanks to 1wayjonny at xda for these drivers!

Setup and Files
Are you still with me? Great... let's get started!

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. Know the exact folder containing the fastboot files you will be using.

[NOTE]Throughout these instructions I will be entering our commands in the format:
Code:
fastboot ? ? ?
However, you must remember to modify just the beginning part to reference the appropriate file for your system.
For Windows this should look like:
Code:
fastboot-windows ? ? ?
For Linux (note that sudo may be required before entering fastboot commands):
Code:
sudo fastboot-linux ? ? ?
For Mac (note that ./ is required before entering the commands on a Mac):
Code:
./fastboot-mac ? ? ?
[/NOTE]

[INFO]1. Extract the files from the Factory Image we downloaded from Google. The BEST app you can use for this is 7zip. I suggest Googling it and finding a version for your OS. Using other file archive apps (i.e. winrar, winzip, etc) may result in errors. Dive through the folders and you will find a number of files we are going to fastboot to your device. We want to place all of these files into the directory we located earlier which contains our "fastboot" file. Move or copy them over to that folder.

2. 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 you grabbed the zip I posted earlier and extracted it on your desktop, your folder is called "nexus4-adb-fastboot" on your desktop, and you would enter:
Code:
cd desktop
cd nexus4-adb-fastboot
Now your command prompt is ready in the correct directory for all of the following commands.

3. Boot into the bootloader/fastboot mode. Power down the phone, then hold Volume Down and Power until you see the familiar green robot, and a string of text on the left that begins with "fastboot mode" in red letters. You may also get here if your phone is powered on and plugged into the computer already by simply typing
Code:
fastboot reboot bootloader
in the prompt and hitting Enter. Regardless.. Plug it in now. If possible try to use a USB port in the rear of your computer, rather than the front. Yes, this can make a difference!

4. Let's make sure fastboot is recognizing your device. Type this command and hit Enter:
Code:
fastboot devices
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! You may need to remove them and try just reinstalling from the Setup tab earlier. If you got the expected response, let's move on to fastbooting you back to stock...

5. This first command is going to wipe all your old EVERYTHING from the device. This step isn't always needed, but it's a great idea to do it anyway. The code we use later to flash the Factory Image will also wipe it, but you may sometimes avoid bugs by doing it manually 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

6. These commands are going to flash the Factory Image to your device. Each command will flash a different component/image required to go to stock. You can copy and paste each command, but if they don't work type them in. There's a general "language" that's being spoken here, so as long as you understand that language you'll be able to get the general jibe of what's going on. Also, make sure each command is COMPLETE before going to the next.
Code:
fastboot flash bootloader bootloader-mako-makoz20i.img
fastboot reboot-bootloader
fastboot flash radio radio-mako-m9615a-cefwmazm-2.0.1700.84.img
fastboot reboot-bootloader
fastboot ?w update image-occam-jwr66v.zip
When the final command completes the phone should reboot itself. Let it do this without touching anything, all the way to the Welcome screen. Leave your command prompt window open, we aren't done just yet!

7. If you intend to keep your device unlocked and get back to playing with it, then you are done! Have fun! However, if you would like to re-lock your bootloader now that you have a stock device again, simply reboot into the bootloader just like we did earlier. In the command prompt type:
Code:
fastboot oem lock
fastboot reboot-bootloader
Hitting enter between each line, of course. Now you can boot up into your stock, locked phone. If you want to unlock that bootloader again (remember, doing so will wipe everything just as it did the first time) just boot into the bootloader again and use:
Code:
fastboot oem unlock

And that's it.. you have in your hands a completely restored, stock device and can get back to tinkering with it as much as you like. If you have any questions, comments, concerns.. just post them and myself or someone else will help you out as soon as we can. Also check the Troubleshooting tab for some solutions to common questions or errors. Credit to everyone who I stole borrowed files and verbatim for this guide :)

Happy fastbooting![/INFO]

Step-by-Step
Answers and Solutions to Common Issues
Q. When entering the commands I see the error "fastboot is not a recognized command"
A. Your command prompt just isn't looking in the correct location. Remember you had to locate the directory which contains your fastboot file, move all of the files extracted from the Factory Image to that directory, and then either tell the command prompt to look in that directory or open the command window from within that directory. Go back to Step 2 of the step-by-step and try again.

Q. Everything seemed to work.. but when I was flashing the image I saw these (or similar) messages:
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
A. Safe to ignore these.

Q. After the process completes I am getting stuck at the Android X or boot logo and cannot get past it.
A. Boot back into the bootloader and try locking and then unlocking it, simply using:
fastboot oem lock
followed by
fastboot oem unlock
And accept it on the phone. Sometimes the wipe this does is needed to fully clear the old data and caches.

Q. I got an error saying "FAILED (command write failed (Unknown error))"
A. Try using a different USB port. It's usually best, if possible, to use one in the back of your computer rather than the front.

Q. Message indicates the fastboot command is not in the correct syntax.. or I got an error sending the system portion.. or it seemed to freeze when sending system and won't boot up now.
A. Besides trying a different USB port, also try entering the final command switching up the "-w" portion to follow the "update" command, as in:
fastboot update ?w image-occam-jop40d.zip

Q. I got an error saying "FAILED (remote: (BadParameter))"
A. Your computer did not like flashing the last file, the big .zip containing the various parts of your system (specifically the boot, system, recovery, and userdata sections). Unzip that file, and make sure to move the extracted files once again to the same directory as your fastboot file. Now you are going to flash each of them one at a time, as in:
Code:
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash recovery recovery.img
fastboot flash userdata userdata.img
Please be sure to only enter these lines one at a time and let each one finish before entering the next. When done reboot.

Troubleshooting

Nexus 4 Factory Image Restore
 
Last edited:

BearDroid

New member
Nov 23, 2012
2
0
0
Visit site
Alright so I've done this countless times with my N7 and Gnex, and I tried this with the N4 a couple times and followed this guide, but I'm stuck at the boot screen and it just won't boot up. Anyone else run into this issue?
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Alright so I've done this countless times with my N7 and Gnex, and I tried this with the N4 a couple times and followed this guide, but I'm stuck at the boot screen and it just won't boot up. Anyone else run into this issue?

Have you unplugged it from the computer? That sometimes has to be done as soon as the restore completes..
 

BearDroid

New member
Nov 23, 2012
2
0
0
Visit site
Have you unplugged it from the computer? That sometimes has to be done as soon as the restore completes..

I have not. I will try that now.

Edit: So far it's not working. It's still stuck on the bootscreen.

Edit 2: I used the Nexus 4 Toolkit and it worked. I have no idea why and what the difference was. I followed the directions down to the .img and nothing worked.
 
Last edited:

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Housekeeping... updated link and instructions to reflect the new 4.2.1 (JOP40D) factory image.

Lol what's a guy gotta do to get stickied around here? Who's asleep at the wheel AC? :p
 

mzanette

Zee
Aug 22, 2012
826
14
18
Visit site
Friend of mine did a factory reset on his Nexus 4, and now he doesn't have the Emoji keyboard as an option any longer. On my Nexus it's called iWnn IME under language and input. I've found a .zip file on XDA that contains this keyboard, but I'm just curious as to how I go about installing it. Do I flash the entire .zip file through the fastboot/command line option, or can I take the iWnn IME.apk that I find inside the zip file and install that as a regular app? Anyone know?
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
Friend of mine did a factory reset on his Nexus 4, and now he doesn't have the Emoji keyboard as an option any longer. On my Nexus it's called iWnn IME under language and input. I've found a .zip file on XDA that contains this keyboard, but I'm just curious as to how I go about installing it. Do I flash the entire .zip file through the fastboot/command line option, or can I take the iWnn IME.apk that I find inside the zip file and install that as a regular app? Anyone know?

If it was a part of stock, it should have been included when he correctly flashed the factory image.

In terms of the zip you found, you would want to flash it using a custom recovery. You can boot into TWRP temporarily for that purpose, just follow the steps in the Root It! tab in my Unlock guide, and flash that zip instead of the SuperSU one.

Sent from my Nexus 4 using Tapatalk 2
 

mzanette

Zee
Aug 22, 2012
826
14
18
Visit site
If it was a part of stock, it should have been included when he correctly flashed the factory image.

In terms of the zip you found, you would want to flash it using a custom recovery. You can boot into TWRP temporarily for that purpose, just follow the steps in the Root It! tab in my Unlock guide, and flash that zip instead of the SuperSU one.

Sent from my Nexus 4 using Tapatalk 2

That's that's what I suspected. Just note, he didn't actually FLASH the factory image, he went into the phone settings -->Backup and reset--> "Factory data reset"
 

wahaha686

Member
Dec 9, 2012
7
0
0
Visit site
HELP....NO IDEA WHAT TO DO

I followed the instruction, all successful, until I input "./fastboot-mac -w update image-occam-jop40d.zip"

- 1st try,
Code:
checking product... OKAY
checking version-bootloader... OKAY
checking version-baseband... OKAY
sending 'boot' (6166 KB)... OKAY
writing 'boot'... OKAY
sending 'recovery' (6664 KB)... OKAY
writing 'recovery'... OKAY
sending 'system' (531285 KB)... ERROR: usb_write failed with status e00002be
FAILED (data transfer failure (No such file or directory))

- 2nd try....I'm confident I didn't misspell, so I re-enter the code again and IT GETS STUCK
Code:
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
 

2defmouze

Well-known member
Jul 9, 2011
3,945
1,552
0
Visit site
HELP....NO IDEA WHAT TO DO

I followed the instruction, all successful, until I input "./fastboot-mac -w update image-occam-jop40d.zip"

- 1st try,
Code:
checking product... OKAY
checking version-bootloader... OKAY
checking version-baseband... OKAY
sending 'boot' (6166 KB)... OKAY
writing 'boot'... OKAY
sending 'recovery' (6664 KB)... OKAY
writing 'recovery'... OKAY
sending 'system' (531285 KB)... ERROR: usb_write failed with status e00002be
FAILED (data transfer failure (No such file or directory))

- 2nd try....I'm confident I didn't misspell, so I re-enter the code again and IT GETS STUCK
Code:
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------

Try using a different usb port, one in the back if possible. Also redownload the file.

Sent from my Nexus 4 using Tapatalk 2
 

cjhudelson

Member
Oct 24, 2012
8
0
0
Visit site
Thank you so much for the guide. Everything seems to be working well, except I got the three boot, recovery, and system.sig errors. When my Nexus 4 reboots, it seems fine until it gets to the "X" splashcreen. It has now been stuck at this point for about 45 minutes. I have tried going through the entire process multiple times now, and have downloaded the stock file multiple times as well. It won't boot either plugged in or unplugged via usb.

Someone help.... Please???
 

Trending Posts

Forum statistics

Threads
943,112
Messages
6,917,348
Members
3,158,828
Latest member
DragnDon