I love a clean start. There’s nothing like the feel of a smartphone (or PC) after a factory reset.
I’m using my Nexus 5 for almost a year now. For a while, I’ve been wanting to do a factory reset and start clean. The upcoming Lollipop upgrade is exactly the push I needed to do it.
My game plan:
- Before upgrading:
- After upgrading:
- Restore apps, data, settings and configuration, as needed.
- Explore what new built-in features can replace 3rd party apps I’m using. I always prefer built-in over 3rd party.
Initially, I planned to wait for the OTA update. I figured it would simplify the process, and should reach my device soon enough. Google started rolling out the OTA on November 12th 2014. Like most Android updates, this rollout was in “waves”. 3 days later, the waves still didn’t reach my Nexus 5.
With the factory images already available, I started wondering why I’m waiting for the OTA over going manual. I figured that the only downside of going manual with the factory image is having to perform full wipe to unlock the bootloader. That doesn’t bother me, since I want to factory reset any way!
I decided to pursue the manual upgrade route, which I describe in this post.
Warning: This process requires using the fastboot tool over USB from a terminal. While not too complicated, it does require being comfortable with doing such things. Also, enabling USB debugging and unlocking the bootloader exposes your device to extra security risks (even if for a short time). Proceed with caution, or prefer going the OTA route.
The upgrade process
It’s also useful to have the adb tool, but not mandatory. If you have the Android SDK, you have adb.
Next, download the Lollipop factory image for your Nexus. You can find it in this list for the Nexus 5. The list includes MD5 and SHA-1 checksums. I strongly advise that you verify the downloaded image using these checksums! (in OS X: run
md5 filename or
shasum -a1 filename; in Linux: run
md5sum filename or
sha1sum filename; in Windows: see HashTab). You don’t want to find out your download was corrupt only after bricking the device… Unzip the image somewhere.
Flashing the image
- First, you need to go into fastboot mode.
- If you have adb, run
adb reboot bootloaderwith the device connected via USB.
- An alternative method is using a key combo. For Nexus 5, turn the device off, turn it on, and immediately hold the Volume Up + Volume Down + Power buttons.
- If you have adb, run
- Unlock the bootloader (if it’s locked, which is likely) by running
fastboot oem unlock. This step wipes all data on the device!
- In terminal, cd to the unzipped image directory. It contains the flash-all script, that performs the installation steps. You can run it, but I preferred looking into what it does, and chose to perform the individual commands on my own:
~ $ fastboot oem unlock ... OKAY [ 99.477s] finished. total time: 99.477s ~ $ ~ $ cd ~/aux/Downloads/hammerhead-lrx21o/ ~ hammerhead-lrx21o $ cat flash-all.sh #!/bin/sh # Copyright 2012 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. fastboot flash bootloader bootloader-hammerhead-hhz12d.img fastboot reboot-bootloader sleep 5 fastboot flash radio radio-hammerhead-m8974a-188.8.131.52.21.img fastboot reboot-bootloader sleep 5 fastboot -w update image-hammerhead-lrx21o.zip hammerhead-lrx21o $ fastboot flash bootloader bootloader-hammerhead-hhz12d.img sending 'bootloader' (2579 KB)... OKAY [ 0.241s] writing 'bootloader'... OKAY [ 0.491s] finished. total time: 0.732s hammerhead-lrx21o $ fastboot reboot-bootloader rebooting into bootloader... OKAY [ 0.001s] finished. total time: 0.001s hammerhead-lrx21o $ fastboot flash radio radio-hammerhead-m8974a-184.108.40.206.21.img target reported max download size of 1073741824 bytes sending 'radio' (45521 KB)... OKAY [ 1.776s] writing 'radio'... OKAY [ 3.128s] finished. total time: 4.904s hammerhead-lrx21o $ fastboot reboot-bootloader rebooting into bootloader... OKAY [ 0.001s] finished. total time: 0.001s hammerhead-lrx21o $ fastboot -w update image-hammerhead-lrx21o.zip target reported max download size of 1073741824 bytes archive does not contain 'boot.sig' archive does not contain 'recovery.sig' archive does not contain 'system.sig' archive does not contain 'tos.img' Creating filesystem with parameters: Size: 29236371456 Block size: 4096 Blocks per group: 32768 Inodes per group: 8192 Inode size: 256 Journal blocks: 32768 Label: Blocks: 7137786 Block groups: 218 Reserved block group size: 1024 Created filesystem with 11/1785856 inodes and 156120/7137786 blocks Creating filesystem with parameters: Size: 734003200 Block size: 4096 Blocks per group: 32768 Inodes per group: 7472 Inode size: 256 Journal blocks: 2800 Label: Blocks: 179200 Block groups: 6 Reserved block group size: 47 Created filesystem with 11/44832 inodes and 5813/179200 blocks -------------------------------------------- Bootloader Version...: HHZ12d Baseband Version.....: M8974A-220.127.116.11.21 Serial Number........: ******************** -------------------------------------------- checking product... OKAY [ 0.101s] checking version-bootloader... OKAY [ 0.096s] checking version-baseband... OKAY [ 0.100s] sending 'boot' (8852 KB)... OKAY [ 0.580s] writing 'boot'... OKAY [ 0.762s] sending 'recovery' (9552 KB)... OKAY [ 0.648s] writing 'recovery'... OKAY [ 0.803s] erasing 'system'... OKAY [ 1.287s] sending 'system' (981596 KB)... OKAY [ 35.925s] writing 'system'... OKAY [ 66.657s] erasing 'userdata'... OKAY [ 15.627s] sending 'userdata' (139109 KB)... OKAY [ 5.241s] writing 'userdata'... OKAY [ 9.402s] erasing 'cache'... OKAY [ 0.631s] sending 'cache' (13348 KB)... OKAY [ 0.700s] writing 'cache'... OKAY [ 1.080s] rebooting... finished. total time: 140.068s
After this, the device is flashed, and the upgrade is complete. The device now boots into Lollipop! Hurray!
Relocating the bootloader
After flashing the image, it is recommended to lock the bootloader again.
To do this, start the device in fastboot mode again, and run
fastboot oem lock.
Unlike the unlock command, this does not wipe any data.
This is how I upgraded my Nexus 5 to Lollipop, using the factory image from Google.
Manual image flashing isn’t too hard, but probably also not for everyone. If you choose to go through with it, do it at your own risk! 🙂