yashsingh1/xdaforums huggingface dataset:
[Nexus 5 General] aerozolic:
[TUTORIAL] How to flash a factory image | Return to stock | Unroot your Nexus 5

You run TWRP from your computer and the script from internal memory. You need unlocked bootloader to run TWRP
[Nexus 5 General] osm0sis:
Anybody else have a device on which my BootUnlocker zip doesn't work with CWM? [MENTION=4173463]aletto[/MENTION] is taking awhile to answer his PMs. ;)

I need a volunteer to try a hopefully fixed version. I removed the TWRP getprop workaround since the latest TWRP doesn't need it anymore, and hopefully this will fix CWM on the subsection of hammerhead devices that wouldn't work.
[Nexus 5 General] faultytowersdude:
Ah I see that's clever :), looks like I'll have to unlock then relock then. Want to keep stock just in case.
[Nexus 5 General] aletto:
Sorry for the delay - Life's been very busy and I simply forgot. I already posted that though.
[Nexus 5 General] osm0sis:
Please try the new version I PM'd you. :)
[Nexus 5 General] osm0sis:
[MENTION=4346614]abaaaabbbb63[/MENTION] I need some follow-up on this. Could you or anyone who wants to help please test:
[Nexus 5 General] Cronnny:
Thanks

Thanks you very much for this gonna keep the files on my computer for backup :) Great to see posts like this here!
[Nexus 5 General] hpsauce37:
been trying to follow the video guide posted (for windows) but every time i get to the final line to type in the cmd window it comes up with an error say fastboot has stopped and the phone does not reboot?

help please
[Nexus 5 General] jd1639:
If you type. fastboot devices. Do you see your device?
[Nexus 5 General] hpsauce37:
where do i type fastboot devices?

---------- Post added at 06:52 PM ---------- Previous post was at 06:38 PM ----------

seems to go through every stage fine but when i hit enter on the last command there is a pause and then i get a windows error message saying fastboot has stopped working
[Nexus 5 General] hpsauce37:
tried this time and time again now and really cant see what im doing wrong, all the other stages complete fine and say 'ok'

its just that last one thats says fasboot.exe has stopped working

anyone any ideas please...just want to get back to standard....i have stock rom just want no root on there!
[Nexus 5 General] abaaaabbbb63:
What method did you use? When exactly does the window stop responding?
[Nexus 5 General] hpsauce37:
following the youtube guide here http://www.androidrootz.com/2013/11/how-to-unroot-nexus-5-complete-stock.html

which i think is your method 2?

i enter the last cmd (copy and past them to make sure entered correctly) and then when i press enter there is a pause and then i get an a windows box come up saying 'fastboot.exe' has stopped working

Appreciate any help as im getting myself in a right pickle over this!

ok,

just tried your method 1 from here and it starts to flash the files, after the radio and then into bootloader it then says finished (dont know if it actually had) and thats when i then get the windows message.

I thought that it may have actually done everything it needs to and so i went to recovery but its showing me clockwork rom manager recovery (not sure if it should be ) so not sure if i should then factory reset or not?

Bound to be something stupid im doing but not really up to speed on all this flashing and rooting stuff
[Nexus 5 General] faultytowersdude:
Trying to relock bootloader and reset flag got this error,

I'm following the guide where I be going wrong ?

C:\Users\The Dude>fastboot boot path/to/TWRP.img

cannot load 'path/to/TWRP.img': No such file or directory
[Nexus 5 General] abaaaabbbb63:
Try flashing the recovery.img separately. Use the command "fastboot flash recovery recovery.img".

The best I can do is test the new Nexus 4 bootloader. I'll post when I'm done.
[Nexus 5 General] abaaaabbbb63:
Ok, so I tested with the latest 4.4 Nexus 4 bootloader. Zip works, locks/ unlocks properly. fastboot oem lock doesn't affect the tamper flag. All is good :D

fastboot oem unlock does change the tamper flag to true.
[Nexus 5 General] osm0sis:
For the Nexus 4 I'd like to know if the new bootloader version from the KitKat OTA enabled the tamper flag being set to true on fastboot oem unlock or at all so please do let me know about that if you can. :)
[Nexus 5 General] hpsauce37:
thanks for the help but could you please do a quick step by step for me?

I tried your method 1 and then it stops, you say flash the recovery img separatley..how do i do that?
[Nexus 5 General] faultytowersdude:
Need some help resetting the tamper flag, keep getting an error

