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]IntroA 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 FilesAre 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 ? ? ?
For Windows this should look like:
Code:
fastboot-windows ? ? ?
Code:
sudo fastboot-linux ? ? ?
Code:
./fastboot-mac ? ? ?
[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
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
4. Let's make sure fastboot is recognizing your device. Type this command and hit Enter:
Code:
fastboot devices
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
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
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
Happy fastbooting![/INFO]
Step-by-StepAnswers 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
Troubleshooting
Nexus 4 Factory Image Restore
Last edited: