• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Mods [Guide]How to flash a Nexus Factory Image manually.

Hey @gheazey, which specific Nexus device do you have and which factory image version were you flashing?

The specifics about what is needed to flash would be in the flash-all.bat (for Windows) (or flash-all.sh for Linux) files that is inside the factory image archive.
 
I flashed my Moto Nexus 6 to Shamu mra58x (is that the info you're asking after? I'm super nube.) The flash-all.bat didn't work for me...kept getting the system.img error. Going one by one seems to have worked, I just don't quite get how I got a functioning radio, as I never got a successful response in the command prompt. I'm working off a windows 10 machine, FWIW.
 
Welcome to our AndroidForums, by the way (forgot to say that before :)).

Okay, I downloaded the factory image for "mra58x" for the Nexus 6 (shamu) and here's the flash-all.bat file (or at least the relevant pieces :p):

PATH=%PATH%;"%SYSTEMROOT%\System32"
fastboot flash bootloader bootloader-shamu-moto-apq8084-71.15.img
fastboot reboot-bootloader
ping -n 5 127.0.0.1 >nul

fastboot flash radio radio-shamu-d4.01-9625-05.30+fsg-9625-02.107.img
fastboot reboot-bootloader
ping -n 5 127.0.0.1 >nul
fastboot -w update image-shamu-mra58x.zip

So it is possible that in one of the prior attempts at using the flash-all.bat file, it got far enough along and actually flashed the radio (after all, the big, longest duration step is the last one where the "update-image-shamu-mra58x.zip" is flashed)?

Can you scroll-back and see that you did the flashing of the radio (i.e., the line I listed in red above)?

I do agree with your have better success doing the steps manually, one-at-a-time, as you're are certainly not the only person I've seen post that that strategy yield better success than running the script (just make sure that you do all of the steps and pause a bit between them--that's what the ping commands are in there fore along with rebooting the bootloader).

Hope that helps! Cheers!

:)
 
Ummm...so I closed the command prompt window out of exhaustion. :confused::) I think I might leave well enough alone, unless you advise me going back in. Other than the radio, there are only the four files you need to install if you go the manual route, right?
And thanks for having me. I really appreciate this place. I barked up a lot of cat-less trees before I got here. :D
Oh, also, is there a quick way to re-lock the boot loader (assuming I'm done updating)? Or is it worth just leaving it there?
Thanks again,
Greg
 
Well, at least for the mra58x image for shamu, you only need to flash the bootloader (bootloader-shamu-moto-apq8084-71.15.img), the radio (radio-shamu-d4.01-9625-05.30+fsg-9625-02.107.img), and the system image (image-shamu-mra58x.zip) -- at least that's all I see in the flashing scripts.

If things are working well, then I'd probably quit while I'm ahead ;) :).

As far as re-locking the bootloader, I keep mine unlocked because it can give you some recovery options in case things go awry (i.e., you could soft-boot or flash a custom recovery to poke around in your system to possibly fix the problem or recover files)--amongst other things like being able to take a full device backup (again, via the custom recovery).

Keeping it unlocked though would allow a nefarious third party to also get in to the guts of your device and retrieve your files, too, using the custom recovery method I indicated above.

So, dealer's choice :).

Glad to have you here, too, and glad you signed-up witth us :).
 
I mean, the only thing I remember succesfully going in were these:
system.img
boot.img
recovery.img
cache.img
I'd assume the radio must have worked from the earlier attempt, so maybe by going and doing the secondary zip folder independently I managed to ice the cake without even knowing it?
Either way, I'll quite while I'm ahead and hop back on here if I glitch.
Also, any idea where a nube might get a dummies overview of what I just did? I'd like to get more into monkeying around with these things.
 
Ah, you manually flashed those various .img files? Cool :cool:.

They're inside/part of the image-shamu-mra58x.zip file and would normally get flashed by the fastboot -w update image-shamu-mra58x.zip command.

By the way, there's a pretty cool automated tool for flashing these images--as well as rooting your device: Wug's Nexus Root Toolkit (from http://www.wugfresh.com/nrt/). It is very good for you to have already manually done the things you have done, but in a pinch, Wug's NRT will automate and do these tasks (and others) for you.

We've got a good FAQ area here that you might want to browse through that has some other interesting threads that might be of interest to you.

Not sure what other overview we have or I might give you, other than what you manually flashed are the typical partitions that exist on most Android devices:

bootloader

radio
(some devices have more than one radio that need flashing)

boot.img (Android kernel)

cache.img (/cache partition)

recovery.img (/recovery partition -- typically containing the stock recovery, but can be overflashed with a custom one)

system.img (/system partition --- i..e, the bulk of rest of Android)

userdata.img (/data partition)​

Other devices might have other partitions, but these are the biggie / main ones.

Hope that helps! :)
 
Hi I'm getting stuck at step 9 it says FAILED (remote: flash write failure) my LOCK STATE is unlocked and this is the command line I typed ./fastboot-mac flash bootloader bootloader-hammerhead-hhz12d.img

Any ideas what is wrong?
 
I'd assume the radio must have worked from the earlier attempt, so maybe by going and doing the secondary zip folder independently I managed to ice the cake without even knowing it?

That's been my experience with the N6 and trying to use the flash-all.bat script. The bootloader and radio will successfully flash, but the fastboot command to use the zip file always fails, so I have to unpack them and flash manually. So, you are right that both the bootloader and radios were updated and there's probably nothing more you have to do. :)

Hi I'm getting stuck at step 9 it says FAILED (remote: flash write failure) my LOCK STATE is unlocked and this is the command line I typed ./fastboot-mac flash bootloader bootloader-hammerhead-hhz12d.img

Any ideas what is wrong?
Hammerhead is for the N5 so if you could confirm, that's you're phone, we can look at other problems that might be happening.

I'd also check that the md5 checksum matches on the dowloaded file. If that's okay, then you might try a different USB cable and switch it to a different port. From the command, I am assuming you are using a Mac. Model and OS version?
 
Hi, I was able to execute all commands succesfully, but the boot never ends (and I can see mount erros on mount/cache/recovery/log on recovery mode). I also tried the direct way with fastboot -w update (no mount errors), but the phone then shutdowns after booting. Do you know what might be wrong?
I have a Nexus 4 and I'm using image-occam-lmy48t.
 
Welcome to our AndroidForums, @ftkg :).

Just a quick thought as to why you might be seeing an endless boot could be caused by a bad/incomplete/partial/corrupt download of the factory image file.

After you do the download to your PC, it's probably wise to check either the MD5 checksum or the SHA1 checksum published for the factory image you downloaded from the Nexus Factory Images page.

See this thread here at AF some tools to help you check the MD5: http://androidforums.com/threads/md5-verification.443074/

If you do have the right checksum, then we could explore other issues, although this is a likely suspect/culprit.

Cheers!
 
Hey, thanks!

I did a MD5 check and the package is good.
As I said, I also did a fastboot -w update, and the booting ends (but the device shutdowns)

I also flashed different ROMs before with a toolkit -- it was just today that I started trying the manual approach, as the toolkit didn't solve the boot issue.

Your help is very appreciated!
 
Hmm, did you take a nice pause between fastboot commands?

Sometimes doing a fastboot reboot-bootloader (like the flash-all.bat/sh scripts do) is helpful...

Not sure what else to suggest...hopefully a Nexus 4 user/owner will chime-in, too.
 
Yes, I did pause between commands.

Weird thing is that on power charger the boot goes further before shutting down.
I guess I'll get a new battery and try again.
 
As far as re-locking the bootloader, I keep mine unlocked because it can give you some recovery options in case things go awry (i.e., you could soft-boot or flash a custom recovery to poke around in your system to possibly fix the problem or recover files)--amongst other things like being able to take a full device backup (again, via the custom recovery).

Keeping it unlocked though would allow a nefarious third party to also get in to the guts of your device and retrieve your files, too, using the custom recovery method I indicated above.
Daaanng.....I didn't know that!!! I leave my bootloader unlocked so I can do stuff in case something goes wrong, but I didn't know it left my device vulnerable if lost/stolen. When I read this I tried it out to prove you wrong but you were right. I powered off. Booted into recovery. connected to pc. adb pulled file from my phone to pc and read them on my pc,...without ever once having to enter my PIN (so thief could easily do the same).

BUT my phone is encrypted. I wonder how TWRP unencrypted the file without my PIN???... I thought the PIN was built into the encryption. How the **ck can something be unencrypted without the key???
(**ck stands for heck)
 
Last edited:
Not researched this fully myself, but this has some good starting info:

That matches what I found when researching Android encryption following the whole Apple vs FBI thing. If your PIN/Pattern/Password isn't required before the Android system finishes booting, then the system uses a default password (literally, "default_password") to decrypt at boot time. After learning that, I made sure to tick the option to require my unlock code at startup.

I also found that enabling any third-party Accessibility app (Lastpass/Dashlane, any clipboard managers, anything with access to what's on your screen, etc) disables that option. Kind of frustrating as those are apps I use regularly, but I'm okay with the compromise in the name of security.
 
Yes, that is the way I read it also (need to have password on boot option enabled to avoid default encryption key). However I think you can have BOTH pin-on-boot and accessibility services running if you set it up in the right sequence:

First, enable required accessibility services. it does turn off the pin-on-boot behaviour as mentioned.

Second, AFTER you have enabled all accessibility services, go back and reset your pin and re-enable the pin-on-boot option. Now everything will stick and you have both. At least that's what I have on my phone at this moment: pin-on-boot enabled and tasker accessibility service enabled. I have verified Tasker accessibility works and that TWRP now asks for PIN.

I think the logic is that when a new accessibility need is identified, Android considers there is a new handicapped user it r the old the user is now suddenly handicapped and not be capable of entering PIN on boot without the aid of those accessibility services (which aren't loaded until after boot). So it conservatively disables pin on boot to avoid locking out the newly handicapped user our new handicapped user. But if you have already your accessibility needs identified and then deliberately set the pin on boot, it assumes you know what you're doing. Or maybe there's no logic.
 
Last edited:
Hello all!

I am currently having the exact same problem, after running the exact same procedures, as the user lifeisfun.
Re-cap:

Nexus 5 Hammerhead
Android 6.0.1
Build MOB30H

1. Phone stuck on bootloop after a faulty update;
2. Developer tools were not activated;
3. Downloaded and set-up the Windows 7 drivers (by koush);
4. Device Manager is currently detecting an "Android Device" -> Google Nexus ADB Interface;
5. Downloaded the Android SDK and the "Mini ADB and Fastboot" tool, and I am using the Mini tool;
6. Downloaded the .IMG files that correspond to the version and build of the phone. The files are from the they are placed in the same folder as adb.exe and fastboot.exe.

The problem that I am getting is exactly the same as lifeisfun's.

1. Fastboot detects the device. I can get fastboot to unlock the bootloader (which autolocks on reboot);
2. These commands work and return no error:
  • fastboot erase boot;
  • fastboot erase cache;
  • fastboot erase recovery;
  • fastboot erase system;
3. The game is over at this point: I am unable to flash the bootloader, nor any other stock .IMG file to the phone.

At this point I have read everything related to this in androidforums, xda-developers, stackexchange and even reddit.

Any updates on the issue?

Best,
Ted.
 
Ted, Welcome to Android Forums! :)

At this point my best recommendation is to try Wug's Toolkit and use the softbrick option to flash back to stock. It will temporarily boot to an insecure kernel in order to flash the images and then on final boot use the stock kernel. Once you boot into Android, then you can go into developer options and enable bootloader unlock.
 
Hey lunatic59,

That was an incredibly fast answer.

To use the restore/uprade/downgrade option for softbricked/bootlooped devices in Wug's Nexus Root Kit is a really good idea.

Here I have two options, and both of them do not work for me:

1. To wait for NRT to ask me to unlock the bootloader. If I use this option, NRT reboots the phone automatically after unlocking the bootloader and NRT prompts me to enable the developer tools once the OS finishes loading. Needless to say, that is not possible since after the reboot the phone is stuck in the bootloop again;

2. To unlock the bootloader manually, using the "fastboot oem unlock" command via the Minimal ADB and Fastboot tool, before I start the restore/uprade/downgrade option for softbricked/bootlooped devices in Wug's Nexus Root Kit.
Doing this, I get a little further. NRT seems to be able to push its recovery to the phone, and reboots it. Now the phone shows the NRT logo, as if the NRT recovery is being loaded. However, at this point, both fastboot and ADB are not functioning, and the NRT on the PC cannot flash the ROM.

In general, with both tries, the crash is at the same stage as when doing it manually, as explained in my first post. It is not possible to run the "fastboot flash recovery/system/userdata *.IMG" command successfully, returning the now popular error:

FAILED (remote: flash write failure).

Now, playing around with this, I figure that the problem is hidden in either (or both) of these issues:

1. The phone us unable to mount the /cache partition, no matter what. It returns the following line: "E:failed to mount /cache (Invalid argument)," no matter what I do: whether it is clearing/wiping the cache, clearing the /data partition, or any other command in the Recovery mode;

2. The PC does not detect the phone as an ADB device. The command "adb devices" returns blank with only one exception: the only way to actually use an adb command is by turning on the ADB update in Recovery mode, but the only possible command is "adb sideload * ". I have tried to sideload several OEM IMG zipped packages, OTA IMG zipped update packages, and unzipped "naked" IMG files, to no avail.

After the n-th time of doing all this, I have rebooted the phone and it is still bootlooping. Great mystery.

Best,
Ted.
 
With Android 6.x they added a new setting for oem unlocking which can get in the way of flashing. I thought Wug's had the workaround for that with the softbrick option. ADB will only recognize the phone if debugging is enabled in developer mode or recovery supports it. As you see, recovery supports adb sideloading, but is very limited. Sideloading only works with zipped files specifically for stock recovery, so if your phone was modified prior to this issue, I can see why it might have a problem there, too.

What I find curious is that you can get the phone into fastboot mode and unlock the bootloader, but still not flash the system.img, but it let you erase it. And that even though you issued the fastboot command to erase the recovery partition, you can still boot into recovery.

I know this might be overly obvious, but have you tried a different USB cable and/or port? Just grasping at straws at this point.
 
I thought the same thing when I erased the boot/cache/recovery and /system, and couldn't flash them right afterwards. I thought I had completely damaged the phone, but somehoew I still get into recovery, and the phone still tries to boot the OS if left alone.

I haven't actually tried different USB cables, will be the first thing I do when I get home. But am I supposed to be able to use "fastboot flash *.IMG" if dev tools is off and with the /cache error getting in the middle of everything?

I'll post some screenshots of the whole loop later, done with another usb cable, hehe.

Regards,
Ted.
 
Developer options should have no effect on flashing the .img files for system, cache or user. But you shouldn't be able to flash boot or recovery if the bootloader is locked, but to be honest I haven't tried that since my Nexus 4 and that was still KitKat. IT might be different with MM now.
 
Back
Top Bottom