[GUIDE] Unlock/Root/Flash for OnePlus One

Search This thread

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
[SIZE=+3]Heisenberg's How-To Guide For Beginners[/SIZE]
[SIZE=+2]OnePlus One[/SIZE]
W2OmtZJ.jpg
[SIZE=+1]See Also:
[INDEX] OnePlus One

[FAQ] OnePlus One Frequently Asked Questions
[/size]

[SIZE=+1]Intro[/SIZE]

This thread will serve as a location for basic how-to guides for the OnePlus One (Bacon). I'm going to start off with a couple of the more obvious ones and go from there. If anyone has any suggestions for additions please feel free to let me know.

[size=+1]Prerequisites[/size]:

You'll need a working adb/fastboot environment on your PC to get through some of these guides. Go here to download the Android SDK, which will give you most updated version of adb and fastboot. Scroll to the bottom of the page and find Other Download Options>SDK Tools Only, and grab the right version for your OS. While it's downloading create a folder in C:\ called SDK (C:\SDK). Once you've downloaded the zip you can extract it into your C:\SDK folder. Navigate to C:\SDK\android-sdk-windows and open SDK Manager.exe. In SDK Manager you need to install the following packages:

Tools> Android SDK Tools, Android SDK Platform-tools
Extras> Android Support Library

Once you have installed those, inside C:\SDK you should see some new folders, one of them will be called platform-tools, within that folder you should see fastboot.exe and adb.exe. I'll refer to this as your fastboot folder/directory or working folder/directory during this guide. To make sure adb is correctly installed, open a command prompt from within your fastboot folder (hold shift + right click, select open command prompt here) and issue this command:
Code:
adb version

If it returns a version number for Android Debug Bridge then you're good to go.

You'll find universal adb/fastboot drivers here, download it and follow the installer, then reboot your PC.

You can test adb by connecting your device to your PC while booted into Android (making sure that adb/usb debugging is enabled in Settings>Developer Options) with the screen unlocked and issuing this command:
Code:
adb devices
It should return your device serial number, if so, adb is working.

You can test fastboot by connecting your device to your PC while booted into fastboot mode (power + volume up) and issuing this command:
Code:
fastboot devices
It should return your device serial number, if so, fastboot is working.

By attempting any of the processes listed this thread you accept full responsibility for your actions. I will not be held responsible if your device stops working, catches on fire, or turns into a hipster and claims to have been modified before it was cool. Make sure you read a section and fully understand it before attempting it.

z7e6jQa.jpg

[SIZE=+1]Index[/SIZE]
  1. How To Unlock Your Bootloader
  2. How To Install A Custom Recovery On Your Device
  3. How To Make A Nandroid Backup With TWRP Recovery
  4. How To Root Your Stock Rom
  5. How To Install A ROM with TWRP Recovery
  6. How To Install A Custom Kernel With TWRP Recovery
  7. How To Flash The Stock Kernel With Fastboot
  8. How To Flash The Cyanogen OS Fastboot Images
  9. How To Update Modem/Firmware When Switching From KitKat To Lollipop (and vice versa)
  10. How To Make Sure You Can Pretty Much Always Recover From An Accidentally Wiped System
  11. How To Backup & Restore Your EFS Partition

z7e6jQa.jpg

[SIZE=+1]1. How To Unlock Your Bootloader[/SIZE]

  • Power off your phone then boot into fastboot mode (power + volume up).
  • Connect your phone to your PC via usb cable.
  • Open a command prompt from within your fastboot folder (navigate to where you have fastboot.exe located on your PC, shift + right click anywhere within that folder, select open command prompt here).
  • Check your fastboot connection by issuing this command:

    Code:
    fastboot devices

    It should return your device serial number, if not you need to make sure your drivers are installed correctly.​
  • Once you've confirmed your fastboot connection issue this command:

    Code:
    fastboot oem unlock

    The device will now go through the automated unlocking process, just let it do its thing and it'll boot up into Android.​
  • Go back to fastboot mode and issue this command to ensure that it worked:

    Code:
    fastboot oem device-info

    It should have a couple of lines there, both with the flag set to true.​
  • You can now reboot your phone using this command:

    Code:
    fastboot reboot
  • It's now safe to disconnect your usb cable.

Please note: this will erase all user data from your device, it is best to do this before you really start using the device and installing apps or putting data on the internal storage.

z7e6jQa.jpg

[SIZE=+1]2. How To Install A Custom Recovery On Your Device[/SIZE]

