• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE] Unlock/Root/Flash for Nexus 5X

Search This thread

Unconn

Senior Member
Dec 3, 2009
396
109
Raleigh
Hello.

Today approximately 10 hours ago, while refreshing my facebook app, my Nexus 5x froze and rebooted. For 3-4 hours I attempted to get it to boot and it would display 'Google' for about 5-10 seconds then turn off. I am able to get in to fastboot mode; however, entering recovery mode only works about 1 out of 10 times.

A co-worker of mine pointed me to this forum to possibly reload factory image onto the phone. However, it seems a key component in doing so is unlocking the bootloader, which requires turning on dev tools in the phone settings. For reasons stated above, I am unable to do this.

Are there any other options for me?
Thanks,

Dan

I am having the same issue on my wife's 5X. All stock. Listening to podcasts on the way home and it shut down and starts rebooting. Never unlocked, never Developer mode. Now it just reboots every 10 seconds. I have tried Clearing Cache and ever a Factory Reset and that same thing. Something wrong with the December 2016 update?!?

EDIT: it is still on Nov update (N5D91L) maybe it was a bad update attempt..

EDIT2: This could be the reason...

Last EDIT: Hardware issue...
 
Last edited:

ljfnky

Senior Member
Mar 11, 2012
74
26
I'm in the process of learning so I can root my 5x and I'm was wondering since we can now download TWRP Thanks to Team Win at the Play Store if this changes the process of rooting in anyway as per OP Thanks and sry if this is dumb question.
 

ulxerker

Senior Member
Jul 6, 2015
4,144
1,084
Google Pixel 5
I'm in the process of learning so I can root my 5x and I'm was wondering since we can now download TWRP Thanks to Team Win at the Play Store if this changes the process of rooting in anyway as per OP Thanks and sry if this is dumb question.

for all: news about the new TWRP app on Google Play you can find here.

of course, you can still stay with the procedures of the thread's OP. the app is just supposed to be more user friendly and intended for "beginners" for an easier installation/update of TWRP.
 

truneaux

Member
Dec 21, 2016
7
3
Cannot install TWRP properly

Hi folks,

this tutorial read great. But I wasn't able to install TWRP properly. Here's the story:

- I got a brand new 5X and don't want to use Goolge SW at all
- I decided to use CopperheadOS as custom ROM
- trying to install TWRP 3.0.2-2 (with tips from another site) I got stuck being asked for a decrypt password. I hadn't set up a passord on the device before and tried "default_password" which didn't work
- having a lack of further ideas I simply flashed the custom ROM which worked fine
- now reading of EFS backups being important I tried to install TWRP 3.0.2-3 and I'm stuck at the same point:
TWRP keeps asking for a password to decrypt, cannot mount /cache ... not being able to backup anything

can I revert to stock with a factory image and start from the beginning ?
or how would I get across these passwords ?

I'm on MAC / Linux, no Windows available or wanted ...

Any ideas or recommendations would be kindly appreciated.

thanks in advance

truneaux
 

SlimSnoopOS

Senior Member
Jan 29, 2011
8,052
3,348
Hi folks,

this tutorial read great. But I wasn't able to install TWRP properly. Here's the story:

- I got a brand new 5X and don't want to use Goolge SW at all
- I decided to use CopperheadOS as custom ROM
- trying to install TWRP 3.0.2-2 (with tips from another site) I got stuck being asked for a decrypt password. I hadn't set up a passord on the device before and tried "default_password" which didn't work
- having a lack of further ideas I simply flashed the custom ROM which worked fine
- now reading of EFS backups being important I tried to install TWRP 3.0.2-3 and I'm stuck at the same point:
TWRP keeps asking for a password to decrypt, cannot mount /cache ... not being able to backup anything

can I revert to stock with a factory image and start from the beginning ?
or how would I get across these passwords ?

I'm on MAC / Linux, no Windows available or wanted ...

Any ideas or recommendations would be kindly appreciated.

thanks in advance

truneaux

Yes you can start over with a factory image. Idk about the password issue, usually the "default_password" works on TWRP or your email account if you have signed into the phone.

When you say "brand new," this is a freshly unwrapped Nexus 5X from a store or a "like new" 5X purchased from someone online?
 

Rakkos98

Member
Nov 14, 2014
45
8
Hey,
I have got prolem with unlock bootloader when i write fastboot oem unlock nad i have unlock bootloader and i write fastboot reboot my phone erasing and start. I restart my phone and turn on fastboot mode and my bootloader again locked. Why???
 

SlimSnoopOS

Senior Member
Jan 29, 2011
8,052
3,348
Hey,
I have got prolem with unlock bootloader when i write fastboot oem unlock nad i have unlock bootloader and i write fastboot reboot my phone erasing and start. I restart my phone and turn on fastboot mode and my bootloader again locked. Why???

Sounds like the motherboard was replaced. That is associated with "No RPMB" being displayed on the bootloader screen. See if the second post helps you.

http://forum.xda-developers.com/nexus-5x/help/rpmb-impossibility-to-unlock-bootloader-t3483339

If not, request a replacement.
 

Rakkos98

Member
Nov 14, 2014
45
8

truneaux

Member
Dec 21, 2016
7
3
Yes you can start over with a factory image. Idk about the password issue, usually the "default_password" works on TWRP or your email account if you have signed into the phone.

When you say "brand new," this is a freshly unwrapped Nexus 5X from a store or a "like new" 5X purchased from someone online?

Hi SlimSnoopOS,
yep, "brand new" means from the store, not "like new" and used from someone else. I will try and start over with the factory image and report back about the issue with the password and post found solutions.
Thanks for the hint
 

Modder001

Senior Member
Sep 18, 2016
171
28
Hello guys and @SlimSnoopOS @sfhub
I bought nexus 5x along with my friend back in july 2016
It had freezing issue from the day it was unboxed , i hoped that android n update would solve it .
Unfortunately it did not
So can someone please tell me solution ?
Description of my issue :
My device randomly freezes while loading social media messages. Also if i set up some lock like pattern/pin, and leave it overnight untouched,.... I get black screen on morning.
But it is not shut down.
If I press power button for few seconds (Like when accessing power menu) I get normal vibration. But I don't see anything on screen.
So i have to press power button for 10 or more than 10 seconds to see a bootlogo and bootanimation.
After bootup it lags a lot while on lockscreen
This issue is bugging me a lot and I need help ASAP
Thanks
PS: I can't return my device as it was a gift . Amazon does not replace gifts and I've tried factory reset for 3 times and flashed factory image for 2 times
Please help me ASAP , I'm depressed due to this issue
(My friend sent me this phone through gift option on amazon ... but I actually paid to my friend.. It's weird I know)
Help me guys .. I used all my savings to buy this phone. I want to solve this issue
 

sfhub

Senior Member
Oct 23, 2008
5,342
7,220
Hello guys and @SlimSnoopOS @sfhub
I bought nexus 5x along with my friend back in july 2016
It had freezing issue from the day it was unboxed , i hoped that android n update would solve it .
Unfortunately it did not
So can someone please tell me solution ?
Description of my issue :
My device randomly freezes while loading social media messages. Also if i set up some lock like pattern/pin, and leave it overnight untouched,.... I get black screen on morning.
But it is not shut down.
If I press power button for few seconds (Like when accessing power menu) I get normal vibration. But I don't see anything on screen.
So i have to press power button for 10 or more than 10 seconds to see a bootlogo and bootanimation.
After bootup it lags a lot while on lockscreen
This issue is bugging me a lot and I need help ASAP
Thanks
PS: I can't return my device as it was a gift . Amazon does not replace gifts and I've tried factory reset for 3 times and flashed factory image for 2 times
Please help me ASAP , I'm depressed due to this issue
(My friend sent me this phone through gift option on amazon ... but I actually paid to my friend.. It's weird I know)
Help me guys .. I used all my savings to buy this phone. I want to solve this issue
Factory reset and set it up with new google account with no additional apps installed. See if it is still happening. If so, maybe it is hardware. If not, then it is software and you need to figure out which.

I used to get something like that after upgrading to 7.1 but then I updated the keyboard app and disabled any of the word suggestions and everything was much smoother.
 

Modder001

Senior Member
Sep 18, 2016
171
28
Factory reset and set it up with new google account with no additional apps installed. See if it is still happening. If so, maybe it is hardware. If not, then it is software and you need to figure out which.

I used to get something like that after upgrading to 7.1 but then I updated the keyboard app and disabled any of the word suggestions and everything was much smoother.
Thanks for the reply . but I have tried factory resetting it twice and second time I didn't put any account. So actually the issue didn't occur for a day. So I decided to put my google account. and when i picked my phone for doing that . It hanged again and I had to force restart !!!!!!!!
I can't guess what is wrong with my phone.

SO please help
Edit : whenever i try to debug it and plug in usb issue never occurs. I used it for 2 days with usb connected :v
 
Last edited:

craggert

New member
Dec 22, 2016
1
0
i am in the bootloader and i type fastboot devices and it does not reply serial number or anything noted above it just go to the new line and over nothing happens . Any suggestions what i am doing wrong.
 

ZLevente

Senior Member
Oct 6, 2013
124
15
i am in the bootloader and i type fastboot devices and it does not reply serial number or anything noted above it just go to the new line and over nothing happens . Any suggestions what i am doing wrong.

Me too, but i can do anyting. Unlocked BL and installed TWRP and CM14.1 :)
Maybe it works for you too.

But i have a question anyway @SlimSnoopOS or everyone who knows.
I made an EFS backup, but i can't move to my Google Drive (failed) can't copy to my PC (failed again, it skip .win files)
Why? How to move it somewhere safe? :D
Tried to zip it, but it become 0kb
Every other files works, just the .win not.
 

No_Signal

Senior Member
Feb 28, 2014
83
19
[SIZE=+3]Heisenberg's How-To Guide For Beginners[/SIZE]
You'll need a working adb/fastboot environment on your PC to get through some of these guides.

Please do not install adb/fastboot via any means other than the Android SDK, using other tools (like Minimal adb & fastboot) can lead to an outdated setup and various problems with flashing. You've been warned, other tools will not be supported in this thread.

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 Repository, Google USB Driver

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.

First of all, thanks for this excellent thread! Regarding this first steps to get one started it needs to be fixed though. Following the the link and downloading the SDK Tools package the folder structure is a different one than described by OP. No android-sdk-windows for example.
SDK Manager.exe is found in \lib is asking for tools\android.bat that is not existent by default folder structure, androit.bat is instead in the root folder (C:\SDK when following the guides naming). Copying the SDK Manager.exe to the root folder and executing it, ends with a "Failed to execute tools\android.bat:, error 2 The system cannot find the file specified", same error as above.
Tools and Extras Folder are not created from the zip file structure and Google USB Driver are not in the .zip file either.
Any help?
 
Last edited:

sfhub

Senior Member
Oct 23, 2008
5,342
7,220
SO please help
Edit : whenever i try to debug it and plug in usb issue never occurs. I used it for 2 days with usb connected :v
I am just making a wild guess here, but plugging in USB supplies power so maybe there is an issue with the battery.

What happens if you plug in and older low power charger (or the stock charger if you don't have one)
 

No_Signal

Senior Member
Feb 28, 2014
83
19
[SIZE=+1]10. How To Flash The Factory Images (And Return To Stock)[/SIZE]

I try to flash the latest 6.0.1. factory image from Google. Following the steps from first post, progress stops at fastboot flash boot C:\bullhead\images\boot.img, FAILED (remote: invalid bootloader image). What went wrong there, what might be the issue? I tried to restore a NANDROID backup but the device won't go past the Google Boot logo (white one, not animated).

Another question, why using method above over flash-all method described on https://developers.google.com/android/images ? With flash-all described there I got 6.0.1. working.
 
Last edited:

SlimSnoopOS

Senior Member
Jan 29, 2011
8,052
3,348
Sorry for being so quiet the last few days. I caught a stomach virus and didn't feel like doing much of anything.

Hi SlimSnoopOS,
yep, "brand new" means from the store, not "like new" and used from someone else. I will try and start over with the factory image and report back about the issue with the password and post found solutions.
Thanks for the hint

Gotcha. Just thought I'd ask in case you had a used phone. Were you able to get this working btw?

i am in the bootloader and i type fastboot devices and it does not reply serial number or anything noted above it just go to the new line and over nothing happens . Any suggestions what i am doing wrong.

If on Windows, sounds like a driver issue. Try deleting that installed driver and reinstalling it while in the bootloader.

Me too, but i can do anyting. Unlocked BL and installed TWRP and CM14.1 :)
Maybe it works for you too.

But i have a question anyway @SlimSnoopOS or everyone who knows.
I made an EFS backup, but i can't move to my Google Drive (failed) can't copy to my PC (failed again, it skip .win files)
Why? How to move it somewhere safe? :D
Tried to zip it, but it become 0kb
Every other files works, just the .win not.

I had to email it to myself when I tried a year ago. Of course, I use OSX so my transfer options are limited. Maybe adb push or try moving the files over while in TWRP?

First of all, thanks for this excellent thread! Regarding this first steps to get one started it needs to be fixed though. Following the the link and downloading the SDK Tools package the folder structure is a different one than described by OP. No android-sdk-windows for example.
SDK Manager.exe is found in \lib is asking for tools\android.bat that is not existent by default folder structure, androit.bat is instead in the root folder (C:\SDK when following the guides naming). Copying the SDK Manager.exe to the root folder and executing it, ends with a "Failed to execute tools\android.bat:, error 2 The system cannot find the file specified", same error as above.
Tools and Extras Folder are not created from the zip file structure and Google USB Driver are not in the .zip file either.
Any help?

This is difficult to troubleshoot because I use OSX. Although, I don't believe I had to drag any files anywhere. Did you download the 1 GB, 64 bit exe?

I try to flash the latest 6.0.1. factory image from Google. Following the steps from first post, progress stops at fastboot flash boot C:\bullhead\images\boot.img, FAILED (remote: invalid bootloader image). What went wrong there, what might be the issue? I tried to restore a NANDROID backup but the device won't go past the Google Boot logo (white one, not animated).

Another question, why using method above over flash-all method described on https://developers.google.com/android/images ? With flash-all described there I got 6.0.1. working.

Show me the screenshot of your computer and this error.

Sometimes the flash-all does not work for people. Others have a personal preference to write out each command. This guide has the manual way written out so that new users have a a familiarity and comfort with adb/fastboot commands. Both methods will end in the same result, a completely wiped, factory reset phone.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 262
    [SIZE=+3]Heisenberg's How-To Guide For Beginners[/SIZE]
    [SIZE=+2]Nexus 5X[/SIZE]
    GLoF1eq.jpg

    [SIZE=+1]Intro[/SIZE]

    This thread will serve as a location for basic how-to guides for the Nexus 5X. 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.

    If you're unsure about something please read the FAQ section in post #2 before creating a post to ask a question.

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

    You'll need a working adb/fastboot environment on your PC to get through some of these guides. Below are two options for install.

    Please do not install adb/fastboot via any means other than the Android SDK, using other tools (like Minimal adb & fastboot) can lead to an outdated setup and various problems with flashing. You've been warned, other tools will not be supported in this thread.

    Option A
    Google hosts ADB/Fastboot (platform-tools) for Windows, OSX, and Linux. This is a minimal download, in contrast to Option 2. These links and file sizes may be updated periodically by Google. If using Windows, download the Google USB Driver and follow the driver install instructions. Once you have downloaded the platform-tools zip, extract the file then transfer the platform-tools folder to your desktop. The platform-tools folder contains adb, fastboot, and several other files. Note that clicking any link for platform-tools will immediately start a download.

    *Windows: platform-tools. Google USB Driver install.
    *OSX: platform-tools. For additional details on how to use OSX and adb/fastboot commands, see post #3.
    *Linux: platform-tools.

    See Option B below for old method to install adb/fastboot:

    Option B
    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 Repository, Google USB Driver

    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.


    For Option A and B, 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 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 the bootloader (power + volume down) 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.

    z7e6jQa.jpg

    [SIZE=+1]Quick Tips[/SIZE]

    How to boot into the bootloader:
    Power off your device. Once it's powered off hold power + volume down and the phone will boot into the bootloader. You can also use the following adb command:
    Code:
    adb reboot bootloader
    You can also use an app called Quick Boot to boot into the bootloader directly from Android (root required).

    How to boot into recovery:
    Boot into the bootloader (see above), use the volume keys to scroll through the options and use the power button to select the recovery mode option. You can also use the following adb command:
    Code:
    adb reboot recovery
    You can also use an app called Quick Boot to boot into the recovery directly from Android (root required).

    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 Decrypt Your Data Partition
    4. How To Make A Nandroid Backup With TWRP Recovery
    5. How To Make An EFS Backup With TWRP Recovery
    6. How To Root
    7. How To Install A ROM with TWRP Recovery
    8. How To Install A Custom Kernel With TWRP Recovery
    9. How To Update To A New Build Of The Stock ROM
    10. How To Flash The Factory Images (Return To Stock)
    11. How To Flash The Factory Images (Return To Stock But Leaving Internal Storage Intact)
    FAQ can be found in post #2!

    z7e6jQa.jpg

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

    • Go into Settings/About Phone, scroll down and click on ?build number? continuously until you see a toast notification telling you that you've enabled Developer Options. Go back to your Settings menu and enter Developer Options, scroll down and click on the ?Enable OEM Unlock? checkbox, also make sure you enable USB Debugging while you're in the Developer Options menu.
    • Power off your phone then boot into the bootloader (power + volume down).
    • 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
      This will erase all user data from the device!
    • You should now see a screen on your phone asking you to confirm this action, use the volume keys to scroll and the power key to confirm if you're sure you want to go ahead.
    • Allow the process to complete and then issue this command:

      Code:
      fastboot reboot
    • Allow everything to go ahead and once finished you can disconnect your usb cable.

    Important: do not relock your bootloader unless your phone is fully stock. You must flash the factory images first in order to remove root and custom recovery (if you have them), if this precaution isn't taken you may end up with a brick. Please see section 10 of this guide for full instructions on how to return to stock.

    z7e6jQa.jpg

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

    Prerequisites: unlocked bootloader (section 1). Please read FAQ #7 if using TWRP 3.0.2-1 or 3.0.2-2.

    • Download TWRP Recovery onto your PC.
    • Make sure you check the md5 to verify its integrity (where possible).
    • Place the file in your fastboot folder (this is where fastboot.exe is located on your PC).
    • Power off your phone then boot into the bootloader (power + volume down).
    • 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), enter this command:

      Code:
      fastboot flash recovery filename.img

      (The recovery filename in the command will change depending on which recovery you're flashing)
    • Use the volume keys to scroll and power key to select the Reboot Bootloader option. Once the phone has booted back into the bootloader, use the volume keys to scroll and the power key to boot into your newly flashed recovery. It's now safe to disconnect your usb cable. If using Nougat 7.0 or newer, you must now boot directly into TWRP and flash SuperSU (or your preferred root alternative) so that TWRP will persist between reboots.
    When TWRP boots up you'll be asked whether you want to allow system modifications or to keep it read-only, choose to allow system modifications, there's no benefit to keeping it read-only.

    Do not flash the version of SuperSU that TWRP offers to flash for you in order to give you root, it is not compatible and will cause problems. When you attempt to reboot out of TWRP it will tell you that it's detecting that you don't have root and it will offer to root for you, skip past this.


    Some users need a custom recovery for a temporary period, so they live boot the recovery. In this scenario, the custom recovery replaces the stock recovery until a reboot is performed. Place the file in your fastboot folder then enter this command:

    Code:
    fastboot boot filename.img

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

    z7e6jQa.jpg

    [SIZE=+1]3. How To Decrypt Your Data Partition[/SIZE]

    This is no longer necessary as long as you use TWRP 2.8.7.1 or newer

    Prerequisites: unlocked bootloader (section 1).

    TWRP recovery cannot decrypt your data partition at this stage. In order for TWRP to be able to read/write on your data partition (to root or create a nandroid backup) you will need to format it, a format will remove encryption.

    • Boot into the bootloader and 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), enter this command:
      Code:
      fastboot format userdata
      Please note: this will erase all user data from the device!
    • Once the process has completed you can either reboot normally:
      Code:
      fastboot reboot
      Or you can reboot back to the bootloader in order to undertake another task:
      Code:
      fastboot reboot-bootloader

    z7e6jQa.jpg

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

    Prerequisites: unlocked bootloader (section 1), TWRP recovery (section 2).

    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.

    Boot 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]5. How To Make An EFS Backup With TWRP Recovery[/SIZE]

    An EFS backup is very important to have, if your EFS partition becomes corrupt you will have no IMEI, and therefore will not be able to use the phone as a phone. Making an EFS backup is insurance against this catastrophic event. Without a backup, restoring your EFS can be extremely difficult or impossible. The backup you create can be easily restored using the restore tool in TWRP recovery.

    Please read FAQ #7 if using TWRP 3.0.2-1 or 3.0.2-2. Boot into TWRP and select the backup option from the TWRP home screen, make sure only the EFS box is selected, and swipe to backup. The process will take a few seconds. Keep a copy of the backup on your phone and also keep another copy somewhere safe.

    z7e6jQa.jpg

    [SIZE=+1]6. How To Root[/SIZE]

    Prerequisites: unlocked bootloader (section 1), TWRP recovery (section 2).

    • Download the latest root method of your choosing to your phone:
      Magisk
      SuperSU Stable
      SuperSU Service Release (SuperSU beta channel)
      Or to root Android Nougat 7.0 visit this thread: Use SuperSU 2.78 or newer.
      [WIP] Android N Preview
    • Boot into TWRP recovery and enter the install menu.
    • Navigate to where you have SuperSU stored on your internal storage 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.
    Do not flash the version of SuperSU that TWRP offers to flash for you in order to give you root, it is not compatible and will cause problems. When you attempt to reboot out of TWRP it will tell you that it's detecting that you don't have root and it will offer to root for you, skip past this. You do have root, ignore this every time it comes up.

    z7e6jQa.jpg

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

    Prerequisites: unlocked bootloader (section 1), TWRP recovery (section 2), vendor.img (section 9).

    Installing a ROM is a straight forward and easy process. Before you install anything you should make a nandroid backup (instructions above). Next, install the vendor.img that matches the Google security OTA that the ROM you want to install is based on. Find the vendor.img inside the factory images provided by Google then flash this file with fastboot (section 9).

    • Download a ROM and appropriate Gapps package and place on your device.
    • Boot into your custom recovery.
      • Select the wipe option from the TWRP home screen.
      • Perform a Factory Reset.
      • 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]8. How To Install A Custom Kernel With TWRP Recovery[/SIZE]

    Prerequisites: unlocked bootloader (section 1), TWRP recovery (section 2).

    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 Kernel Auditor, EX Kernel Manager, Trickster Mod, No Frills, Kernel Tuner, and many more.

    z7e6jQa.jpg

    [SIZE=+1]9. How To Update To A New Build Of The Stock ROM[/SIZE]

    Prerequisites: unlocked bootloader (section 1).

    This method does not wipe your data, so you will keep your apps and settings. You should have no problems, however, if you experience problems you may need to perform a factory reset and flash again. Make a backup first and transfer it to your PC.

    • Download the latest build via the appropriate factory images for your model (Nexus 5X/Bullhead) here.

      Note: Android 7.1.2 and newer factory images do not contain cache.img. Do not wipe the cache.img for this process when using or moving to Android 7.1.2 or newer. If you have wiped cache.img, download the most recent Android 7.1.1 factory image and flash the cache.img from that zip archive.

    • Unzip the bullhead-xxxxxx-factory-xxxxxxxx (x's replace variables) into a directory on your PC (for this guide we'll use C:\bullhead\).
    • Once unzipped you should have a folder named bullhead-xxxxxx (x's replace variables). Open it and move the following files to a new directory named C:\bullhead\images\:
      • bootloader-bullhead-bullhead-xx.xx.img
      • radio-bullhead-bullhead-xx.xx.img
      (Please note that radio and bootloader naming changes from build to build so the filenames and below commands will change with them)
    • Within C:\bullhead\bullhead-xxxxxx\ you'll see another zip archive named image-bullhead-xxxxxx, unzip the contents of that zip into the C:\bullhead\images\ folder we created before. Now within C:\bullhead\images\ you should have the following files:
      • android-info.txt
      • boot.img
      • bootloader-bullhead-bullhead-xx.xx.img
      • cache.img
      • radio-bullhead-bullhead-xx.xx.img
      • recovery.img
      • system.img
      • userdata.img
      • vendor.img
    • Boot into the bootloader and 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), enter these commands to flash:
      Code:
      fastboot flash bootloader C:\bullhead\images\bootloader-bullhead-bullhead-xx.xx.img
      fastboot reboot-bootloader
      fastboot flash radio C:\bullhead\images\radio-bullhead-bullhead-xx.xx.img
      fastboot reboot-bootloader
      fastboot flash boot C:\bullhead\images\boot.img
      fastboot erase cache
      fastboot flash cache C:\bullhead\images\cache.img
      fastboot flash recovery C:\bullhead\images\recovery.img
      fastboot flash system C:\bullhead\images\system.img
      fastboot flash vendor C:\bullhead\images\vendor.img

      You can skip flashing the recovery if you wish, but even if you do the stock recovery may be patched on the first boot anyway. So you'll need to flash TWRP and SuperSU again if you need/want those, as well as any other system modifications you may have had.
    • You'll have to flash SuperSU again now, plus add any mods that you previously had.

    z7e6jQa.jpg

    [SIZE=+1]10. How To Flash The Factory Images (And Return To Stock)[/SIZE]

    Prerequisites: unlocked bootloader (section 1).

    This section will explain how to return the phone to be like it was when it came out of the box. This will wipe everything from the phone. If you wish to flash the factory images without wiping your personal data from the internal storage please move on to the next section.

    Note: Android 7.1.2 and newer factory images do not contain cache.img. Do not wipe the cache.img for this process when using or moving to Android 7.1.2 or newer. If you have wiped cache.img, download the most recent Android 7.1.1 factory image and flash the cache.img from that zip archive.


    • Go to Settings/Backup & Reset and perform a factory data reset. This will remove all of your user data from the device (apps, settings, photos, music, etc).
    • Download the appropriate factory images for your model here.
    • Unzip the bullhead-xxxxxx-factory-xxxxxxxx (x's replace variables) into a directory on your PC (for this guide we'll use C:\bullhead\).
    • Once unzipped you should have a folder named bullhead-xxxxxx (x's replace variables). Open it and move the following files to a new directory named C:\bullhead\images\:
      • bootloader-bullhead-bullhead-xx.xx.img
      • radio-bullhead-bullhead-xx.xx.img
      (Please note that radio and bootloader naming changes from build to build so the filenames and below commands will change with them)
    • Within C:\bullhead\bullhead-xxxxxx\ you'll see another zip archive named image-bullhead-xxxxxx, unzip the contents of that zip into the C:\bullhead\images\ folder we created before. Now within C:\bullhead\images\ you should have the following files:
      • android-info.txt
      • boot.img
      • bootloader-bullhead-bullhead-xx.xx.img
      • cache.img
      • radio-bullhead-bullhead-xx.xx.img
      • recovery.img
      • system.img
      • userdata.img
      • vendor.img
    • Boot into the bootloader and 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), enter these commands to flash:
      Code:
      fastboot flash bootloader C:\bullhead\images\bootloader-bullhead-bullhead-xx.xx.img
      fastboot reboot-bootloader
      fastboot flash radio C:\bullhead\images\radio-bullhead-bullhead-xx.xx.img
      fastboot reboot-bootloader
      fastboot flash boot C:\bullhead\images\boot.img
      fastboot erase cache
      fastboot flash cache C:\bullhead\images\cache.img
      fastboot flash recovery C:\bullhead\images\recovery.img
      fastboot flash system C:\bullhead\images\system.img
      fastboot flash vendor C:\bullhead\images\vendor.img

      If you wish to you can also relock the bootloader with this command:
      Code:
      fastboot oem lock
      (This command will wipe all user data from the device)

      Important: do not lock the bootloader unless you have first flashed the stock images. Locking the bootloader while you have a custom recovery installed can result in a brick. Please also note that the locking procedure will wipe all data on an encrypted device.

      Once all commands/flashes are complete you can reboot the device:
      Code:
      fastboot reboot

    z7e6jQa.jpg

    [SIZE=+1]11. How To Flash The Factory Images (Return To Stock But Leaving Internal Storage Intact)[/SIZE]

    Prerequisites: unlocked bootloader (section 1), TWRP recovery (section 2). Note: Android 7.1.2 and newer factory images do not contain cache.img. Do not wipe the cache.img for this process when using or moving to Android 7.1.2 or newer. If you have wiped cache.img, download the most recent Android 7.1.1 factory image and flash the cache.img from that zip archive.

    This section will explain how to return the phone to be like it was when it came out of the box, except it will not wipe any of your personal data (photos, music, etc) from the internal storage.


    • Download the appropriate factory images for your model here.
    • Unzip the bullhead-xxxxxx-factory-xxxxxxxx (x's replace variables) into a directory on your PC (for this guide we'll use C:\bullhead\).
    • Once unzipped you should have a folder named bullhead-xxxxxx (x's replace variables). Open it and move the following files to a new directory named C:\bullhead\images\:
      • bootloader-bullhead-bullhead-xx.xx.img
      • radio-bullhead-bullhead-xx.xx.img
      (Please note that radio and bootloader naming changes from build to build so the filenames and below commands will change with them)
    • Within C:\bullhead\bullhead-xxxxxx\ you'll see another zip archive named image-bullhead-xxxxxx, unzip the contents of that zip into the C:\bullhead\images\ folder we created before. Now within C:\bullhead\images\ you should have the following files:
      • android-info.txt
      • boot.img
      • bootloader-bullhead-bullhead-xx.xx.img
      • cache.img
      • radio-bullhead-bullhead-xx.xx.img
      • recovery.img
      • system.img
      • userdata.img
      • vendor.img
    • Boot into TWRP recovery and enter the wipe menu, select advanced wipe, check only the data box and swipe to wipe.
    • Go to the TWRP main menu and enter the reboot menu, select bootloader. The phone will now boot into the bootloader, once it has you can 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), enter these commands to flash:
      Code:
      fastboot flash bootloader C:\bullhead\images\bootloader-bullhead-bullhead-xx.xx.img
      fastboot reboot-bootloader
      fastboot flash radio C:\bullhead\images\radio-bullhead-bullhead-xx.xx.img
      fastboot reboot-bootloader
      fastboot flash boot C:\bullhead\images\boot.img
      fastboot erase cache
      fastboot flash cache C:\bullhead\images\cache.img
      fastboot flash recovery C:\bullhead\images\recovery.img
      fastboot flash system C:\bullhead\images\system.img
      fastboot flash vendor C:\bullhead\images\vendor.img
      Once all commands/flashes are complete you can reboot the device:
      Code:
      fastboot reboot

    z7e6jQa.jpg
    FAQ can be found in post #2!

    aDlDoZJ.jpg

    Donate To Me
    45
    [size=+1]Frequently Asked Questions[/size]

    1. How do I boot into the bootloader?

    Power off your device. Once it's powered off hold power + volume down and the phone will boot into the bootloader. You can also use the following adb command:
    Code:
    adb reboot bootloader
    You can also use an app called Quick Boot to boot into the bootloader directly from Android (root required).

    2. How do I boot into recovery?

    Boot into the bootloader (see above), use the volume keys to scroll through the options and use the power button to select the recovery mode option. You can also use the following adb command:
    Code:
    adb reboot recovery
    You can also use an app called Quick Boot to boot into the recovery directly from Android (root required).

    3. When issuing the fastboot flashing unlock command it doesn't work, I only get a list of possible commands. What's going on?

    This is usually due to having an outdated adb/fastboot setup. If you installed adb/fastboot by any means other than via the Android SDK this is probably the cause. Visit the prerequisites section in the beginning of this guide to properly install adb/fastboot and ensure that it's up to date.

    4. How do I take an OTA or update if I have root or other system modifications on the stock ROM?

    You can't take an OTA update while you have root or any system modifications. You'd need to use fastboot to flash the system, boot, and recovery images. It's much easier to just flash the newer build with fastboot, see section 9 of this guide for full instructions.

    5. Does taking an OTA update wipe my user data?

    No, it doesn't.

    6. Do I need to make an EFS backup?

    Absolutely yes. An EFS backup is extremely important. If your EFS partition becomes corrupt, your IMEI will disappear and you will not be able to use the phone as a phone. Without a backup it can be extremely difficult (or impossible) to restore your EFS. See the next question for an EFS backup related issue and solution.

    7. I have a bootloop after restoring my EFS backup in TWRP 3.0.2-1. What can I do?

    TWRP 3.0.2-1 and 3.0.2-2 are the first official TWRP releases with Nougat 7.0 or newer compatibility. Unfortunately, there are separate bugs affecting TWRP 3.0.2-1 and 3.0.2-2. A member of the TWRP development team details these issues right here. This link redirects to a thread in the Nexus 6P forums but also applies to the Nexus 5X. Read the original post of that same thread to learn how to resolve this EFS restore bootloop. You must use ADB and the phone must be booted in TWRP to resolve this issue. These ADB commands work on the Nexus 5X and 6P.

    8. Can I flash just the xxxxxx.img from the factory image without losing my data?

    Flashing userdata.img will format your entire phone (personal data including SMS/MMS, pictures, downloaded files, etc). You can flash any combination of these partitions (boot, system, vendor, radio, or bootloader) and this will leave your personal data intact. However, any mods that you have installed into system, vendor, or boot will be overwritten and returned to the default factory image setup when you flash these partitions. Flashing recovery.img or a newer version of your custom recovery will replace your existing recovery.

    9. After updating my ROM, I get this message on every boot: "There's an internal problem with your device. Contact your manufacturer."

    This warning indicates a mismatched vendor and system partition. The vendor partition was formerly integrated in the system partition for previous Nexus devices but is now a separate partition that must be flashed for each Google security update. Download a factory image and update your vendor partition using fastboot so that it matches your rom's OS build and monthly security update. If you have a file explorer installed on your phone, you can determine which vendor.img is installed by navigating to /vendor/build.prop and clicking on the build.prop. The specific vendor installed will be a combination of six numbers and letters listed in all capitals (example: NMF26F) in the ro.vendor.build.fingerprint line. These will always match up with the factory image of the same Android build (six digit alphanumeric name) for this device.

    Vendor.img is specific to each OTA and contains proprietary binaries for the phone that regularly receive updates to resolve security risks. If you are a custom rom user, make sure that you flash the vendor.img for the Google monthly security update that you are moving to. Be aware that sometimes AOSP roms utilize the AOSP master branch which has a newer Android build than the monthly security update for this device. You will still need to install that month's vendor.img.

    The phone will fail to boot if you mismatch the vendor.img with a different Android version. For instance, a 6.0 Marshmallow vendor.img will not allow your phone to boot on 7.0 Nougat. The vendor.img is typically not included in the custom rom zip but is often available as a separate download in the custom rom thread's first post.
    20
    Here is the modified boot image for MMB29K
    bullhead-mmb29k-mboot.zip (tested working)

    The boot image has the following modifications per Chainfires instructions, just like the modified mdb08i boot image:
    - patched sepolicy
    - disabled dmverity
    - disabled forceencrypt

    This is for system root.
    10
    Here are modified boot images for MDB08L & MDB08M & MMB29K
    bullhead-mdb08l-mboot.zip (tested working)
    bullhead-mdb08m-mboot.zip (tested working)
    bullhead-mmb29k-mboot.zip (tested working)

    These boot images have the following modifications per Chainfires instructions, just like the modified mdb08i boot image:
    - patched sepolicy
    - disabled dmverity
    - disabled forceencrypt
    7
    Updated 2015/12/23!

    Updated:


    I've edited the guide to include separate sections for systemless root and traditional root. I'll also be adding some extra information for updating and flashing the factory images soon. If I've missed any of the posts by @reddv1 that contain modified boot.img's please let me know and I'll add them to the traditional root section.

    EDIT: Extra sections for updating and flashing factory images have been added, plus a section on creating an EFS backup. I've also added an FAQ in the second post.