Unable to open TWRP on internal memory for some reason

UPDATE - managed to sort it did not realise TWRP had to be in platform tools folder I thought that had to be on phone storage, so now bootloader locked and tamper set to false. Managed to learn something new :)
[Nexus 5 General] hpsauce37:
i just tried this and got an error cannot open 'recovery.image'
[Nexus 5 General] abaaaabbbb63:
Follow method 2, but when the entering commands part comes, only type "fastboot flash recovery recovery.img", and ignore the other commands.

What error?
[Nexus 5 General] jd1639:
I ran the zip in twrp 2.6.3.2 and it worked great. What recovery are you using?
[Nexus 5 General] iB4STiD:
edit
[Nexus 5 General] jd1639:
Fastboot oem device-info
[Nexus 5 General] abaaaabbbb63:
Type the command:

fastboot oem device-info

If tampered=true, then here you go.
[Nexus 5 General] mido2malik:
Thanking

Thanks a lot.
[Nexus 5 General] hpsauce37:
still getting and error saying 'cannot open recovery.image'

any other ideas?
[Nexus 5 General] abaaaabbbb63:
It's recovery.img, not recovery.image. Are you sure you wrote it properly?

Try moving the recovery.img on another disk. Like, from C to D. Then try again.

fastboot flash recovery path/to/recovery.img
[Nexus 5 General] hpsauce37:
ok so i have the recovery.img (thats the name of the file as i see it on my c drive) on my c drive, i copy the command you gave which is

fastboot flash recovery recovery.img

phone is in fastboot mode (and connected as it should be as far as i am aware)

i open a cmd window and type in fastboot flash recovery recovery.img

get error message cannot open 'recovery.img'

im sure its just me but i do appreciate the help.

---------- Post added at 09:40 PM ---------- Previous post was at 09:22 PM ----------

