As a follow up to our recent PSA on bootloader quirks with GPE devices, we thought it would be a good idea to shed some light on a bootloader anomaly which affects both Nexus and GPE devices. Recently, there have been changes to the way unlocking happens behind the scenes. These changes can result in a device that infinitely boots into recovery.
Traditionally, when you decide to unlock and flash a custom recovery, the procedure goes something like this:
- You type "fastboot oem unlock" from the command line.
- A warning appears on your device's screen informing you that you're about to void your warranty by proceeding with the unlock.
- You confirm that you do indeed want to proceed.
- The bootloader wipes your device's data and cache, then switches to an unlocked state.
- You flash a custom recovery like ClockworkMod or TWRP.
- You reboot your device and you're done.
A lot of people perform these steps as soon as they get their device, before booting it for the first time. Unfortunately, on the Nexus 4 (as of bootloader version MAKOZ30d), Nexus 5, 2013 Nexus 7, G Pad 8.3 GPE, and Z Ultra GPE, the bootloader doesn't wipe data as it has on past devices. Instead, it depends on stock recovery to do that the next time you reboot. If you unlock, then immediately flash a custom recovery, this can, and most likely will, cause headaches. Here is how things could play out:
- You confirm you want to proceed.
- The bootloader unlocks, then modifies the device's boot chain to force booting to stock recovery upon the next reboot.
- You flash a custom recovery, which overwrites the stock one.
- You reboot, and your device force-boots to the custom recovery you just flashed.
- It sits waiting for input from you.
- Thinking something is weird, you reboot and your device continues force booting into recovery indefinitely.
When the boot chain is changed during the unlock process, instructions are set which tell stock recovery to wipe the data and cache partitions and set the chain back to normal boot procedure. Custom recoveries don't seem to interpret these instructions correctly and one of two things usually happen:
- Your custom recovery just sits waiting for input, pretending there are no pre-existing instructions for it. Rebooting will just force-boot to recovery again.
How to fix: To break this impasse, you'll have to flash stock recovery and reboot. Data and cache will be properly wiped and the boot chain will be reset. At that point, all is well and you can flash a custom recovery.
- The custom recovery actually interprets the instructions, wipes data and cache, sets the boot chain back to normal, but then your ROM gets stuck in a boot loop at the boot animation.
How to fix: This can be rectified by simply booting into fastboot mode, then running "fastboot format" on the userdata and cache partitions.
Moving forward, if you want to avoid this situation entirely, the best procedure to use is as follows:
- Unlock your bootloader, but do not flash your custom recovery yet.
- Your device will force-boot into stock recovery, wipe data and cache, then reboot again.
- Let the device boot all the way to the welcome screen.
- Reboot back into fastboot mode.
- Flash the custom recovery.
We hope this will save some of you the time and frustration of troubleshooting this yourselves. Truth be told, it would be nice if Google informed us of changes like this when devices launch. That said, it seems that there is instead an assumption that we'll just catch on and we're smart enough to figure it out on our own. Thankfully, that's exactly the case.