Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A step-by-step guide how to manually flash the Android 5.0.1 (LRX22C) OTA-Update on a Nexus 5 with modified system (custom recovery/kernel, rooted, modified framework etc.)..

Update: For those interested, here's the version for updating from Android 5.1.0 (LMY47D/LMY47I) to Android 5.1.1 (LMY48B):
https://gist.github.com/eyecatchup/dab5cf7977008e504213


  UPDATE `NEXUS 5` 
     SET `VERSION`='5.0.1', `BUILD`='LRX22C', `RECOVERY`='CUSTOM', `ROOTED`=1 
   WHERE `VERSION`='5.0' && `BUILD`='LRX21O' && `RECOVERY`='CUSTOM' && `ROOTED`=1 
         && `WANNA_KEEP_USERDATA`=1;

A manual OTA for rooted hammerheads, quasi.

When you tampered with the Android system, you can't install OTAs; installation fails. Sometimes it's enough to flash the stock recovery to use adb sideload update.zip, but often, especially when you tampered a lot, this also fails.

Even after unrooting and flashing stock boot, recovery and cache it can fail. So one might ask whether the only way is to do a clean install using the latest factory image instead. For those who ask themselves this question: Before you do so, take a minute and read on.


This document describes how I successfully updated my Nexus 5 from stock Android 5.0 (LRX21O) with TWRP 2.8.1.0 and rooted with SuperSU to Android 5.0.1 (LRX22C) with TWRP 2.8.2.0 and rooted with SuperSU - without loosing user data.

NOTE: The steps outlined in this document assume the Android SDK to be installed on your PC and the adb, fastboot and android.[bat|sh] to be in your PATH variable! Oh, and if it burns down your house, it's not my fault. Proceed at own risk.

Download & prepare files

  • Download OTA zip from Google's servers to your PC.
    http://goo.gl/dx2JoM - signed-hammerhead-LRX22C-from-LRX21O.785a2f7a.zip

  • Rename the downloaded zip to 'update.zip' (without the quotes (and if you're on windows and known file extension are hidden, make sure you not end up with update.zip.zip)).

  • To the same folder, download the latest SuperSU flashable zip.
    http://goo.gl/XRK49m - UPDATE-SuperSU-v2.40.zip

  • To the same folder, download the latest TWRP recovery image for hammerhead.
    http://goo.gl/9GrBPl - openrecovery-twrp-2.8.4.0-hammerhead.img

  • To the same folder, download the 5.0 factory image tgz archive from Google's servers.
    http://goo.gl/Z8ITiM - hammerhead-lrx21o-factory-01315e08.tgz

  • From the 5.0 tgz archive extract the recovery.img, boot.img and system.img files to the same directory where your downloads are located.
    (Tip: With 7zip, for example, you can 'internally' open the archives within the archive and extract just the files you need. The same is possible with command line tools, of course.)

The directory structure should look like this now:

..
boot.img
openrecovery-twrp-2.8.4.0-hammerhead.img
recovery.img
system.img
update.zip
UPDATE-SuperSU-v2.40.zip

Time for the command line..

Open a terminal on your PC and cd into the directory where your downloaded files are located. Now go on by running the commands in the terminal as follows (type only those lines prefixed with '> ', but without actually typing the '> '!).

Update platform tools
# On Windows:
> android.bat update sdk -u -t platform-tools,tools
# On Linux/Mac:
> android.sh update sdk -u -t platform-tools,tools

You may need to accept a license agreement. Type 'y' and hit enter.

Do you accept the license 'android-sdk-license-5be876d5' [y/n]: y
Installing Archives:
  Preparing to install archives
  Downloading Android SDK Tools, revision 24.0.2
  Installing Android SDK Tools, revision 24.0.2
    Installed Android SDK Tools, revision 24.0.299%)
    Done. 1 package installed.</code>
Update adb
# On Windows:
> android.bat update adb
# On Linux/Mac:
> android.sh update adb

If adb was updated, command line will ask you to restart it. Do so.

adb has been updated. You must restart adb with the following commands
      adb kill-server
      adb start-server

--

Now, we're finally ready to go..

Time for flashing..

Connect your device (USB debugging enabled, of course) to your PC.

Back at your terminal, go on by running the commands as follows (type only those lines prefixed with '> ', but without actually typing the '> '!).

# Make sure the device is recognized
> adb devices

# Boot into bootloader mode
> adb reboot bootloader

# In bootloader mode, make again sure the device is recognized
> fastboot devices

# Flash stock LRX21O recovery image
> fastboot flash recovery recovery.img

# Flash stock LRX21O system image
> fastboot flash system system.img

# Flash stock LRX21O boot image
> fastboot flash boot boot.img

When the last flash is confirmed, use the volume rockers to choose 'Recovery mode' and confirm with the power button.

When you see the little Android lying with the red triangle warning sign on it, hold the power then press the volume up button to get to the recovery options.

When you got to the recovery options, select 'apply update from ADB' using the volume rockers again and press the power button to choose it. When the device says it's awaiting commands, type from the PC's command line:

adb sideload update.zip

When OTA update successfully installed, select 'reboot bootloader' from the recovery options again using the volume rockers and press the power button.

Back in bootloader mode, type from the PC's command line:

fastboot flash recovery openrecovery-twrp-2.8.4.0-hammerhead.img

When the flash is confirmed, use the volume rockers to choose 'Recovery mode' and confirm with the power button.

Now in the TWRP recovery menu, choose 'Advanced' > 'adb sideload'. Check both option, clear 'Dalvik-Cache' and 'Clear Cache' and swipe the bar to start sideload mode. When the device says it's awaiting commands, type from the PC's command line:

adb sideload UPDATE-SuperSU-v2.40.zip

When done, confirm to reboot system. Finished. Mission completed.

You're now on 5.0.1 with your custom recovery, rooted and can pick up from where you left.

PS: First boot, as always, will take some minutes.

@jonmcoe

This comment has been minimized.

Copy link

commented Dec 19, 2014

it works - thanks. really screwed me up that TWRP doesn't work with this.
Nexus 5 stock recovery menu is actually pretty easy - hold power, tap volume up
http://www.android.gs/how-to-boot-recovery-mode-for-google-nexus-5/

@hhggit

This comment has been minimized.

Copy link

commented Dec 20, 2014

“Try it a couple of times until the recovery options appear. (It may work at the first try, but sometimes it may require like 38 attempts. Just keep trying. ;))”
I had tried it hard for many times but it went the unexpected ways that either showning the laying down android robot or staring the normal system.