i think there is a problem with the cmd path to the c drive where the files are? dont know how to check or correct it though :(
[Nexus 5 General] abaaaabbbb63:
You are writing the command wrong:

fastboot flash recovery path/to/recovery/img.

Lets say you have your recovery.img in a folder named Android on your C drive. Then it would be:

fastboot flash recovery C://Android/recovery.img
[Nexus 5 General] hpsauce37:
So when i open a cmd window and type

fastboot flash recovery path/to/recovery/img

i get

Microsoft Windows [Version 6.0.6002]

Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\hpsauce37>fastboot flash bootloader C:/image-hammerhead-krt16m/bootload

er.img

'fastboot' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\hpsauce37>fastboot flash recovery path/to/recovery/img

'fastboot' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\hpsauce37>fastboot flash recovery path/to/recovery/img

'fastboot' is not recognized as an internal or external command,

operable program or batch file.

C:\Users\hpsauce37>

sorry to be such a pain but im just not getting this and its a bit out of my comfort area lol
[Nexus 5 General] abaaaabbbb63:
You should have followed the instructions in the OP.

You don't have fastboot installed

http://www.redmondpie.com/how-to-set-up-android-adb-and-fastboot-on-windows-tutorial/

and, it's not literally /path/to/recovery.img!! You just replace that thing with the path to the recovery.img... like C:/Android/recovery.img

for example, if I would put the recovery.img on my desktop, the command will be:

fastboot flash recovery C:\Users\Andu\Desktop\recovery.img
[Nexus 5 General] hpsauce37:
adb is installed as per the guide

it says to confirm this i type adb devices in the cmd window and it shows my device as an attatched device.
[Nexus 5 General] abaaaabbbb63:
ok, now boot in fastboot, and type the command above.
[Nexus 5 General] nbogan1:
When I download the factory image from the website provided, all I get is hammerhead-krt16m-factory-bd9c39de.tar which I unzip and all that gets is a file called hammerhead-krt16m-factory-bd9c39de. I don't see any bootloader, radio or image
[Nexus 5 General] jd1639:
You need to extract it out of that file too
[Nexus 5 General] nbogan1:
Got it, didn't realize you had to extract twice. Much appreciated!!
[Nexus 5 General] aerozolic:
People who are unable to follow simple step by step instructions, don't know how to enter commands in a console/terminal or doesn't even know which way slashes are in their current OS shouldn't mess with stuff like flashing and so on :rolleyes:
[Nexus 5 General] td32:
Hi guys

I'm stuck at this point

★After everything finished, select "Recovery" using the volume buttons.

★When a small Android appears, press Power Button + Volume UP.

If i chose recovery mode and and then when the small android appears i press Power Button and Volume UP the phone loops between screen off and the google screen , while it i leave it boot normally it get to the language screen.

SO how do i get to this ?

★Select "Wipe data/factory data reset"

★Reboot. Your phone should be stock.

Thanks
[Nexus 5 General] jd1639:
If you get to the language screen you don't have to worry about doing the factory reset.
[Nexus 5 General] td32:
It says camera has stopped working and gallery has stopped working?

And they won't run!

What did it happen?
[Nexus 5 General] jd1639:
Just reboot
[Nexus 5 General] td32:
Thanks

I just boot twrp and wiped from there and then flashed the Nexus BootUnlocker script zip.

I just noticed though that twrp created a folder

http://i.imgur.com/YxFSz0w.png

I'm deleting this manually.
[Nexus 5 General] jd1639:
Don't delete it. Twrp uses it.
[Nexus 5 General] td32:
i'm returning it to google, RMA, so that's why i returned to stock
[Nexus 5 General] jd1639:
Ok, that's fine then. You might want to boot into the boot loader then and then get into recovery and do the factory reset
[Nexus 5 General] td32:
When i enter the recovery mode all i see is an android image lying on its back with a red triangle over it!!!

Or you do mean boot twrp once again with fastboot command?

Edit:

Ok the menu appeared after pressing volume buttons.

executed factory reset
[Nexus 5 General] Young Cardiac:
Can anyone help me out? Would be MUCH appreciated!

I just installed cwm on my nexus 5 and when I was rebooting there came an option that said I could disable the original stock recovery that would be flashed since I was going on the stock rom. I pressed that and now when I reboot the phone keeps going on the 4 colour boot screen. I tried using flashing the stock rom via the bootloader but have had no success. The commands seem to be failing in the bootloader.

The command fastboot devices does work.

EDIT: Problem fixed. Turns out I had easytether on my computer which was messing something up. Once I uninstalled it and reinserted my phone into the computer my problem was fixed!
[Nexus 5 General] nanoindustria:
just to be sure: once i relocked the bootloader and reset the tamperflag, theres no way to tell if i made any modifications to the phone, right? Does the bootloader say "locked" instead of "relocked"?
[Nexus 5 General] jd1639:
I wouldn't say there is no way to tell you modified the phone depending on what else you've done to it. But to answer your question it does say "locked" Not re-locked
[Nexus 5 General] poisonjam:
Hi, this is probably a silly question, but I'm kind of new to this and could use some help.

I've been able to follow every step of this guide except for the part about resetting the tamper flag. After getting into TWRP, what is the exact command I need to enter to flash the zip that will reset the tamper flag?

Thanks so much for the help!
[Nexus 5 General] abaaaabbbb63:
You select "install" in twrp, then navigate to the zip location and select it, confirm, then reboot.
[Nexus 5 General] poisonjam:
Thanks for the quick response, I think I might still be missing something though... when I start TWRP i don't have an install option, here are the options I have:

C:\Users\Chris>fastboot oem device-info

...

(bootloader) Device tampered: true

(bootloader) Device unlocked: true

(bootloader) off-mode-charge: true

OKAY [ 0.004s]

finished. total time: 0.005s

C:\Users\Chris>fastboot c:/twrp.img

usage: fastboot [ <option> ] <command>

commands:

update <filename> reflash device from update.zip

flashall flash boot + recovery + system

flash <partition> [ <filename> ] write a file to a flash partition

erase <partition> erase a flash partition

format <partition> format a flash partition

getvar <variable> display a bootloader variable

boot <kernel> [ <ramdisk> ] download and boot kernel

flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it

devices list all connected devices

continue continue with autoboot

reboot reboot device normally

reboot-bootloader reboot device into bootloader

help show this help message

options:

-w erase userdata and cache

-s <serial number> specify device serial number

-p <product> specify product name

-c <cmdline> override kernel commandline

-i <vendor id> specify a custom USB vendor id

-b <base_addr> specify a custom kernel base address

-n <page size> specify the nand page size. default:

2048
[Nexus 5 General] jd1639:
You have to boot into recovery, twrp is the recovery
[Nexus 5 General] poisonjam:
Thanks, So I think I figured it out and installed TWRP to the phone and installed from there. I was able to reset the tampered flag. However, now the custom recovery is still on the phone and the phone is in locked status. How can the recovery be cleared without unlocking the phone again and resetting the tamper flag?

Thanks again,
[Nexus 5 General] jd1639:
You can't
[Nexus 5 General] poisonjam:
Oh Ok, so just to make it clear, there's no way to have both the stock rom and recovery, and have the tamper flag removed? which is probably more important for warranty purposes?
[Nexus 5 General] jd1639:
No you can have stock rom, stock recovery, rooted and no tamper flag. Just don't re-lock the bootloader using fastboot. There's an app, boot unlocker that you can use to lock or unlock the bootloader with out having to do it in fastboot. But you do have to be rooted

Edit, using boot unlocker does not trip the tamper flag.
[Nexus 5 General] poisonjam:
So it sounds like the correct order to fix this is:

1)Re-root and unlock phone

2)Redo tamper flag fix

3)Unlock again with boot unlocker app

4)Reflash stock

Correct?

Thank you,
[Nexus 5 General] jd1639:
If you want to be rooted with the stock recovery and you've reset the tamper flag I would just

Fastboot flash recovery recovery.img

Where recovery.img is the stock recovery
[Nexus 5 General] osm0sis:
Can somebody tell me, when unlocked and tamper is set to false, if fastboot oem lock triggers the tamper?
[Nexus 5 General] Nephilim-Giant:
I know this might be pathetic.. but I really wished there was a video showing how to remove the tampering part. :crying:

Ah well, I'll take my chances. RMA'ed for a rattling power button. I'd be shocked if they said anything about rooting is the cause of my problems, so I'll stay hopeful.
[Nexus 5 General] osm0sis:
It's dead easy, you just flash the zip to both reset the tamper and lock.
[Nexus 5 General] Nephilim-Giant:
I got a blue and gray screen saying "teamwin", I didn't know where else to go from there.
[Nexus 5 General] abaaaabbbb63:
It doesn't go further than that? Download the recovery again, and boot it again.
[Nexus 5 General] Nephilim-Giant:
That's where I got stuck unfortunately. I tried booting the 13 mb .img file and just got stuck in a constant boot loop.

I hate to sound like a pain, but mind if you could explain it a bit more than the front page? I downloaded both the TWRP file and the "cwm-Nexus.BootUnlocker" which contains the folder "meta-INF". Maybe the cwm-Nexus.BootUnlocker part I'm getting stuck at? What do we exactly do with this?
[Nexus 5 General] osm0sis:
It's a flashable zip. You flash it in recovery like every other flashable zip. ;)
[Nexus 5 General] Nephilim-Giant:
Thanks!! I finally got it to work! Maybe I was losing my sanity yesterday and I couldn't get it to work. I got it to work today though!

For some reason, yesterday it said I have 0 mb of internal storage and it did not show any zip folder. Today on the other hand, it showed that I have storage and the zip was on there! :victory:

I double checked the tamper label and it states: false :highfive:
[Nexus 5 General] osm0sis:
Great! Before you send it back can you please answer my post? It's important information to know about how the tamper flag works, and if I owned a Nexus 5 I would have done this by now since it'd only take 1 minute.
[Nexus 5 General] adil_93:
Is there any way to reset the tamper flag without the TWRP recovery image?

The reason I ask is because I am having a battery issue that makes my phone turn off randomly, and 95% off the time I cannot restart it.

I did manage to restart and flash everything back to stock, now just want to reset the tamper flag and lock up the bootloader so I can RMA it.

I can get into fastboot mode when I am lucky, but when I try to load the TWRP image it reboots and then I can't get it back on again.

My last resort is to just lock the bootloader using "fastboot oem lock" and hope that no one makes a fuss over the tamper flag
[Nexus 5 General] Nephilim-Giant:
Fastboot OEM device info:

device tamper: false

device unlock: false

off-mode-charge: true

fastboot OEM lock:

OKAY: .001s

Finished

Fastboot OEM device info:

device tamper: false

device unlock: false

off-mode-charge: true

