yashsingh1/xdaforums huggingface dataset:
[Nexus 5X General] aiah:
I have a few questions

1) can you give me a step by step description on how to create a modified boot.img for myself ?

I know how extract and rebuild a boot.img but my modified boot.img doesn't seem to boot.

2) how did you modify the sepolicy

The sepolicy in stock mdb08i is identical to the sepolicy in stock mdb08m but your modified sepolicy for mdb08m is different to the chainware-mdb08i version

Also many thanks for supplying modified boot image.
[Nexus 5X General] jadesocket:
Thank you for the response.

So if I wanted to revert back to receive ota updates, I have to flash a factory image and relock my phone?
[Nexus 5X General] Cheesejam:
Immediately after flashing the modified boot image, my phone rebooted (it didn't' stay in fastboot)--I had no control over it. You know when you phone boots up after unlocking the bootloader and there is the orange/yellow text warning that your phone can't be checked for corruption? A similar message popped up at the beginning of this reboot, but it was red and it said my phone corrupt or something like that. The phone then booted up, asked me for my device password (I put in my PIN for my lockscreen, not sure if that's what it wanted), then said I had to factory reset my phone with a "reset" button to click. Once clicked, the phone factory reset, with MDB08M, unlocked booatloader, and custom recovery still present. After this, I tried flashing your modified MDB08M boot again, and the same thing happened.

I am not really sure what went wrong here in this chain of events. Flashing the MDB08I modified boot did the trick for me to achieve root though.
[Nexus 5X General] blinkin:
So basically the instructions in the first post on "3. How To Decrypt Your Data Partition" are not complete? :)
[Nexus 5X General] reddv1:
Yes, they are incomplete. If you formate userdata, it decrypts your phone, but if you reboot the phone with stock boot.img still installed your phone will re-encrypt during the boot animation.
[Nexus 5X General] reddv1:
1. After extracting boot.img, connect your phone to the computer, enable adb from developer options, type in the adb commands provided by Chainfire to patch sepolicy. After that delete the original sepolicy in the ramdisk and replace it with sepolicy_out that was created, obviously rename sepolicy_out to sepolicy. Next, you have to disable verity and forced encryption by editing the file, fstab.bullhead in the ramdisk. delete the lines in red to disable verity, and replace "forceencrypt" in blue with "encryptable" to disable forced encryption.

/dev/block/platform/soc.0/f9824900.sdhci/by-name/system /system ext4 ro,barrier=1 wait[COLOR="Red"],verify=/dev/block/platform/soc.0/f9824900.sdhci/by-name/metadata[/COLOR]
/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor /vendor ext4 ro,barrier=1 wait[COLOR="Red"],verify=/dev/block/platform/soc.0/f9824900.sdhci/by-name/metadata[/COLOR]
/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,data=ordered,nomblk_io_submit,noauto_da_alloc,errors=panic wait,check,[COLOR="Blue"]forceencrypt[/COLOR]=/dev/block/platform/soc.0/f9824900.sdhci/by-name/metadata

Finally, delete the file "verity_key" from the ramdisk as that file is no longer necessary becasue verity is disabled.

Repack the boot.img, and you are done.

One important note about repacking boot.img post Marshmallow update; repacking marshmallow boot.img using the same method before Marshmalllow somehow changes the permissions of the ramdisk and will cause the boot.img to fail to boot. I used AIK-1.9.1, Android Image Kitchen, to unpack and repack the boot.img becasue I had problems with other programs. Make sure to use the 1.9.1 version which addressed the Marshmallow ramdisk bug.

2. I don't know why they are different, I just used his instructions to patch sepolicy in MDB08M & MDB08L.

---------- Post added at 05:12 PM ---------- Previous post was at 04:41 PM ----------

Never heard of fastboot rebooting automatically into system after flashing a boot image or any other image. Fastboot boots into the system automatically if you issue a "fastboot boot boot.img" instead of "fastboot flash boot boot.img". Maybe you forgot to put "flash" in the command. Fastboot boot command is for booting an image once, for one boot cycle.

I had the the red triangle warning screen saying the phone is corrupt after mistakenly flashing the stock image instead of the modified boot image when I was testing the boot images. I was already decrypted so boot time took a long time, because the phone was re-encrypting. I didn't let the system finish booting up completely because I realized I flashed the wrong boot image, and just forced rebooted the phone into fastboot mode.
[Nexus 5X General] efrant:
Yes, flash a factory image (except userdata.img), but no need to re-lock the bootloader.
[Nexus 5X General] ljfnky:
ADB side-load is that using TWRP> advanced> side-load can "O" be instaled that way?
[Nexus 5X General] ulxerker:
if you update from an older version and you're using the correct full OTA image for your device, then yes.

when in sideload mode in twrp, you have to issue "adb sideload OTAxxx.zip" in a PC's command shell while connected to the phone.
[Nexus 5X General] -Asskicker-:
Following step 9 I updated to the latest version (7.1.2). However like other people in the thread pointed out the cache.img is missing from the latest images.

I proceeded to download an older version (7.1.1) and get the cache.img from there and just flashed that. That seems to have worked (device boots), will it work alright like this or is it recommended to go back to 7.1.1 completely and then use the OTA to update?

Thanks,

AK
[Nexus 5X General] ulxerker:
It'll work like this, so you're good.
[Nexus 5X General] pmacevad:
sorry to clutter the thread, i just dont know where else to ask. Im having trouble with my cpu recognizing my device when booted into bootloader. The device is recognized by adb when booted into system but when i issue the command fastboot devices while booted into the bootloader the device is not recognized. I did just update my adb drivers as they were outdated and that got adb working for me while booted but i cant figure out why the device is not being recognized while in bootloader. This is preventing me from issuing the command to flash twrp via fastboot. Any help appreciated. its been a while since i rooted and im a little rusty. is there another way to flash twrp without using a pc without root if this continues to be a problem?
[Nexus 5X General] zurik:
cache[.]img does not required now.
[Nexus 5X General] SlimSnoopOS:
This isn't clutter. Questions like this belong here :) Have you updated your platform tools as well ADB? I don't use Windows, but uninstall the driver that is currently installed while the phone is in the bootloader and connected to the computer. There should be an exclamation mark on it being that you are having connection issues.
[Nexus 5X General] pmacevad:
I got it figured out. Ended up setting up a new environment on another PC. Thanks for the response.
[Nexus 5X General] SlimSnoopOS:
Nice, happy flashing!
[Nexus 5X General] ensboarder:
Is it possible to unlock/root a Nexus 5x running stock Android 7.1.2 ?
[Nexus 5X General] SlimSnoopOS:
Yes. Follow the instructions in my first post.
[Nexus 5X General] pmacevad:
Just did it last night. Easy of you follow the directions.
[Nexus 5X General] :
does it always work with new windows powershell?
[Nexus 5X General] Komodoketavaran:
It works. Use ".\adb devices" instead of "adb devices" for example.

Gesendet von meinem Nexus 5X mit Tapatalk
[Nexus 5X General] :
You again to rescue me thanks a lot ? but as I saw your message too late I found an alternative I downloaded stock rom and in this zip there is a flash all.bat and it worked but now I will know how to do.

But it's really stupid from Microsoft devs to change a thing that users where using since long time with no issues.

?
[Nexus 5X General] Ted_dy2839:
After I did root or flash a rom (lineage os), the device stuck on the startup screen forever... You know, those 4 balls turns around again and again on the screen... It takes me several hours to wait... But I can always restore back to original system. Do you know is there anything wrong with my root? Or should I just wait more hours?
[Nexus 5X General] ulxerker:
nope, normally it should work ... please ask in the LineageOS thread for assistance, thanks.
[Nexus 5X General] luisbraz:
Thanks for the excellent guide!

I've been using NRT to update and root my phone, but since it's not being updated for 2 months, I must do it manually. Let's pray! :)
[Nexus 5X General] SlimSnoopOS:
You're welcome. Make sure you do not format cache partition if moving up to 7.1.2. Google has stopped including this image in the Nougat 7.1.2 factory images. I'll be adding this into the OP soon now that things have calmed down in my personal life.
[Nexus 5X General] luisbraz:
Thanks for the warning! I've read that some posts ago!

I have TWRP. Can I pass the stock recovery flash and after flash all the stuff, reboot directly to recovery (TWRP) and root the device? Thanks.
[Nexus 5X General] SlimSnoopOS:
Yup! That's what I do when I'm on stock.
[Nexus 5X General] luisbraz:
Done! Updated and rooted at the same time! Thanks for the excellent guide.
[Nexus 5X General] Popoto_:
Hi all!

I flashed a new rom (Dirty Unicorns) using the methods from this post and some mistakes were made.

I wiped cache, and my 5x stuck on google logo. I flashed the cache.img and everything runs ok.

