Nexus 7 (2012): Revert to Previous Firmware using Ubuntu 14.04

First of all, this is for the 2012 version of the Nexus 7 Wi-Fi. Though the steps for doing this on other Nexus devices may be similar enough to make following this post safe, I would still try to find some verification of that before doing it. Second, this will wipe the tablet of all data, applications and settings. With the exception of items that can be recovered via Google’s account backup service, you will lose everything on the tablet. I recommend using the USB link to back up any data you wish to keep before continuing.

I decided to post this after doing some research and reverting my Nexus 7 tablet – which had recently been updated to Android 5.1 – back to Android 4.1.2. If you’re wondering why I’d want to revert back, it’s safe to say you haven’t ran Lollipop on the 2012 Nexus 7. In fact, I haven’t ran it either, because crawled it would be a more fitting description. I suppose it’s to be expected that an OS three years newer than the hardware it’s installed on might make that hardware run sluggish, but I think it should be unjustified for a company with Google’s technical foundation to even release such an update for the device if it is going to be incapable of running in a state that provides any kind of real experience. A lot of us are used to being a step or two behind when it comes to Android updates anyway, especially with the pace that most phone manufacturers push out their updates.

To get back on subject, the process of reverting the Nexus back to an older version was actually quite easy. Though all of the tutorials and examples online referred to doing it from Windows – with occasional references to Mac in the form of “oh, just change this command to be like this,” nothing referred to using Linux. In fact, I couldn’t even find a location to download fastboot for Linux. Luckily, I didn’t need to. Apparently, Ubuntu has both fastboot and adb compiled in the repositories – at least for Ubuntu 14.04 – and supposedly from version 12.10 on. I believe there’s a PPA you can add to grab it if you’re using 12.04 or earlier, but I can’t speak to that from experience.

As far as the process of reverting the tablet to a former version goes, you can start with grabbing the image of whichever version you’re looking to revert to from Google’s page for factory Nexus images. Based on what I’ve seen since reverting back, OTA updates seem to be in succession, so you’ll be updating to the next immediate version (eg: from 4.1.2 to 4.2.2), in case you are afraid that you will have to re-image the tablet to go from one older version to a newer version that isn’t 5.1 Lollipop. You also want to make sure you have fastboot installed on your computer from the Ubuntu Software Center.

Make sure the tablet has USB debugging enabled. In newer versions of Android, you have to reveal the location, which is hidden by default, in Settings by first going to Settings -> About tablet and tapping several times on the Build number field. You’ll see a small message pop up saying that you’re on your way to becoming a developer. After a few more presses, there will be a new settings location under the System category titled Developer options, which holds the setting for enabling USB debugging. Make sure it’s enabled.

Next, power the tablet off, and then restart it by holding down all three physical buttons simultaneously (Power + Volume Up + Volume Down) until you see the Google splash screen and the Android bootloader screen. Lastly, make sure the tablet is plugged into the computer’s USB port using the charge cable. At this point, you’re done with the tablet itself and can set it aside (somewhere it won’t get knocked around!).

Now navigate to the tgz file for the factory image you downloaded. First, extract the archive. Then, open a terminal and navigate to the directory where the tgz and extracted folder are located. In my case, it was my Downloads folder, which can be easily accessed by:

cd ~/Downloads

Next, check the hash value of the archive and make sure it matches the one listed on Google’s page for the factory image you downloaded. In my case, I used 4.1.2. If using a different Android version, or the 3G tablet (which is codenamed nakasig instead of nakasi), you will obviously have a different filename.

jerry@Ubuntu:~$ md5sum nakasi-jzo54k-factory-973f190e.tgz
d906b505ccae0d439839d3c5fafb137a  nakasi-jzo54k-factory-973f190e.tgz

If the hash value matches, we’re good. If not, you need to re-download the file and check again. Assuming the hash was good, navigate to the folder that was extracted.

cd nakasi-jzo54k

Now we need to verify that fastboot recognizes the tablet is connected to the computer. If you just type fastboot into the terminal, it will return some information for what commands and options can be pushed to it. The command we need is devices.

fastboot devices

If the terminal line breaks directly back to prompt without listing any devices, it means the computer is not able to communicate with the tablet. You may need to restart the tablet, or you may not have enabled USB debugging. Otherwise, you’ll see a serial number beside the word fastboot.

Assuming your device was recognized, it’s now time to unlock the bootloader (which will wipe the tablet – make sure you backed up any important data beforehand) and flash the image.

fastboot oem unlock

At this point, the tablet will display a screen warning about unlocking the bootloader (guess I was wrong about being done with the tablet). Make sure Yes is selected and hit the power button. Once it returns to the bootloader screen, proceed with flashing the image to the tablet.

At this point, a lot of tutorials state to enter each fastboot command manually. If you look at flash-all.sh in a text editor, you’ll see that the shell script enters the exact same commands, but saves you the work of doing it. I decided to use the shell script.

./flash-all.sh

At this point, you’ll see fastboot spitting some information and time lapses into the terminal. You want to leave it alone until it finishes. You’ll know when it’s done, because it will end with the following lines:

rebooting...

finished. total time: 105.989s

The value for total time will vary, but it typically shouldn’t take more than 2-3 minutes. Still, I would wait for 30 minutes if it seemed to take that long, because I would assume that trying to interrupt the process could cause problems for the tablet.

After the process has finished, the tablet will automatically restart and boot into the reverted Android version. It will prompt you with a screen similar to the one it did when you bought the tablet and turned it on for the first time. At this point, I would follow the prompts and any steps it has you do to initialize the tablet. But once you’re at the home screen, you will want to go to Settings -> Developer options, turn the slider from OFF to ON and then check to enable USB debugging. Now turn the tablet back off and reboot into the bootloader.

Once you’re into the bootloader and verified with fastboot that the tablet is recognized, re-apply the bootloader lock to re-secure the tablet and help protect your data.

fastboot oem lock

The main reason for doing this is to protect the data on your tablet, in case it is ever lost or stolen. If the bootloader is locked, fastboot and adb cannot be used to access or manipulate data on the tablet – and unlocking it again will wipe the data again. If it is left unlocked, this safeguard will not be in place.