Hope this answered your question. So nope, it doesn't trigger the tamper :)
[Nexus 5 General] osm0sis:
Sorry, I meant when the device is unlocked. Can you please try it again unlocked, but with tamper set to false from using my zip (you'll probably need to flash it twice in a row)? Thanks! :highfive:

So to be clear, the output from fastboot oem device-info before should read:

Fastboot OEM device info:
device tamper: false
device unlock: true
off-mode-charge: true

Then fastboot oem lock and show me the output of fastboot oem device-info after please. :)
[Nexus 5 General] Nephilim-Giant:
Blah. I got a a stupid boot loop with the google color dots :mad: I'll try again when I come home :)
[Nexus 5 General] oifi:
I tried the first method, but it didn't work.

It did a hundred times on the Gnexus but now it won't.

Whats wrong here?

sending 'bootloader' (2506 KB)...

OKAY [ 0.280s]

writing 'bootloader'...

OKAY [ 0.521s]

finished. total time: 0.801s

rebooting into bootloader...

OKAY [ -0.000s]

finished. total time: -0.000s

sending 'radio' (42033 KB)...

OKAY [ 1.522s]

writing 'radio'...

OKAY [ 2.904s]

finished. total time: 4.426s

rebooting into bootloader...

OKAY [ -0.000s]

finished. total time: -0.000s

archive does not contain 'boot.sig'

archive does not contain 'recovery.sig'

failed to allocate 709571364 bytes

error: update package missing system.img

Press any key to exit...
[Nexus 5 General] abaaaabbbb63:
You did use the factory images for the Gnex, didn't you? It seems it lacks boot and recovery. Try downloading the images again.
[Nexus 5 General] oifi:
;) I took the one for nexus 5.

it works, using method 2, but I wonder whats the problem with method 1 because I'm lazy and want to use it.
[Nexus 5 General] abaaaabbbb63:
Probably some files that are not in their place. Good thing it worked.
[Nexus 5 General] abaaaabbbb63:
That should not happen. Flashing the recovery.img should wipe TWRP, and install the stock recovery. When you flashed the files, did you get any error?
[Nexus 5 General] jd1639:
http://xdaforums.com/showthread.php?p=47876375
[Nexus 5 General] jtdc:
the only reason i placed CWM recovery is to flash the zip for louder speaker.

now i just want to get back to stock recovery to minimize any issue with incoming OTA,

"fastboot flash recovery C:/image-hammerhead-krt16m/recovery.img"

is that command enough?

a stupid question but wanna ask nonetheless... could the tamper flag be reset back and keep bootloader unlocked?
[Nexus 5 General] jimburke57:
I am in need of some help. I installed the Xposed Framework yesterday, and now I am unable to boot into the system. Sometimes it will get to the boot animation, then shut off. Other times it won't do anything. I am able to boot to fastboot. I have tried to recover using method one, and I keep getting errors while writing the boot.img and system.img. Now I am trying method 2 and when writing system.img it fails giving me (remote: flash write failure).

To preface this, I am not a noob when it comes to modding and flashing. So any help or advice will be greatly appreciated. And I am on windows 8 if that helps.

Thanks in advance.
[Nexus 5 General] thegtfusion:
worked excellent. good job OP :)
[Nexus 5 General] osm0sis:
GT. Buddy. Does my zip work with CWM on your device?
[Nexus 5 General] abaaaabbbb63:
Try formatting system using this command, before flashing the img:

fastboot erase system

Well thanks sir! Thank the guys in the credits section too :P
[Nexus 5 General] jimburke57:
I did, still failing. When going through the steps in the second post, I make it up to flashing the system.img. It fails at this step.
[Nexus 5 General] abaaaabbbb63:
Ok, try these things:

Try redownloading the factory images.

Try moving the system.img to a different disk (Like, from C to D)

Try using a different PC, if able.
[Nexus 5 General] jimburke57:
So I did everything except trying a different pc, and I got the same error during the system.img. flash write failure.
[Nexus 5 General] abaaaabbbb63:
Then just try flashing a custom recovery (like twrp), and flashing a ROM (use "adb push" to copy a rom on your storage)
[Nexus 5 General] jd1639:
He's trying that. http://xdaforums.com/showthread.php?p=47913198

Edit, the op has multiple threads going
[Nexus 5 General] kmar22:
This has been such a great help
[Nexus 5 General] abaaaabbbb63:
He somehow managed to make /system unmountable and unflashable. Weird.

I saw that..
[Nexus 5 General] jd1639:
Yea, the exposed module he flashed must have borked the partitions somehow.