But...my sensors are not working :( (except the fingerprint sensor). I searched and found that if i flash vendor.img, everything should be fine, but, nothing changed :(

Below are prints off cpu-z showing my sensors without data and the command i run while on bootloader.

https://drive.google.com/file/d/0B1pWfEOl_3e9cklwLW02RDBiMjg/view?usp=sharing

https://drive.google.com/file/d/0B1pWfEOl_3e9ejdMdzcwZ08xa0k/view?usp=sharing

https://drive.google.com/file/d/0B1pWfEOl_3e9UDQ4UGlUTm1Vd0E/view?usp=sharing

I don't know what to do, i can't even rotate my screen :(

Can someone help me with this issue?
[Nexus 5X General] SlimSnoopOS:
Hi,

If you're coming from Android O, I've seen folks mention that they have to wipe their entire phone (including internal storage) for their sensors to begin working again.

If not coming from Android O, do a factory reset in TWRP, wipe system, then run the May 7.1.2 factory image. See if your sensors have returned to normal.
[Nexus 5X General] Popoto_:
Ya, i came from android O :sad:, so, wiping EVERYTHING (cache too?) and flashing EVERYTHING again should work?

I'll try that later, thanks for pointing me out!
[Nexus 5X General] SlimSnoopOS:
Yea, before Android O, my recommendation is a factory reset and to install the 7.1.2 vendor.img. If that doesn't reset your sensors, then you'll have to wipe everything including internal storage. Sounds like a headache but it may be the only resolution. I'm not sure about wiping cache too but if you do, have the 7.1.1 cache.img readily available if the phone doesn't boot. 7.1.2 factory images do not contain this image anymore.
[Nexus 5X General] Popoto_:
I wiped everything and installed stock 7.1.2, sensors not working yet...then i factory reset the stock and sensors are working!!! (weird)

After all of that, i flashed Dirty Unicorns and everything are ok till now
[Nexus 5X General] xankg:
Can someone walk me through installing the USB drivers? Tried everything, the instructions on installing the USB driver isn't working, I can't find my device under "Portable devices" no matter what USB-mode i choose, both with USB-debugging on or off. I get the device under "Universal Serial Bus controllers but can't update the drivers, Windows just tells it already got the latest driver installed. Update: switched USB-ports to the ones on my motherboard directly and now it showed up on under portable devices but still can't install the drivers, it says the latest MTP-driver is already installed, what do I do?
[Nexus 5X General] CLPose:
I don't know if the I have the best answer, but I solved the problem with Nexus Root Toolkit. It has a dedicated part for installing the correct drivers. I don't want to stuff this thread with this, so please Google for Nexus Root Toolkit in XDA. Good luck!
[Nexus 5X General] xankg:
Thanks for the tip but this didn't work for me, now I can't find my Nexus 5X at all under portable devices.
[Nexus 5X General] luisbraz:
Search for my post in nexus root Toolkit thread, some months ago. I've installed the drivers selecting the manual installation, and you have to let windows install unassigned drivers!
[Nexus 5X General] CLPose:
Yup! +1!
[Nexus 5X General] antrea:
Hi

I have a nexus 5x with:

Image: 7.1.2 (N2G47O, May 2017)

Bootloader version: BHZ11m

But I can't unlock the bootlader... I have enabled the debug mode, OEM unlocking enabled... but if i wrote fastboot flashing unlock/fastboot oem unlock it will unlock the bootloader, after the rebooting it will re-lock the bootloader.... how i should unlock it permanent!?

regards
[Nexus 5X General] SlimSnoopOS:
Hi there,

Your mainboard was replaced and has "no rpmb" displayed in the bootloader. There is a workaround but you will not be truly bootloader unlocked. I'd suggest replacing the device again. If you can't, follow the workaround below:

https://www.reddit.com/r/nexus5x/comments/5hj0r0/bootloop_after_lg_replaced_mainboard_bootloader/
[Nexus 5X General] antrea:
Yep.... but I don't think that LG will change (freely) my board again without the booloader unlock issue...
[Nexus 5X General] SlimSnoopOS:
Won't hurt to try. Also, see if you can sign into any DRM based properties like Netflix, Hulu, Google Play Music. If those don't work then it's possible the no rpmb status is affecting your ability to use the phone. Someone asked about it late in this thread.
[Nexus 5X General] joschae:
Need Some Help!!!

Deleted.. moved to PureNexus thread.
[Nexus 5X General] z0ned:
Just a heads up for people flashing to 7.1.2 stock (June): I had to grab and flash both cache.img and userdata.img partitions from the 7.1.1 stock (April) fileset as these are both absent from the 7.1.2 stock fileset as packaged. Until I did userdata.img I was getting component crash loops on first boot (System UI and com.android.phone keeps crashing). This was for me coming from a December 2016 CM 14.1 ROM anyway. It was a mildly stressful (it took me a few runs through flashing both April and June to figure it out) detour I hope I can help others to avoid. Pretty sure OP is getting ready to update the top post with some bit of instructions about these in any case, but be aware.
[Nexus 5X General] ruben.vreeken:
Slightly n00b question about oem locking

Hey all,

I have a question regarding locking my phone after putting another ROM on it.

In the beginning of this thread, there's a warning that locking your phone when it is not in a factory setup can brick your phone. I have tried several OS's on my phone and would like some verification if it may be safe for me to lock my phone again.

Here's the steps I've taken since receiving my phone and messing around with it:

Updated the factory-installed android version (Android 7.1.2 May 2017)

Unlocked the bootloader

Installed TWRP

Made a full back-up of everything on my phone (all partitions)

Attempted to install KDE Plasma Mobile (got stuck in boot-loop)

Restored the full TWRP backup

Downgraded from Android 7 to android 6, using google's factory image and the flash-all.sh script that comes with the image.

Attempted to install KDE Plasma Mobile Again (worked this time, but turned out to be highly unstable)

Restored the full TWRP backup

Installed android 7.1.2 Jun 2017 release, using google's factory image and the flash-all.sh scrip that comes with it.

Installed Copperhead OS, latest build downloaded from their site, installed using the flash-all.sh script that comes with the build.

A few things worry me a little:

The latest Android 7 images do not include a cache.img. I did include the cache partition in my original TWRP backup though, so it should be restored.

The guide at the start of this thread uses a list of fastboot commands to restore a factory image. I used the bundled flash-all.sh script instead.

Recovery mode in the bootloader showed the "no command" error.

Should I be worried about the "no command" error? If so, what should I do to resolve this?

Does any of the above indicate I would likely brick my phone if I tell fastboot to 'oem lock' my phone?

Sorry for the long message, I have tried to be thourough. Thanks in advance for anyone taking the time to help me.
[Nexus 5X General] fvisagie:
Correct. The alternative as mentioned in the thread recently is to use the cache partition from the most recent factory image that has one (I forget which version exactly).

The main difference is that flash-all.sh always clears your user data. The manual fastboot commands aim to avoid that.

That's normal for stock recovery. You can invoke it by pressing Power and at the same time Volume Up or Down (I only know which when I do it ;)).

Stock = stock. So you'd have to undo your most recent customisation (Copperhead).
[Nexus 5X General] ishtiyaaak:
I am a total noob

I am on 7.1.2 (june) patch and i have not rooted the phone before, can anyone explain me step to step unlock rooting and recovery ? plzzz with the easiest way possible
[Nexus 5X General] SlimSnoopOS:
Read my guide once. Think about what does or does not make sense. Then read my guide a second and third time. Then ask questions about what doesn't make sense if you feel uncomfortable about proceeding.
[Nexus 5X General] gagrot9211:
I'm having a problem

My status- Unlocked bootloader, twrp accessible, devices not getting detected in fastboot/ bootloader mode by the pc, rooted, restoring using the backup results in a bootloop, correct drivers installed on the pc, superSU and full backup in the mobile.

i cant transfer files since device not getting detected.

my timeline- i followed every instruction on https://xdaforums.com/nex...nners-t3206930 and everything went successful, but when it rebooted to the 'Welcome' page (the page which comes when u open mobile for the first time) i restarted my nexus 5x 32gb to recovery mode and then the every boot procedure after that doesn't complete for several minutes(doesn't go ahead the ball animation)

versions of the apps- android 7.1.2 may security update, twrp 3.1.1,
[Nexus 5X General] CLPose:
I'm sorry if I'm meddle in this, but I agree that you should read and re-read OP steps more than one. ;) Anyway, I think there should be a note or something about the "cache.img" not present in latest factory images, just in case someone makes this wipe :eek: (I can't find that reference in the OP). I'm just trying to help, but feel free to correct me if I'm wrong. Thanks!
[Nexus 5X General] SlimSnoopOS:
Try deleting the drivers, rebooting, then installing the drivers again.

Done!
[Nexus 5X General] gagrot9211:
update- the mobile is seen as android in 'devices and printer' though(not in device manager)

drivers updated. devices now visible under 'fastboot devices' but not visible in 'my computer'. now what to do?
[Nexus 5X General] CLPose:
To go back to the basics, if all drivers are correctly installed, you can see your device in these cases:

adb devices (from Windows CMD)

fastboot devices (from Windows CMD)

In "My computer" after enabling "MTP" in your device.

Once again, follow the OP steps and you'll be just fine!

Good luck! :fingers-crossed:
[Nexus 5X General] gagrot9211:
like redo the whole rooting process from the initial command - 'fastboot oem unlock'?
[Nexus 5X General] SlimSnoopOS:
1) Run fastboot format userdata (this wipes your entire phone).

2) Flash the June 7.1.2 factory image.

3) Also, download the latest 7.1.1 factory image. Now install just the cache.img from there.

4) Try booting up.
[Nexus 5X General] CLPose:
I'll answer here (not through private messenger) because this piece of information may be helpful for others and because I may be wrong in my guessing. Taking into account what you mentioned in the PM you sent me, your phone was fine until the initial setup wizard (unlocked bootloader, TWRP and rooted). As you couldn't see your device in your PC (I guess just because you didn't enable MTP from the status bar), you restarted your device and you went into bootloop (IDK why, I guess because you didn't complete your initial configuration). If you can fastboot your device, do as [MENTION=3576831]SlimSnoopOS[/MENTION] said. If you can't solve your problem, explain current state of your phone and we'll try to help you. Good luck! :fingers-crossed:
[Nexus 5X General] gagrot9211:
Indirectly you are asking me to follow section 10 of your guide and flash complete 7.1.1?
[Nexus 5X General] SlimSnoopOS:
Yes. I don't use Windows but your device is recognized with "fastboot devices" which is what you need.
[Nexus 5X General] gagrot9211:
worked, thanks
[Nexus 5X General] skttrbrain:
OP is a great guide, but I think the

fastboot erase cache
fastboot flash cache C:\bullhead\images\cache.img

lines should be removed from steps 9, 10 and 11 now, or at least a note should be added that this is no longer necessary, as the past few images have not included a cache.img and so erasing it will create an unbootable device. It is easily fixed by getting a cache.img from an older build and flashing that but it could be avoided in the first place if those lines weren't there.
[Nexus 5X General] SlimSnoopOS:
Happy Tuesday!

Thank you for your heads up but I already added those alerts to each section a few weeks ago.
[Nexus 5X General] Zach1928:
[HELP] I unlocked the bootloader, did a live boot into TWRP and followed the steps- it wouldn't let me decrpyt the data partition, so I hit cancel, clicked agree on the next screen and then I was in the TWRP recovery. I attempted to reboot the phone without making any changes, at which point it just spins away trying to reboot but doesn't (after several minutes). It doesn't appear I can get into the recovery mode or the bootloader either- it just flashes "no command." I can however still get into fastboot. Is there a way to flash the factory image from here? Will the steps in this video get me back to factory?

https://www.youtube.com/watch?v=bqvr5kHwxlw&t=98s
[Nexus 5X General] SlimSnoopOS:
Hey,

I did not watch your video. Power off the phone. Then hold Power and Volume Down until the bootloader menu displays. Now follow section 11. If this does not work, try section 10 which wipes the entire phone.
[Nexus 5X General] Zach1928:
Thanks for the reply,

The video basically just uses the "flash-all" batch file contained within the Nexus factory images from google to restore everything back, which is what I'm trying to do. I do not have TWRP installed (I prefer it to be all back to stock). Will the batch file work essentially the same? I'm trying not to compound the issue, hence the question.
[Nexus 5X General] Zach1928:
I'm getting an error cannot load system.img when following your steps. Am I doing something wrong?
[Nexus 5X General] SlimSnoopOS:
Sounds like you need to update your platform tools
[Nexus 5X General] BenAsly:
Nexus Root Toolkit by Wugfresh is a nice and easy way to do things.
[Nexus 5X General] luisbraz:
But it's not updated for centuries!
[Nexus 5X General] BenAsly:
Yep but it works absolutely fine even for android 7.1.2, just select "any build"! :)

Managed to flash TWRP, to root, to unlock bootloader, even to flash stock. I was on stock 7.1.2 last patch, so officially not supported by NRT. In reality it works flawlessly so don't hesitate to give it a try!