Unboxed my new OnePlus One and immediately installed the usual apps etc. Then I realized that the device bootloader isn’t unlocked! I don’t know why, but I assumed the OnePlus One came unlocked and rooted. Silly me! All I want to do is root the device (an update file for SuperSU can be downloaded from here), but to do that I can’t use the stock recovery as that performs signature checking and so the update will fail). Option 1 is to install a custom recovery, option 2 is to temporarily boot into a custom recovery. Either of these options will then let me root the device. I prefer the second option, but it doesn’t matter really because to install/ temporarily boot a custom recovery the device must be unlocked! And unlocking means my data will be wiped.
So … here’s what I did to unlock the device and trying not to lose the data. Note that if you are looking for a tutorial sort of post there are better places on the Internet. This is more of a rambling on what I did. I didn’t succeed in what I set out to, so this could be a waste of your time too. :) Also, I have an older post that explains boot loaders, custom recovery, etc. That’s worth a read.
First I downloaded the Android SDK on my laptop. I didn’t download the ADT, only the SDK tools. Specifically, I downloaded the zip version of the SDK tools so I can put it in my Dropbox for future use. (The zip version can be found under “View All Downloads and Sizes”).
Downloaded the zip file. Extracted the contents to Dropbox. Ran
SDK Manager.exe. This had “Android SDk Tools”, “Android SDK Platform-tools”, and “Android SDK Build-tools” selected as well as a bunch of items under the folder called “Android 5.0 (API 21)”. Plus under the “Extras” folder the “Google USB Driver” and “Android Support Library” too were selected. I un-selected the “Android 5.0” folder and “Android SDK Build-tools” as I don’t need these. I need the “Android SDK Platform-tools” as that contains the tools I want. And the USB driver is good to have too.
After installing these I went to the Dropbox folder where I had extracted everything, went into the
android-sdk-windows\platform-tools sub-folder, pressed the SHIFT key and right clicked within the folder, and selected the option to “Open a command window here”.
After this I went to the OnePlus One “Settings” menu > “About phone” > and tapped 7 times on the “Build number”. This enables the “Developer Options” menu under “Settings”. Went in here and enabled “Android debugging” (it’s unchecked in the screenshot below, I checked it).
Now I connected the phone to my laptop. Maybe you’ll get prompted for a driver install in which case you should choose the one under
android-sdk-windows\extras\google\usb_driver. If you don’t get prompted for anything then check the Device Manager. If an unknown device called “A001” is present, update its driver with the one in the above location.
Assuming all goes well typing
adb devices in the command prompt should show the OnePlus One:
> adb devices
List of devices attached
ADB is pretty cool in that you can do a lot of stuff to your device with it. For example: boot into the boot loader, boot into recovery, take a device backup, sideload apps, and so on.
The following command will reboot the OnePlus One into bootloader:
Unlike the Nexus devices I am used to, with the OnePlus One the bootloader doesn’t give any info. It has the Cyanogenmod mascot with the words “fastboot mode” beneath it.
Once in fastboot mode we can ues a tool called fastboot to manage the device. Think of it as ADB but when in the bootloader mode. Assuming all went well before the following command should show the OnePlus One connected:
> fastboot devices
At this point I can follow either of the options I mentioned above – install a custom recovery or temporarily boot into a custom recovery. In my case this is where I would have issued a command like this to temporarily boot into a recovery image (after downloading a recovery image such as TWRP and specifying the downloaded path below):
> fastboot boot \path\to\downloaded\recovery\image
If I wanted to flash the custom recovery over the stock recovery I would have typed the following instead:
> fastboot flash recovery \path\to\downloaded\recovery\image
If you do this without unlocking the device you will get an error along these lines:
OKAY [ 0.540s]
FAILED (remote: Device not unlocked cannot boot)
finished. total time: 0.556s
Unlocking is easy. Type the following command (before typing it read the next few paragraphs though):
> fastboot oem unlock
OKAY [ -0.000s]
finished. total time: 0.019s
At this point the device should be unlocked. I expected it to not reboot – because the first boot after unlocking is when the phone wipes all your data– but mine rebooted! So I quickly powered it off, then powered it on by pressing the Volume UP & Power keys together. Give a minute and the phone will power on and go into the boot loader (fastboot mode).
I confirmed that
fastboot devices shows the phone, so I booted into a temporary recovery as before:
> fastboot boot c:\Users\rakhesh\Downloads\openrecovery-twrp-18.104.22.168-bacon.img
OKAY [ 0.547s]
OKAY [ 0.031s]
finished. total time: 0.589s
The fastboot screen icon turned white and after a minute TWRP booted.
I chose the option to “Wipe”, followed by “Advanced Wipe”, and selected “Cache”. This wiped the cache, after which I rebooted the device. (Before rebooting TWRP pointed out that the device isn’t rooted so it can root for me. I chose to go with that). Unfortunately I think I was too late in powering off the phone before because it turns out everything was wiped! :(
Thankfully I was able to restore from the backup – sort off, because that seemed to break off midway – so finally I just recreated the phone. I had kind of expected this outcome as most data wiping as part of unlocking the bootloader is a pretty standard thing. I was hoping to avoid it through the trick above, but I guess it wasn’t my day. :)
(Note to self: If I try this again try flashing recovery and then unlocking. Maybe then the device won’t reboot).
Before I end, I’d like to point out this forum post. It’s from the OnePlus forum and goes into details of unlocking, rooting, etc. It’s a pretty good post, I discovered it while writing this blog post.