@deloz

This comment has been minimized.

Copy link

commented Dec 20, 2014

thank you very much, success for Nexus 5 from 5.0. to 5.0.1!

if you are doing adb start-server , and it show " failed to start", you can use adb nodaemon server, and open a new CMD window(Windows), and use the adb command.

if you are doing adb sideload update.zip, and it show "You need adb version 1.0.32 or above",
please use the newest version adb in sdk tools directory. you can download sdk tools from google website http://developer.android.com/sdk/installing/index.html?pkg=tools, and add the tools directory to operator system PATH

while it show "5.0.1 error in sideload package.zip status 7 " , just redo the mission.

if not show TWRP recovery menu , just redo fastboot flash recovery openrecovery-twrp-2.8.2.0-hammerhead.img

there are all my do.

@dannywillems

This comment has been minimized.

Copy link

commented Dec 20, 2014

When I try "adb sideload update.zip", it stopped at 61% and show my N5 : "[...] has unexpected contents E.Error in /sideload/package.zip status 7" when it verifies current system.

I redo it 3 times, and always the same.

@davrux

This comment has been minimized.

Copy link

commented Dec 20, 2014

Just tried and it works. Thanks!

@davehardy20

This comment has been minimized.

Copy link

commented Dec 21, 2014

Worked like a charm, thanks you very much!!

@noname2062

This comment has been minimized.

Copy link

commented Dec 21, 2014

Instructions are perfectly laid out. Everything worked great! Couldn't get SU to sideload, but I suspect issue is on my end I suppose. Thanks again

@banasiak

This comment has been minimized.

Copy link

commented Dec 23, 2014

Excellent instructions, thanks! I just swapped out the appropriate files and this procedure worked fine for the 2013 Nexus 7. Also couldn't get TWRP to start the SuperSU sideload, but maybe I wasn't being patient enough. I just did a...

adb push UPDATE-SuperSU-V2.40.zip /sdcard

...and installed it manually via TWRP.

@ericntd-legacy

This comment has been minimized.

Copy link

commented Dec 23, 2014

Works like a charm, thanks mate!

@deadmantfa

This comment has been minimized.

Copy link

commented Dec 23, 2014

Thank you, Great Job , keep up the great work brother

@xhcnb

This comment has been minimized.

Copy link

commented Dec 26, 2014

IT WORKS!!! Thanks a lot!

@onedyle

This comment has been minimized.

Copy link

commented Dec 26, 2014

Thank you so much. Works perfectly.

@robrich

This comment has been minimized.

Copy link

commented Dec 28, 2014

@jonmcoe is right, it's trivial to get into stock recovery: power then volume up. PR from https://gist.github.com/robrich/f6c9f5bb7d483871feee

@eyecatchup

This comment has been minimized.