Prerequisites: unlocked bootloader.

  • You first need to go into Settings/Developer Options and uncheck the "Update recovery with system updates" option (to enable Developer Options go into Settings/About Phone and click 'build number' about seven or eight times).
  • Download the recovery of your choice (my preferred recovery is TWRP, and we'll be using that for this guide, grab it here).
  • Make sure you check the md5 to verify its integrity.
  • Place the file in your fastboot folder (this is where fastboot.exe is located on your PC).
  • Put the phone in fastboot mode and connect it to your PC via usb cable.
  • Open a command prompt from within your fastboot folder (shift + right click, select open command prompt here), and enter the following commands:

    Code:
    fastboot flash recovery openrecovery-twrp-2.8.1.0-bacon.img

    (The recovery filename in the command will change depending on which recovery you're flashing)

    Code:
    fastboot format cache

    Code:
    fastboot reboot
  • Let the device reboot, it's now safe to disconnect your usb cable.

    Now you can use the advanced power menu (or the power + volume down button combo) to enter your custom recovery.

Please note, if you have taken the stock Lollipop update please read the following:

For some reason CM12S doesn't respect the on/off toggle for the "update CM recovery" option in Developer Options, it just replaces whatever custom recovery you've flashed with the CM recovery regardless of whether that option is unelected.

Flash your custom recovery again, but after flashing don't do a normal reboot. After the flash has succeeded disconnect the usb cable, then power down the phone by holding the power button down, once it's powered off use the power + volume down button combo to boot directly into recovery. This first forced reboot into recovery somehow subverts what was keeping it from staying flashed and all subsequent normal reboots into recovery will boot into the custom recovery of your choice.


z7e6jQa.jpg

[SIZE=+1]3. How To Make A Nandroid Backup With TWRP Recovery[/SIZE]

Prerequisites: unlocked bootloader, TWRP recovery.

A nandroid backup is a very important thing to have before installing any custom software on your device. It's basically a backup of your stock system that you can fall back on if anything goes wrong or if you just want your stock ROM back. You can also use the backup tool to create a backup of your favourite ROM set up exactly the way you like it. The backup you create can be easily restored using the restore tool in TWRP recovery.

All you need to do is enter TWRP recovery, select the backup option from the TWRP home screen, check the system/data/boot boxes, and swipe to backup. The process will take a few minutes.

z7e6jQa.jpg

[SIZE=+1]4. How To Root Your Stock Rom[/SIZE]

Prerequisites: unlocked bootloader, TWRP recovery.

  • First you need to download SuperSU.
  • Enter TWRP recovery via the advanced power menu (or power + volume down).
  • Select the install option from the TWRP home screen.
  • Navigate to where you have SuperSU stored on your sd card and select it.
  • Swipe to install.
  • Once you've installed SuperSU you'll have an option to wipe cache/dalvik and an option to reboot system. Wipe the cache/dalvik, hit the back button, and hit the reboot system button. That's it.

z7e6jQa.jpg

[SIZE=+1]5. How To Install A ROM with TWRP Recovery[/SIZE]

Prerequisites: unlocked bootloader, TWRP recovery.

Installing a ROM is a pretty straight forward and easy process. Before you install anything you should make a nandroid backup (instructions above).

  • Download a ROM and appropriate Gapps package and place on your device.
  • Boot into your custom recovery.
  • Perform a full wipe.
    • Select the wipe option from the TWRP home screen.
    • Select advanced wipe.
    • Check the system, data, cache, and dalvik cache options.
    • Swipe to wipe.
  • Install the ROM.
    • Select the install option from the TWRP home screen.
    • Navigate to where you have the ROM zip stored on your sd card and select it.
    • Swipe to install.
      Most ROMs will run an installer script at this point but some ROMs have what is called an Aroma Installer which allow you to choose some install options before the script runs.​
    • You will also need to install the appropriate gapps package directly after installing the ROM.
  • Once you've installed all necessary zips you'll have an option to wipe cache/dalvik and an option to reboot system. Wipe the cache/dalvik, hit the back button, and hit the reboot system button.

z7e6jQa.jpg

[SIZE=+1]6. How To Install A Custom Kernel With TWRP Recovery[/SIZE]

Prerequisites: unlocked bootloader, TWRP recovery.

A custom kernel can open up a new level of control over your device, such as overclocking/underclocking, undervolting, changing governors, changing I/O schedulers, adjusting colour calibrations, adjusting sound calibrations, and many other options.

  • Download a kernel that is compatible with your current ROM.
  • Check the md5 to verify its integrity.
  • Enter TWRP recovery.
  • Select the install option from the TWRP home screen.
  • Navigate to the kernel and select it.
  • Swipe to install.
  • You'll have an option to wipe cache/dalvik and an option to reboot system. Wipe the cache/dalvik, hit the back button, and hit the reboot system button.

Once your phone has booted up you can use a kernel tuning app to change governors, I/O scheduler, clock speed, and other options. Some of the popular kernel apps are Trickster Mod, No Frills, Kernel Tuner, and many more.

z7e6jQa.jpg

[SIZE=+1]7. How To Flash The Stock Kernel (boot.img) With Fastboot[/SIZE]

Prerequisites: unlocked bootloader.

If you're running a custom kernel on Cyanogen OS you'll need to flash the stock kernel back in order to take an OTA update.

  • Download the appropriate set of stock images from this thread. Extract the zip and grab the "boot.img" file.
  • Put it in your fastboot folder (where you have fastboot.exe located) on your PC.
  • Boot into fastboot mode (power + volume up) and connect your phone to your PC via usb cable.
  • Open a command prompt from within your fastboot folder (shift + right click, select open command prompt here).
  • Issue this fastboot command:

    Code:
    fastboot flash boot boot.img
    It'll take a few seconds to flash the boot.img, once it's finished you can manually reboot your phone or use the following command to reboot it:

    Code:
    fastboot reboot
  • It's now safe to disconnect your usb cable.

Now you have the stock kernel back on your device.

z7e6jQa.jpg

[SIZE=+1]8. How To Flash The Cyanogen OS Fastboot Images[/SIZE]

Prerequisites: unlocked bootloader.

Please note: This procedure requires an unlocked bootloader. This procedure will factory reset your device! All user data (settings, apps, data on internal storage) will be wiped!

  • Download the latest stock images to your PC from here. If you don't want the latest build you can find all stock images mirrored here thanks to @Spannaa.
  • Reboot your device into Fastboot Mode (power + volume up) and connect your phone to your PC via usb cable.
  • Unzip the file you downloaded and put its contents into your fastboot folder (the same folder that you have adb.exe and fastboot.exe located in on your PC).
  • Open a command prompt from within your adb/fastboot folder (shift + right click, select open command prompt here).
  • Issue these fastboot commands:

    Code:
    fastboot flash modem NON-HLOS.bin
    fastboot flash sbl1 sbl1.mbn
    fastboot flash dbi sdi.mbn
    fastboot flash aboot emmc_appsboot.mbn
    fastboot flash rpm rpm.mbn
    fastboot flash tz tz.mbn
    fastboot flash LOGO logo.bin
    fastboot flash oppostanvbk static_nvbk.bin
    fastboot flash boot boot.img
    fastboot flash cache cache.img
    fastboot flash recovery recovery.img
    fastboot flash system system.img
    fastboot flash userdata userdata_64G.img
    or fastboot flash userdata userdata.img if you have the 16gb model)

    Please note: flashing the userdata will wipe your internal storage (your virtual sd card). It's possible to flash these images without that command if a full wipe isn't completely necessary in your situation.
  • Reboot your device with this command:

    Code:
    fastboot reboot
  • It's now safe to disconnect your usb cable.

z7e6jQa.jpg

[SIZE=+1]9. How To Update Modem/Firmware When Switching From KitKat To Lollipop (and vice versa)[/SIZE]

Prerequisites: unlocked bootloader.

  • To update from KitKat to Lollipop download the YOG4PAS1N0 firmware zip here:
    cm-12.1-YOG4PAS1N0-bacon-firmwareonly-fastboot.zip
    To revert from Lollipop to KitKat download the XNPH44s or XNPH05Q firmware zip here:
    cm-11s-XNPH44S-bacon-firmwareonly-fastboot.zip
    cm-11s-XNPH05Q-bacon-firmwareonly-fastboot.zip
  • Reboot your device into Fastboot Mode (power + volume up) and connect your phone to your PC via usb cable.
  • Unzip the file you downloaded and put its contents into your fastboot folder (the same folder that you have adb.exe and fastboot.exe located in on your PC).
  • Open a command prompt from within your adb/fastboot folder (shift + right click, select open command prompt here).
  • Issue these fastboot commands:

    Code:
    fastboot flash modem NON-HLOS.bin
    fastboot flash sbl1 sbl1.mbn
    fastboot flash dbi sdi.mbn
    fastboot flash aboot emmc_appsboot.mbn
    fastboot flash rpm rpm.mbn
    fastboot flash tz tz.mbn
    fastboot flash LOGO logo.bin
    fastboot flash oppostanvbk static_nvbk.bin
  • Reboot your device with this command:

    Code:
    fastboot reboot
  • It is now safe to disconnect your usb cable.

z7e6jQa.jpg

[SIZE=+1]10. How To Make Sure You Can Pretty Much Always Recover From An Accidentally Wiped System[/SIZE]

Prerequisites: unlocked bootloader, TWRP recovery.

There may come a time when you accidentally wipe your OS while trying to perform a basic cache wipe in recovery. Don't laugh, it can happen to the best of us. The best way to insure yourself against being stuck in recovery is to keep a ROM zip or a TWRP/CWM backup (a nandroid backup) on your sd card at all times.
This solution seems like common sense but apparently there are quite a few people out there who don't store a ROM or backup on their phone. You might think it's easy to just mount the OTG storage and copy a ROM across to your phone from your PC (which is definitely an option), but there's always a chance that you won't be near your HDD or sd card at the time, or it won't recognise your phone properly. Basically you need to insure yourself against Murphy's law.

z7e6jQa.jpg

[SIZE=+1]11. How To Backup & Restore Your EFS Partition[/SIZE]

Prerequisites: unlocked bootloader, root.

All too often on this device I've seen folks who have a corrupted or missing EFS Partition. This results in your IMEI being lost and no cellular activity on the device at all. This can be a royal PITA to fix, and some folks haven't been able to fix it at all. You can take a precautionary measure to safeguard yourself against this by taking a couple of minutes to back up your modemst files.

  • Open up Terminal Emulator on your phone (if you don't have it you can download it here).
  • Once it's open you'll be greeted with a command line prompt, in which you can enter text commands, the first thing you need to do is enable root access by entering this line (press the enter key on your on-screen keyboard after each command to issue it):

    Code:
    su

    If this is the first time you've used Terminal Emulator a Superuser or SuperSU popup will appear, make sure you grant root access.​
  • Now enter these two commands:

    Code:
    dd if=/dev/block/mmcblk0p10 of=/sdcard/modemst1.bin bs=512

    Code:
    dd if=/dev/block/mmcblk0p11 of=/sdcard/modemst2.bin bs=512

    The result should look like this:

    ty3eragy.jpg


    This will place two files (modemst1.bin & modemst2.bin) on the root of your internal storage, make sure you copy them to your PC immediately so that you have a backup there to use if you need to restore it in future.

If by chance you end up with a corrupt EFS partition all you need to do is flash the files back to your device using fastboot.

  • Boot into fastboot mode (power + volume up) and connect your phone to your PC via usb cable.
  • Make sure the two files are in your fastboot folder on your PC.
  • These fastboot commands will restore the files:

    Code:
    fastboot flash modemst1 modemst1.bin

    Code:
    fastboot flash modemst2 modemst2.bin
  • Reboot your device:

    Code:
    fastboot reboot
  • It's now safe to disconnect your usb cable.

Credit goes to @Vonnegut for originally posting this method in the TWRP thread.

z7e6jQa.jpg

aDlDoZJ.jpg

Donate To Me
 
Last edited:

ksoze11

Senior Member
Nov 30, 2011
149
8
The best way to insure yourself against being stuck in recovery is to keep a ROM zip or a TWRP/CWM backup (a nandroid backup) on your sd card at all times.

Can you confirm that backups made through CW recovery are fully functional? I remember that my previous phone's kernel wasn't backing up /preload while making nandroid backups...
 
  • Like
Reactions: inforgiven

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
Can you confirm that backups made through CW recovery are fully functional? I remember that my previous phone's kernel wasn't backing up /preload while making nandroid backups...

I don't use CWM recovery so I can't confirm that personally. I use TWRP and can confirm that backups are fully functional with that recovery.

Transmitted via Bacon
 

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
Ive rooted my OPO, how do i perform a nandroid backup ? when i rooted i dont know if i put a custom recovery on it.. i followed this guide https://forums.oneplus.net/threads/...snt-wipe-your-data.66270/page-16#post-3809224

You didn't install a custom recovery or unlock your bootloader if you followed that tutorial. Just unlock your bootloader, it'll wipe your data so just backup anything that's important first. Then you can flash TWRP recovery and make a nandroid backup.

Transmitted via Bacon
 
  • Like
Reactions: daringsmart

Quinnaay

Senior Member
Nov 2, 2013
290
22
urgh, i was hoping i could keep all my data. Think ill give it a miss, it was only so i can install Xposed, but that should work anyway right?
 

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
urgh, i was hoping i could keep all my data. Think ill give it a miss, it was only so i can install Xposed, but that should work anyway right?

If you're rooted you can just install the Xposed Framework apk and away you go. But, I'd strongly recommend you actually unlock your bootloader now, it's only gonna get harder to do the longer you wait.

Transmitted via Bacon
 

Quinnaay

Senior Member
Nov 2, 2013
290
22
Ive moved the "backups" folder containing all the files from my nandroid backup to PC if anything ever happens is it ok just on my PC or does it need to be on my phone?

edit: does this look right?

334t3r8.jpg
 
Last edited:

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
Ive moved the "backups" folder containing all the files from my nandroid backup to PC if anything ever happens is it ok just on my PC or does it need to be on my phone?

edit: does this look right?

334t3r8.jpg

It's fine to store it on your PC. But, you should have either a backup or a ROM zip on your phone at all times. If your system accidentally gets wiped or you run into some kinda trouble and you don't have one of those on your phone you're gonna kick yourself big time.

Yes it looks just fine.

Transmitted via Bacon
 
  • Like
Reactions: daringsmart

Quinnaay

Senior Member
Nov 2, 2013
290
22
It's fine to store it on your PC. But, you should have either a backup or a ROM zip on your phone at all times. If your system accidentally gets wiped or you run into some kinda trouble and you don't have one of those on your phone you're gonna kick yourself big time.

Yes it looks just fine.

Transmitted via Bacon

whats the best thing to leave on my phone? should i put the backup back then?
 

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
It's up to you. Being that the phone has a mammoth amount of internal storage I'd just leave a backup on it because that's the easiest solution (restore it and boot, no setup required). I currently have four full backups on my device.

Transmitted via Bacon
 
  • Like
Reactions: daringsmart

26.2man

Senior Member
Aug 12, 2010
445
46
Forest Hill MD
I have a backup on the phone and my PC. Are you suggesting a flashable ROM on the phone also? I have the international 64 GB model rooted unlocked running stock. Which flashable ROM are you suggesting. I am very happy with 11s.

Sent from my One using Tapatalk
 

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
I have a backup on the phone and my PC. Are you suggesting a flashable ROM on the phone also? I have the international 64 GB model rooted unlocked running stock. Which flashable ROM are you suggesting. I am very happy with 11s.

Sent from my One using Tapatalk

You don't need both, just one or the other is fine. It's just there as a failsafe. As for the ROM question:

Asking which ROM is best/most stable/fastest/prettiest, or asking for a suggestion isn't allowed so I can't answer that, here's why. To say one ROM is better is to infer that the others are inferior in some way. This is disrespectful to the devs who spend their spare time bringing us these awesome ROMs free of charge. Each user has different tastes anyway, the best way to see which ROM suits you is to flash a few and find out for yourself.

Transmitted via Bacon
 

26.2man

Senior Member
Aug 12, 2010
445
46
Forest Hill MD
Thanks. I think you misunderstood me. I know better than to get into the best ROM stuff. I was referring to the factory cm11s ROM and was wondering if there was a flashable one I could leave on my phone.

Sent from my One using Tapatalk
 

Heisenberg

Retired Forum Moderator
Jun 29, 2011
27,184
18,627
Knocking on your door
Thanks. I think you misunderstood me. I know better than to get into the best ROM stuff. I was referring to the factory cm11s ROM and was wondering if there was a flashable one I could leave on my phone.

Sent from my One using Tapatalk

Ahh I see, there is a recovery flashable version of cm11s available, it's in the dev section or general section.

Transmitted via Bacon
 

Top Liked Posts

  • There are no posts matching your filters.
  • 325
    [SIZE=+3]Heisenberg's How-To Guide For Beginners[/SIZE]
    [SIZE=+2]OnePlus One[/SIZE]
    W2OmtZJ.jpg
    [SIZE=+1]See Also:
    [INDEX] OnePlus One

    [FAQ] OnePlus One Frequently Asked Questions
    [/size]

    [SIZE=+1]Intro[/SIZE]

    This thread will serve as a location for basic how-to guides for the OnePlus One (Bacon). I'm going to start off with a couple of the more obvious ones and go from there. If anyone has any suggestions for additions please feel free to let me know.

    [size=+1]Prerequisites[/size]:

    You'll need a working adb/fastboot environment on your PC to get through some of these guides. Go here to download the Android SDK, which will give you most updated version of adb and fastboot. Scroll to the bottom of the page and find Other Download Options>SDK Tools Only, and grab the right version for your OS. While it's downloading create a folder in C:\ called SDK (C:\SDK). Once you've downloaded the zip you can extract it into your C:\SDK folder. Navigate to C:\SDK\android-sdk-windows and open SDK Manager.exe. In SDK Manager you need to install the following packages:

    Tools> Android SDK Tools, Android SDK Platform-tools
    Extras> Android Support Library

    Once you have installed those, inside C:\SDK you should see some new folders, one of them will be called platform-tools, within that folder you should see fastboot.exe and adb.exe. I'll refer to this as your fastboot folder/directory or working folder/directory during this guide. To make sure adb is correctly installed, open a command prompt from within your fastboot folder (hold shift + right click, select open command prompt here) and issue this command:
    Code:
    adb version

    If it returns a version number for Android Debug Bridge then you're good to go.

    You'll find universal adb/fastboot drivers here, download it and follow the installer, then reboot your PC.

    You can test adb by connecting your device to your PC while booted into Android (making sure that adb/usb debugging is enabled in Settings>Developer Options) with the screen unlocked and issuing this command:
    Code:
    adb devices
    It should return your device serial number, if so, adb is working.

    You can test fastboot by connecting your device to your PC while booted into fastboot mode (power + volume up) and issuing this command:
    Code:
    fastboot devices
    It should return your device serial number, if so, fastboot is working.

    By attempting any of the processes listed this thread you accept full responsibility for your actions. I will not be held responsible if your device stops working, catches on fire, or turns into a hipster and claims to have been modified before it was cool. Make sure you read a section and fully understand it before attempting it.

    z7e6jQa.jpg

    [SIZE=+1]Index[/SIZE]
    1. How To Unlock Your Bootloader
    2. How To Install A Custom Recovery On Your Device
    3. How To Make A Nandroid Backup With TWRP Recovery
    4. How To Root Your Stock Rom
    5. How To Install A ROM with TWRP Recovery
    6. How To Install A Custom Kernel With TWRP Recovery
    7. How To Flash The Stock Kernel With Fastboot
    8. How To Flash The Cyanogen OS Fastboot Images
    9. How To Update Modem/Firmware When Switching From KitKat To Lollipop (and vice versa)
    10. How To Make Sure You Can Pretty Much Always Recover From An Accidentally Wiped System
    11. How To Backup & Restore Your EFS Partition

    z7e6jQa.jpg

    [SIZE=+1]1. How To Unlock Your Bootloader[/SIZE]

    • Power off your phone then boot into fastboot mode (power + volume up).
    • Connect your phone to your PC via usb cable.
    • Open a command prompt from within your fastboot folder (navigate to where you have fastboot.exe located on your PC, shift + right click anywhere within that folder, select open command prompt here).
    • Check your fastboot connection by issuing this command:

      Code:
      fastboot devices

      It should return your device serial number, if not you need to make sure your drivers are installed correctly.​
    • Once you've confirmed your fastboot connection issue this command:

      Code:
      fastboot oem unlock

      The device will now go through the automated unlocking process, just let it do its thing and it'll boot up into Android.​
    • Go back to fastboot mode and issue this command to ensure that it worked:

      Code:
      fastboot oem device-info

      It should have a couple of lines there, both with the flag set to true.​
    • You can now reboot your phone using this command:

      Code:
      fastboot reboot
    • It's now safe to disconnect your usb cable.

    Please note: this will erase all user data from your device, it is best to do this before you really start using the device and installing apps or putting data on the internal storage.

    z7e6jQa.jpg

    [SIZE=+1]2. How To Install A Custom Recovery On Your Device[/SIZE]

    Prerequisites: unlocked bootloader.

    • You first need to go into Settings/Developer Options and uncheck the "Update recovery with system updates" option (to enable Developer Options go into Settings/About Phone and click 'build number' about seven or eight times).
    • Download the recovery of your choice (my preferred recovery is TWRP, and we'll be using that for this guide, grab it here).
    • Make sure you check the md5 to verify its integrity.
    • Place the file in your fastboot folder (this is where fastboot.exe is located on your PC).
    • Put the phone in fastboot mode and connect it to your PC via usb cable.
    • Open a command prompt from within your fastboot folder (shift + right click, select open command prompt here), and enter the following commands:

      Code:
      fastboot flash recovery openrecovery-twrp-2.8.1.0-bacon.img

      (The recovery filename in the command will change depending on which recovery you're flashing)

      Code:
      fastboot format cache

      Code:
      fastboot reboot
    • Let the device reboot, it's now safe to disconnect your usb cable.

      Now you can use the advanced power menu (or the power + volume down button combo) to enter your custom recovery.

    Please note, if you have taken the stock Lollipop update please read the following:

    For some reason CM12S doesn't respect the on/off toggle for the "update CM recovery" option in Developer Options, it just replaces whatever custom recovery you've flashed with the CM recovery regardless of whether that option is unelected.

    Flash your custom recovery again, but after flashing don't do a normal reboot. After the flash has succeeded disconnect the usb cable, then power down the phone by holding the power button down, once it's powered off use the power + volume down button combo to boot directly into recovery. This first forced reboot into recovery somehow subverts what was keeping it from staying flashed and all subsequent normal reboots into recovery will boot into the custom recovery of your choice.


    z7e6jQa.jpg

    [SIZE=+1]3. How To Make A Nandroid Backup With TWRP Recovery[/SIZE]

    Prerequisites: unlocked bootloader, TWRP recovery.

    A nandroid backup is a very important thing to have before installing any custom software on your device. It's basically a backup of your stock system that you can fall back on if anything goes wrong or if you just want your stock ROM back. You can also use the backup tool to create a backup of your favourite ROM set up exactly the way you like it. The backup you create can be easily restored using the restore tool in TWRP recovery.

    All you need to do is enter TWRP recovery, select the backup option from the TWRP home screen, check the system/data/boot boxes, and swipe to backup. The process will take a few minutes.

    z7e6jQa.jpg

    [SIZE=+1]4. How To Root Your Stock Rom[/SIZE]

    Prerequisites: unlocked bootloader, TWRP recovery.

    • First you need to download SuperSU.
    • Enter TWRP recovery via the advanced power menu (or power + volume down).
    • Select the install option from the TWRP home screen.
    • Navigate to where you have SuperSU stored on your sd card and select it.
    • Swipe to install.
    • Once you've installed SuperSU you'll have an option to wipe cache/dalvik and an option to reboot system. Wipe the cache/dalvik, hit the back button, and hit the reboot system button. That's it.

    z7e6jQa.jpg

    [SIZE=+1]5. How To Install A ROM with TWRP Recovery[/SIZE]

    Prerequisites: unlocked bootloader, TWRP recovery.

    Installing a ROM is a pretty straight forward and easy process. Before you install anything you should make a nandroid backup (instructions above).

    • Download a ROM and appropriate Gapps package and place on your device.
    • Boot into your custom recovery.
    • Perform a full wipe.
      • Select the wipe option from the TWRP home screen.
      • Select advanced wipe.
      • Check the system, data, cache, and dalvik cache options.
      • Swipe to wipe.
    • Install the ROM.
      • Select the install option from the TWRP home screen.
      • Navigate to where you have the ROM zip stored on your sd card and select it.
      • Swipe to install.
        Most ROMs will run an installer script at this point but some ROMs have what is called an Aroma Installer which allow you to choose some install options before the script runs.​
      • You will also need to install the appropriate gapps package directly after installing the ROM.
    • Once you've installed all necessary zips you'll have an option to wipe cache/dalvik and an option to reboot system. Wipe the cache/dalvik, hit the back button, and hit the reboot system button.

    z7e6jQa.jpg

    [SIZE=+1]6. How To Install A Custom Kernel With TWRP Recovery[/SIZE]

    Prerequisites: unlocked bootloader, TWRP recovery.

    A custom kernel can open up a new level of control over your device, such as overclocking/underclocking, undervolting, changing governors, changing I/O schedulers, adjusting colour calibrations, adjusting sound calibrations, and many other options.

    • Download a kernel that is compatible with your current ROM.
    • Check the md5 to verify its integrity.
    • Enter TWRP recovery.
    • Select the install option from the TWRP home screen.
    • Navigate to the kernel and select it.
    • Swipe to install.
    • You'll have an option to wipe cache/dalvik and an option to reboot system. Wipe the cache/dalvik, hit the back button, and hit the reboot system button.

    Once your phone has booted up you can use a kernel tuning app to change governors, I/O scheduler, clock speed, and other options. Some of the popular kernel apps are Trickster Mod, No Frills, Kernel Tuner, and many more.

    z7e6jQa.jpg

    [SIZE=+1]7. How To Flash The Stock Kernel (boot.img) With Fastboot[/SIZE]

    Prerequisites: unlocked bootloader.

    If you're running a custom kernel on Cyanogen OS you'll need to flash the stock kernel back in order to take an OTA update.

    • Download the appropriate set of stock images from this thread. Extract the zip and grab the "boot.img" file.
    • Put it in your fastboot folder (where you have fastboot.exe located) on your PC.
    • Boot into fastboot mode (power + volume up) and connect your phone to your PC via usb cable.
    • Open a command prompt from within your fastboot folder (shift + right click, select open command prompt here).
    • Issue this fastboot command:

      Code:
      fastboot flash boot boot.img
      It'll take a few seconds to flash the boot.img, once it's finished you can manually reboot your phone or use the following command to reboot it:

      Code:
      fastboot reboot
    • It's now safe to disconnect your usb cable.

    Now you have the stock kernel back on your device.

    z7e6jQa.jpg

    [SIZE=+1]8. How To Flash The Cyanogen OS Fastboot Images[/SIZE]

    Prerequisites: unlocked bootloader.

    Please note: This procedure requires an unlocked bootloader. This procedure will factory reset your device! All user data (settings, apps, data on internal storage) will be wiped!

    • Download the latest stock images to your PC from here. If you don't want the latest build you can find all stock images mirrored here thanks to @Spannaa.
    • Reboot your device into Fastboot Mode (power + volume up) and connect your phone to your PC via usb cable.
    • Unzip the file you downloaded and put its contents into your fastboot folder (the same folder that you have adb.exe and fastboot.exe located in on your PC).
    • Open a command prompt from within your adb/fastboot folder (shift + right click, select open command prompt here).
    • Issue these fastboot commands:

      Code:
      fastboot flash modem NON-HLOS.bin
      fastboot flash sbl1 sbl1.mbn
      fastboot flash dbi sdi.mbn
      fastboot flash aboot emmc_appsboot.mbn
      fastboot flash rpm rpm.mbn
      fastboot flash tz tz.mbn
      fastboot flash LOGO logo.bin
      fastboot flash oppostanvbk static_nvbk.bin
      fastboot flash boot boot.img
      fastboot flash cache cache.img
      fastboot flash recovery recovery.img
      fastboot flash system system.img
      fastboot flash userdata userdata_64G.img
      or fastboot flash userdata userdata.img if you have the 16gb model)

      Please note: flashing the userdata will wipe your internal storage (your virtual sd card). It's possible to flash these images without that command if a full wipe isn't completely necessary in your situation.
    • Reboot your device with this command:

      Code:
      fastboot reboot
    • It's now safe to disconnect your usb cable.

    z7e6jQa.jpg

    [SIZE=+1]9. How To Update Modem/Firmware When Switching From KitKat To Lollipop (and vice versa)[/SIZE]

    Prerequisites: unlocked bootloader.

    • To update from KitKat to Lollipop download the YOG4PAS1N0 firmware zip here:
      cm-12.1-YOG4PAS1N0-bacon-firmwareonly-fastboot.zip
      To revert from Lollipop to KitKat download the XNPH44s or XNPH05Q firmware zip here:
      cm-11s-XNPH44S-bacon-firmwareonly-fastboot.zip
      cm-11s-XNPH05Q-bacon-firmwareonly-fastboot.zip
    • Reboot your device into Fastboot Mode (power + volume up) and connect your phone to your PC via usb cable.
    • Unzip the file you downloaded and put its contents into your fastboot folder (the same folder that you have adb.exe and fastboot.exe located in on your PC).
    • Open a command prompt from within your adb/fastboot folder (shift + right click, select open command prompt here).
    • Issue these fastboot commands:

      Code:
      fastboot flash modem NON-HLOS.bin
      fastboot flash sbl1 sbl1.mbn
      fastboot flash dbi sdi.mbn
      fastboot flash aboot emmc_appsboot.mbn
      fastboot flash rpm rpm.mbn
      fastboot flash tz tz.mbn
      fastboot flash LOGO logo.bin
      fastboot flash oppostanvbk static_nvbk.bin
    • Reboot your device with this command:

      Code:
      fastboot reboot
    • It is now safe to disconnect your usb cable.

    z7e6jQa.jpg

    [SIZE=+1]10. How To Make Sure You Can Pretty Much Always Recover From An Accidentally Wiped System[/SIZE]

    Prerequisites: unlocked bootloader, TWRP recovery.

    There may come a time when you accidentally wipe your OS while trying to perform a basic cache wipe in recovery. Don't laugh, it can happen to the best of us. The best way to insure yourself against being stuck in recovery is to keep a ROM zip or a TWRP/CWM backup (a nandroid backup) on your sd card at all times.
    This solution seems like common sense but apparently there are quite a few people out there who don't store a ROM or backup on their phone. You might think it's easy to just mount the OTG storage and copy a ROM across to your phone from your PC (which is definitely an option), but there's always a chance that you won't be near your HDD or sd card at the time, or it won't recognise your phone properly. Basically you need to insure yourself against Murphy's law.

    z7e6jQa.jpg

    [SIZE=+1]11. How To Backup & Restore Your EFS Partition[/SIZE]

    Prerequisites: unlocked bootloader, root.

    All too often on this device I've seen folks who have a corrupted or missing EFS Partition. This results in your IMEI being lost and no cellular activity on the device at all. This can be a royal PITA to fix, and some folks haven't been able to fix it at all. You can take a precautionary measure to safeguard yourself against this by taking a couple of minutes to back up your modemst files.

    • Open up Terminal Emulator on your phone (if you don't have it you can download it here).
    • Once it's open you'll be greeted with a command line prompt, in which you can enter text commands, the first thing you need to do is enable root access by entering this line (press the enter key on your on-screen keyboard after each command to issue it):

      Code:
      su

      If this is the first time you've used Terminal Emulator a Superuser or SuperSU popup will appear, make sure you grant root access.​
    • Now enter these two commands:

      Code:
      dd if=/dev/block/mmcblk0p10 of=/sdcard/modemst1.bin bs=512

      Code:
      dd if=/dev/block/mmcblk0p11 of=/sdcard/modemst2.bin bs=512

      The result should look like this:

      ty3eragy.jpg


      This will place two files (modemst1.bin & modemst2.bin) on the root of your internal storage, make sure you copy them to your PC immediately so that you have a backup there to use if you need to restore it in future.

    If by chance you end up with a corrupt EFS partition all you need to do is flash the files back to your device using fastboot.

    • Boot into fastboot mode (power + volume up) and connect your phone to your PC via usb cable.
    • Make sure the two files are in your fastboot folder on your PC.
    • These fastboot commands will restore the files:

      Code:
      fastboot flash modemst1 modemst1.bin

      Code:
      fastboot flash modemst2 modemst2.bin
    • Reboot your device:

      Code:
      fastboot reboot
    • It's now safe to disconnect your usb cable.

    Credit goes to @Vonnegut for originally posting this method in the TWRP thread.

    z7e6jQa.jpg

    aDlDoZJ.jpg

    Donate To Me
    6
    Tried searching but couldn't find any info on this...
    Quick post about how an OTA works.
    In order to save bandwith, OTAs patches files already existing in our system. In other words, OTA zips don't come with a full txt/apk/jar/lib/whatever file and then just overwrite the old one. They come with files containing only the binary code which must be added. In this way, they can release an OTA of 20MB instead of one of 100MB. Can you see the point?

    For example, let's say the OTA wants to patch the nextcamera.apk. A routine gets launched (in pascal) and remove some byte and add some more to the existing apk file. Of course this patching method do not work with each and every version of nextcamera.apk but only with one version of it (the more recent one).
    That's why the script calculates and compares the HASH of each and every file that is going to be patched. If all of the the files that must be updated pass the test, the OTA will start patching them, otherwise the installation will be aborted. Even if the HASH of just one file differs from the expected HASH, the installation will stop. That's why ppl must be very careful if they want to edit the build.prop file or replace a library and so on.
    Here's another example. Let's say that i have installed the Xposed framework. When Xposed gets activated (by pressing the install button inside the app), it replaces the app_process file in the system/bin (but only after making a backup of the original one).
    Now, let's say that, i've just received an OTA that wants to update the app_process binary. If i don't replace the modified one (uninstalling Xposed from inside the app) before launching the script, i can be 101% sure that the installation will be aborted.

    As for all of the other partitions (boot, aboot, modem, tz, LOGO etc etc) that might be updated with the OTA, the script overwrite them (if needed), so any custom kernel (or recovery if i didn't unflag the developer option) will be overwritten by brute force.

    To sum it up: only changes in the system can stop an OTA installation. If an OTA fails, just take a recovery log and look what file didn't match the expected HASH.
    Just for the sake of statistics, i can tell that an OTA updates on average about 450 files...so there are about 450 checks which must be passed in order for the installation to be succesfull.

    P.S. Timmaaa, thank you for your work, you put up a very nice guide for beginners.
    5
    here is the full log. then advice me please.
    ____________________________________________________
    C:\Users\Musheer\Desktop\OnePlus>adb version
    Android Debug Bridge version 1.0.32

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash modem NON-HLOS.bin
    target reported max download size of 536870912 bytes
    sending 'modem' (56369 KB)...
    OKAY [ 1.768s]
    writing 'modem'...
    OKAY [ 1.053s]
    finished. total time: 2.821s

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash sbl1 sbl1.mbn
    target reported max download size of 536870912 bytes
    sending 'sbl1' (295 KB)...
    OKAY [ 0.016s]
    writing 'sbl1'...
    OKAY [ 0.016s]
    finished. total time: 0.031s

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash dbi sdi.mbn
    target reported max download size of 536870912 bytes
    sending 'dbi' (11 KB)...
    OKAY [ 0.000s]
    writing 'dbi'...
    OKAY [ 0.016s]
    finished. total time: 0.016s

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash aboot emmc_appsboot.mbn
    target reported max download size of 536870912 bytes
    sending 'aboot' (376 KB)...
    OKAY [ 0.016s]
    writing 'aboot'...
    OKAY [ 0.016s]
    finished. total time: 0.031s

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash rpm rpm.mbn
    target reported max download size of 536870912 bytes
    sending 'rpm' (185 KB)...
    OKAY [ -0.000s]
    writing 'rpm'...
    OKAY [ -0.000s]
    finished. total time: 0.016s

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash tz tz.mbn
    target reported max download size of 536870912 bytes
    sending 'tz' (283 KB)...
    OKAY [ 0.016s]
    writing 'tz'...
    OKAY [ 0.016s]
    finished. total time: 0.031s

    C:\Users\Musheer\Desktop\OnePlus>fastboot flash LOGO logo.bin
    target reported max download size of 536870912 bytes
    sending 'LOGO' (9591 KB)...
    OKAY [ 0.297s]
    writing 'LOGO'...
    OKAY [ 0.188s]
    finished. total time: 0.484s

    C:\Users\Musheer\Desktop\OnePlus>fastboot update -w cm-11.0-XNPH44S-bacon-signed
    -fastboot.zip
    target reported max download size of 536870912 bytes
    archive does not contain 'boot.sig'
    archive does not contain 'recovery.sig'
    failed to allocate 820487604 bytes
    error: update package missing system.img

    C:\Users\Musheer\Desktop\OnePlus>fastboot reboot
    rebooting...

    finished. total time: -0.000s

    C:\Users\Musheer\Desktop\OnePlus>


    Something is failing with the 'fastboot update' command so flash everything manually:
    Code:
    fastboot flash modem NON-HLOS.bin
    fastboot flash sbl1 sbl1.mbn
    fastboot flash dbi sdi.mbn
    fastboot flash aboot emmc_appsboot.mbn
    fastboot flash rpm rpm.mbn
    fastboot flash tz tz.mbn
    fastboot flash LOGO logo.bin
    And as 44S contains static_nvbk.bin, this needs flashing too ( @timmaaa - the guide needs updating for 44S )
    Code:
    fastboot flash oppostanvbk static_nvbk.bin
    Then manually flash the imgs too:
    Code:
    fastboot flash boot boot.img
    fastboot flash cache cache.img
    fastboot flash recovery recovery.img
    fastboot flash system system.img
    fastboot flash userdata userdata_64G.img (or userdata.img for 16G version)
    fastboot reboot
    5
    Hey @timmaaa, just spotted you're now a mod.

    Congratulations - I'm sure that with your cool, calm temperament, you'll be awesome :good:
    Yes sir, I've only just been inducted into the moderator ranks but I'm looking forward to my new position. Thanks for your kind words.

    Transmitted via Bacon
    5
    Updated 2015/10/10!

    Added:


    8b. How To Make Sure Your Firmware Is Updated For 5.1 ROMs
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone