Nexus 5, I'm getting remote: flash write failure while trying to fix a bootloop Before I say anything I just want to say I didn't install any custom ROMs nor rooted my phone.

I've downloaded the factory images from here https://developers.google.com/android/nexus/images#hammerhead

I put my phone into bootloader and I start the flash-all.bat script from the folder I've downloaded above. It runs this script:

PATH=%PATH%;"%SYSTEMROOT%\System32"
fastboot flash bootloader bootloader-hammerhead-hhz12d.img
fastboot reboot-bootloader
ping -n 5 127.0.0.1 &gt;nul
fastboot flash radio radio-hammerhead-m8974a-2.0.50.2.22.img
fastboot reboot-bootloader
ping -n 5 127.0.0.1 &gt;nul
fastboot -w update image-hammerhead-lrx22c.zip

echo Press any key to exit...
pause &gt;nul
exit


I get the following output:

OKAY [  0.307s]
writing 'bootloader'...
**FAILED (remote: not supported in locked device)**
finished. total time: 0.407s
rebooting into bootloader...
OKAY [  0.050s]
finished. total time: 0.050s
&lt; waiting for device &gt;
target reported max download size of 1073741824 bytes
sending 'radio' (45521 KB)...
OKAY [  1.732s]
writing 'radio'...
**FAILED (remote: not supported in locked device)**
finished. total time: 1.842s
rebooting into bootloader...
OKAY [  0.046s]
finished. total time: 0.046s
&lt; waiting for device &gt;
target reported max download size of 1073741824 bytes
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
failed to allocate 1005027540 bytes
error: update package missing system.img
Press any key to exit...


I've noticed the bolded lines so I unlocked the phone using a command fastboot oem unlock. It unlocks it, however if I reset the phone, it's locked again. People on the Internet say that if this happens then the phone is dead. I hope it's not the case.

I've tried running the script again when the phone is unlocked:

target reported max download size of 1073741824 bytes
sending 'bootloader' (2579 KB)...
OKAY [  0.202s]
writing 'bootloader'...
**FAILED (remote: flash write failure)**
finished. total time: 0.402s
rebooting into bootloader...
OKAY [  0.090s]
finished. total time: 0.090s
&lt; waiting for device &gt;
target reported max download size of 1073741824 bytes
sending 'radio' (45521 KB)...
OKAY [  1.709s]
writing 'radio'...
**FAILED (remote: flash write failure)**
finished. total time: 2.939s
rebooting into bootloader...
OKAY [  0.100s]
finished. total time: 0.100s
&lt; waiting for device &gt;
target reported max download size of 1073741824 bytes
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
failed to allocate 1005027540 bytes
error: update package missing system.img
Press any key to exit...


As you can see I get the FAILURE (remote: flash write failure).

I've tried removing the commands that reset the phone so the phone stays locked and I get this output after running the modified script:

target reported max download size of 1073741824 bytes
sending 'bootloader' (2579 KB)...
OKAY [  0.300s]
writing 'bootloader'...
**FAILED (remote: flash write failure)**
finished. total time: 0.492s
target reported max download size of 1073741824 bytes
sending 'radio' (45521 KB)...
OKAY [  1.716s]
writing 'radio'...
**FAILED (remote: flash write failure)**
finished. total time: 1.894s
target reported max download size of 1073741824 bytes
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
failed to allocate 1005027540 bytes
**error: update package missing system.img**
Press any key to exit...


Again, the FAILURE (remote: flash write failure) occurs but I don't understand why it can't find "system.img" because it is in the folder where the script is.

I've also tried the tutorial from this Youtube video https://www.youtube.com/watch?v=pJnoiMTw5cY

When I try the first command which is "fastboot flash system system.img" I get the same error.

So, is my phone dead or can I still fix it?

EDIT: I've RMA-ed[1] the phone and they've sent me a replacement. I hope this thread will help future people.

[1] https://en.wikipedia.org/wiki/Return_merchandise_authorization
The flash-all.sh script does not take into consideration that your bootloader is locked after each restart.

I opened the shell script and executed each command one by one, re-unlocking with the following after each command:

fastboot oem unlock


I flashed each image with no errors, but it did not seem to write to memory regardless.