Copy link
Owner Author

commented Dec 29, 2014

@robich yes, I also recognized this now (after I've read @jonmcoe's comment). True, it's actually trivial. As long as you follow the correct instructions. I'm not sure why, but all guides, I've been gone through so far, explained it wrong - as they suggested that you'd need to do it simultaneously?! Anyway. To get it right for this guide, I'd like to "merge" your "PR". Now, either I'm blind or dumb (or it's cause I'm on mobile).. But, is there any real PR functionality for gists? Or were you suggesting your version as "PR" PR?

@eyecatchup

This comment has been minimized.

Copy link
Owner Author

commented Dec 29, 2014

Updated gist.

@NimoTh

This comment has been minimized.

Copy link

commented Dec 30, 2014

Why don't you directly get, unpack and flash the 5.0.1 recovery, system and boot? Why the detour via old 5.0 images?

@eyecatchup

This comment has been minimized.

Copy link
Owner Author

commented Dec 30, 2014

Of course, you could also dirty flash the respective 5.0.1 partitions. That's one solution.

However, from my flashing experience (which dates back to the GRF39K for the Nexus One), I found to have less corrupted flashes (meaning, that the procedure resulted in anything between boot loops and, at best, permanent FCs) when I dirty flash the current version's required partions, applying the official OTA, and flashing back my custom recovery and install the latest SuperSU zip.

It might be totally up to my side and upstream dirty flashing might be as "safe" as this method. Who ever knows!? Anyway, both methods are equally valid and should both work the same. Just for said reason, I use the, let's say, "less-straight-forward way".

But, to be fair, if everything is set up, it's actually also not that much of a work. ;) (PS: And a guide, as detailed as this, for the other method, BTW, is probably just as "long" as this guide.)

@DIGINEX-zz

This comment has been minimized.

Copy link

commented Jan 9, 2015

From the command lines on updating the platform-tools, I get an error "please consider trying to update again without a package filter" and the confirmation message you've displayed doesn't even shown up.
Then went over through adb update and , followed the kill-server and start-server respectively. Then the rest of the flashing commands went smoothly till the sideload began from stock recovery.

"adb sideload update.zip"

Protocol Error within the command terminal and displayed, "You need to update to ADB 1.0.32 to sideload from this device".

From the SDK UI, the Android SDK tools and Android Platform-tools have been updated to latest. What really hinders the ADB from getting updated, The first command "android.bat update sdk -u -t platform-tools,tools" went running from cd to path "C:\Program Files (x86)\Android\android-sdk\tools"

Thanks.

@lahwran

This comment has been minimized.

Copy link

commented Jan 10, 2015

I used this to update from 4.4.4 ... and somehow ended up on 5.0.0? what? retrying the guide again, since presumably it goes from 5.0.0 to 5.0.1...

@DIGINEX-zz

This comment has been minimized.

Copy link

commented Jan 10, 2015

My ADB issue is solved at last, Please fix the TWRP version to 2.8.1.0 from 2.8.2.0, as it may not push out of the curtains for most of the users. I panicked at very similar point and end up spending a few hours figuring up this!

@nathantsoi

This comment has been minimized.

Copy link

commented Jan 14, 2015

thx @eyecatchup, worked great. I put the whole thing in a bash script if anyone else needs to do this: https://gist.github.com/nathantsoi/e36c5a2f2e94ce5ebb85

@eyecatchup

This comment has been minimized.

Copy link
Owner Author

commented Jan 19, 2015

seems useful to me, @nathantsoi. ty

@consultant1027

This comment has been minimized.

Copy link

commented Jan 23, 2015

Can someone confirm what (if anything) should be changed in the instructions to go from 4.4.4 to 5.0.1?

@djhworld

This comment has been minimized.

Copy link

commented Jan 24, 2015

@consultant1027

I just did exactly this but I played it safe by upgrading to 5.0 first, my setup was as follows

  • Nexus 5 running 4.4.4
  • TWRP 2.6 installed.

Disclaimer: please be careful, this worked for me but might not work for others!

Upgrading to 5.0.0

Follow the instructions here, these are a fork of the instructions above, the difference is you are downloading the 5.0.0 OTA update and 4.4.4 factory image instead of the 5.0.1 OTA update and 5.0 factory image

Upgrading to 5.0.1

Once I was on 5.0.0, I performed everything above "as is" and it worked great!

Thanks @eyecatchup !!

@Karmac

This comment has been minimized.

Copy link

commented Feb 7, 2015

Awesome working perfectly! thanks!

@minj2me

This comment has been minimized.

Copy link

commented Feb 16, 2015

UPDATE-SuperSU-v2.40.zip was working perfectly, thank you!

@DavidRamos015

This comment has been minimized.

Copy link

commented Feb 25, 2015

Thanks a lot, I was thinking my nexus died cause I deleted all data trying to root in last week (Sistem, Recovery,etc.)

Now it works.

@leewc

This comment has been minimized.

Copy link

commented Feb 28, 2015

This was great, thank you! Also note to some people who might get stuck on this part:

"When you see the little Android lying with the red triangle warning sign on it, hold the power then press the volume up button to get to the recovery options."

Notice that the tutorial mentions HOLD the power THEN press the volume up, if you hold power AND volume up you'll just do a force reboot. (at that time just do adb reboot bootloader again)

EDIT: also, if you happen to receive an error about not having permissions when in stock recovery:

adb sideload update.zip
loading: 'update.zip'
error: insufficient permissions for device

Just do 'adb kill-server' then 'sudo adb start-server' which if it says adb command not found then manually point to the absolute path of adb, for example mine was in /Development/android/android-sdk-linux/platform-tools/adb

good luck!

@ev0rtex

This comment has been minimized.

Copy link

commented Mar 12, 2015

FYI, this is actually a pretty generic process and the same process will work with future updates and even on the Nexus 6 (except that download links will vary obviously). I just installed the 5.1 update (LMY47D) on my Nexus 6 using the same procedure. The only catch is that I had to unplug/replug my USB cable whenever I entered sideload mode so that adb would detect it.

@Leomosantos

This comment has been minimized.

Copy link

commented Mar 27, 2015

My Nexus 5 is running Android 5.0.1, with TWRP, Xposed and ElementalX kernel. Will I be able to update to 5.1 following these steps?

@jacobsin

This comment has been minimized.

Copy link

commented Apr 2, 2015

Thanks! Works for updating from 5.0.1 to 5.1.

@apporc

This comment has been minimized.

Copy link

commented Apr 9, 2015

I have just found that, the radio is needed to be rolled back too.

@singles

This comment has been minimized.

Copy link

commented Apr 23, 2015

Thanks you for this tutorial. Just used it (with minor changes) to update Nexus 4 from 5.0.1 to 5.1.0. 🍻

@mcampbell

This comment has been minimized.

Copy link

commented May 25, 2015

This worked fantastically well. I was stuck with a "release-keys" not matching issue trying to sideload 5.1.1 over 5.1 (a problem I've had since 4.4), and finally found this page and was able to get past it.

Thanks so much for putting this out in such a straightforward manner.

@anthonybaldwin

This comment has been minimized.

Copy link

commented May 31, 2015

Found this searching how to sideload the 5.1.1 OTA update to my rooted Nexus 6. Worked perfectly. Thank you!

@yuvilio

This comment has been minimized.

Copy link

commented Jun 4, 2015

Seems like twrp dropped the 'openrecovery' prefix. For my my 5.1.1 update on Nexus 5, the latest file was 'twrp-2.8.6.1-hammerhead.img' . The sideload command works fine. Thanks for this.

@eyecatchup

This comment has been minimized.

Copy link
Owner Author

commented Jun 29, 2015

For those interested, here's the version for updating to Android 5.1.1 (LMY48B): https://gist.github.com/eyecatchup/dab5cf7977008e504213

@eyecatchup

This comment has been minimized.

Copy link
Owner Author

commented Jun 29, 2015

If you run into the following error message:

target reported max download size of 1073741824 bytes
error: cannot load 'system.img'

Just use: fastboot flash -S 512M system system.img

(via)

@albinsuresh

This comment has been minimized.

Copy link

commented Aug 14, 2015

Can someone tell me where you get the OTA update links from? People have posted links for specific versions. But is there any generic URL or something where I can find OTA zips for different versions or rather the most recent version?

@hackel

This comment has been minimized.

Copy link

commented Aug 24, 2015

Just keep in mind this will still erase any customizations you may have made... build.prop, Xposed, busybox, init.d, etc. The Android update system really is crap.

@INFINITEKIFF

This comment has been minimized.

Copy link

commented Oct 13, 2016

My Nexus 5 is running Android 6.0.1, with TWRP, Xposed and ElementalX kernel. Will I be able to update to the 2016-10 security patches following these steps? sick of getting the notifcations which obviously dont go away until you apply the patch. obviously being a noob I discovered I cant apply these patches without first losing root since ota replaces twrp custom recovery right? or am I getting confised, theres so many steps?! I know last time I managed to do it from lollipop to MM but that wasnt a security patch update, so somehow updating the OS seemed easier, this whole security patch thing seems confusing and daunting?? what about if I have Flashfire installed, sint that supposed to retain Root? someone out there with a good idea about how to proceed safely? thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.