[GUIDE] UnBrick your OnePlus X on a Linux machine

Search This thread

SebiderSushi

Senior Member
Dec 4, 2016
69
36
DISCLAIMER: This guide describes procedures with tools that are designed to write directly to the storage of your device. This has the potential to lead to data loss or bricking your device. If you follow this guide carefully, none of these things should happen. That being said, you are still responsible for your own actions and how you handle the tools mentioned in this guide. Caution is advised.


When do i need this?
The following procedure can be used to get your device back into a booting state if all else fails. Usually you'd want to use this tool to get a working recovery running on your device and then go from there, since apart from flashing ROMs, recoveries like TWRP offer direct access to the internal storage as well.

This tool is usually not needed if:
- The device still boots into recovery and it is possible to access the internal storage through it or flash ROMs. Flashing the official OxgenOS downloaded from OnePlus can fix many issues and the stock recovery is just fine for this purpose.
- The devices bootloader is unlocked. In this case fastboot boot <recovery-image.img> can be used to get into a useful recovery
- The Android ROM still boots and offers root access. This can also be used to flash a useful recovery to the device


Now, if you made sure that you are desperate enough to go on, let's cut to the chase.

You may know the legendary guide by Naman Bhalla about unbricking your OnePlus X: https://forum.xda-developers.com/oneplus-x/general/guide-mega-unbrick-guide-hard-bricked-t3272108
It utilizes the interface that's used in factories to flash the OnePlus X and does not rely on an unlocked bootloader - it allows direct read/write access to the devices flash storage. The original guide requires you to install drivers and run an executable from an unknown source on a windows machine. What if you mistrust this or don't have access to a windows machine?
Well, i know i'm hella late but i was happy to find this so i'm going to share it now:
There is an open source tool to flash your device using Qualcomms EDL mode and it can be used on a Linux machine!

Since the same protocol is used to flash onto the device, the procedure is mostly analogous to the original guide by Naman Bhalla. It simply uses another program on your PC to achieve this.
You'll need to know how to use a terminal, how to open a terminal in a specific directory and how to install missing software in the Linux distribution you are using. It is very likely that you also need root access or sudo on your machine.
Once all that is settled, follow these steps:

  • To download and compile QDL, the open source flashing tool that will be used in this guide, follow the section "Get the Linux flashing tool" from these instructions
  • Download and extract the "UnBrick tool mini" linked in a follow up post by Naman Bhalla and open a terminal in the extracted folder with all the files
  • Before the next steps, make sure that everything is configured correctly. Everything else might flash something you don't want and even has the potential brick and/or overwrite anything in your phone's storage. Apart from that, you might also flash just a recovery instead of the complete package that comes with the download. [1] [2]
  • With your OnePlus X powered off, hold the volume up key, then establish a USB-connection to your PC
    (To make sure the device connected properly, you can check the output of "dmesg". It should print something like "Qualcomm USB modem converter now attached to ttyUSB".)
  • On the terminal in the extracted folder, run the following for the default configuration:
    "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn rawprogram0.xml patch0.xml"
    For a customized configuration, edit "rawprogram0.xml" and save it as "customprogram.xml" for example, then run
    "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn customprogram.xml"
    Be careful about the last two "<program />" elements from "rawprogram0.xml" which flash to the "PrimaryGPT" or "BackupGPT" respectively. If you include them in your "customprogram.xml" you must also flash the "patch0.xml" program like in the unmodified configuration, or your device won't boot, like so:
    "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn customprogram.xml patch0.xml"
    If qdl gets stuck at "waiting for device", try running the command with root privileges, e.g. with "sudo <command>".
    If everything worked, you'll see several lines of output and the tool will report what is flashed etc.
  • Once it's done, QDL will reset power on your device to kick it out of EDL mode. If everything is alright your phone should react to being connected via USB by vibrating and booting into the charging screen. Just before this happens, you can already press and hold the volume down button to boot straight into recovery, or wait and boot your device normally into whatever mode you're up to.

Congratulations on unbricking your device on a Linux machine, enjoy. Also, props to you for still using your OnePlus X after all this time :)


HELP, i've ran qdl and my device does not vibrate or boot or ANYTHING AT ALL!
If this happens, you have likely flashed to the GPT without patching it, either accidentaly because you left the "<program />" tags which flash to "PrimaryGPT" and "BackupGPT" in your "customprogram.xml" without adapting your command line as described or because you followed an older version of this guide which contained a serious error in that regard. Don't fret - it's not that serious, you probably just need to flash the "patch0.xml" program from the UnBrick tool to get your device up and running. It ensures that your GPT is intact again after flashing to it. This is your partition table so it is required to read the bootloader from your devices storage or literally anything else. If it can't be read there's nothing to do any booting with.
To get back your device either run the full default configuration with
"/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn rawprogram0.xml path0.xml"
or remove everything but the two "<program />" elements from "rawprogram0.xml", save it as "gptprogram.xml" and run
"/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn gptprogram.xml patch0.xml"

[1] The UnBrick tool comes with a flashing procedure along with the required files, which, without further modifications to rawprogram0.xml or removal of those files, will flash device drivers and bootloader and the recovery from some OxygenOS 2 OTA update by OnePlus onto your phone. If you have "the new bootloader" installed, [ i.e. you once flashed OxygenOS 3, have any modern (post-Marshmallow) ROM running on your device or TWRP v3.0.2-1 or newer ] then this will soft-brick your device, meaning your ROM won't boot anymore.
By having a look at the rawprogram0.xml file, it's fairly easy to figure out how to tinker with it: You can A remove certain elements to flash only what you want or B replace the files that come with the UnBrick tool by anything you want. Want to flash the files from the OxygenOS 3.1.3 OTA? No problem - just obtain them, place them in the directory and give them the right names and go. Want to flash only a compatible TWRP? Put it in the directory and edit the program xml file accordingly and all is good.
[2] Actual bricking should only occur if you use a program xml file meant for a different device or if you change any of the values that control at which offset the files are going to be flashed. QDL will write anything onto your device to any given storage area as specified in the xml program, independent from partition boundaries and even if it means overwriting something from your data partition or maybe your IMEI and MAC address - Remember that via EDL you can reflash most of the storage back to a working system, but not everything. The original rawprogram0.xml from the UnBrick tool mini only writes to partitions that you are able to reflash to a working condition - as long as you haven't edited it, you should be able to restore to a working condition if something goes wrong.
 
Last edited:
  • Like
Reactions: Kéno40

SebiderSushi

Senior Member
Dec 4, 2016
69
36
I have a new TWRP on my OPX, but I don't really know what to change in the rawprogram0.xml file.

I'm not sure if i correctly understood your situation so i am going to assume the folloing:
- You are running a Linux based operating system on your desktop computer
- You have downloaded all necessary files as mentioned in the guide and successfully compiled qdl
- You want to use modern (newer than 2016) ROMs and the current OnePlus firmware and bootloader, i.e. from OxygenOS 3.1.4
- On your OnePlus X, you have "the old bootloader" installed, that is firmware prior to OxygenOS 3 (based on Marshmallow), i.e. firmware from OxygenOS 2.2.1 or similar
- Additionally, you accidentaly flashed TWRP version 3.0.2-1 or newer to your OnePlus X and rebooted into a soft-bricked state

If these assumptions are correct, i suggest as the easiest solution to reflash a compatible TWRP and update your firmware using that version of TWRP. If you can use your recovery, it is almost always the easiest method to make any remaining modifications in the recovery.

The procedure is as follows:
- From https://dl.twrp.me/onyx/, download TWRP version 3.0.2-0 and 3.3.1-0
- Reflash an old version of TWRP that is compatible, i.e. anything version 3.0.2-0 and below.
Once you flashed TWRP in one way or another, continue with the following steps to update your bootloader:
- Reboot to that version of TWRP to see if you succeeded
- In TWRP, install either one of the following to update your firmware:
- The official OxygenOS 3.1.4 zip downloaded from OnePlus via https://www.oneplus.com/support/softwareupgrade
- Only the firmware by following this guide: https://forum.xda-developers.com/oneplus-x/general/guide-update-bootloader-firmware-to-t347891766
- Copy to your device: twrp-3.3.1-0-onyx.img and the installation zip you chose in the previous step
- Flash the zip in TWRP. Once TWRP is done flashing, immediately flash a version of TWRP 3.0.2-1 or later to recovery
- In TWRP, choose Reboot > Recovery. If your OnePlus X reboots to TWRP, everything went good and you can go on to flash roms and anything else like you're used to. Just note that very old ROMs (like from 2016 and before) will no longer boot on your device, but you can revert your Firmware by flashing the follwing zip: https://forum.xda-developers.com/oneplus-x/general/zip-recovery-flashable-firmware-radio-t3381420
Just remember that immediately after flashing this zip in TWRP, you have to flash TWRP version 3.0.2-0 or older again.


Now, there are some differnt cases that affect how TWRP initially needs to be flashed:
1. Your OnePlus X bootloader is not locked
(tested by running "fastboot oem device-info" on your desktop while your phone is connected in fastboot mode)
If your bootloader is still unlocked you can avoid the hassle of using qdl and simply resort to "fastboot flash recovery <recovery image file>" to fix your device.

2. Your ROM still boots and that ROM is rooted.
In this situation you can still avoid going through the hassle of using qdl.
All you need to do is to get a root shell running. There are several ways to achieve this:
- In a Terminal Emulator on the device run the command "su"
- On a desktop with your phone connected with adb enabled:
- Run either "adb root" and then "adb shell"
- Or run "adb shell" and within that shell, run "su"
Once you got the shell running you can flash your recovery with
"dd of=/dev/block/bootdevice/by-name/recovery if=/sdcard/twrp-3.0.2-0-onyx.img"
To get the image to your device if downloaded on your desktop you can use "adb push twrp-3.0.2-0-onyx.img /sdcard/"

3. Your ROM does not boot or is not rooted.
This is the case where you absolutely need qdl and the situation i assume you are in.
Once you downloaded and unpacked the package from Naman Bhalla, you should see a directory containing the rawprogram0.xml and prog_emmc_firehose_8974.mbn files and a lot of others. You can take just the rawprogram0.xml and the prog_emmc_firehose_8974.mbn file and copy them to your working directory for the next steps.
Now, open rawprogram0.xml in a text editor. Search for the string "recovery". You will see a line starting with "<program" and ending in "/>". In your case, only the line containing " label="recovery" " and " filename="recovery.img" " is relevant. Remove all other lines starting with "<program" and save. Optionally, rename the file to "program-onyx-recovery.xml" or something you will recognize. This might be useful if you plan to keep the file and use it again in the future.
Now, optionally change filename="recovery.img" to the file name of your TWRP file or just rename your downloaded TWRP file to "recovery.img".
To flash, make sure that the following files are in your working directory:
- prog_emmc_firehose_8974.mbn
- rawprogram0.xml (but your customized version)
- recovery.img (whatever recovery you want to flash)
If that is settled, run qdl as explained in my initial guide in the original post to flash the recovery file.


Some final remarks on locked bootloader on the OnePlus X:
For the future, remember to just keep your bootloader unlocked. It can save you a lot of hassle.
And if you feel uncomfortable about walking around with an unlocked bootloader:
Re-locking the bootloader while TWRP is installed doesn't give any security benefit at all (for obvious reasons). Even if your Recevery would not be open to any local attacker, a locked bootloader doesn't give you much of a benefit on the OnePlus X.
Yes, the generic attac surface of simply using "fastboot flash" is gone, but remember how easy it is to find the UnBrick tool for the OnePlus X we used in this guide. Any attacker can use it as well to flash a malicious recovery onto your device, even if your bootloader is locked - and your OnePlus will boot it.
This is because the OnePlus X does not support Android Verified Boot. This is a security feature on newer Android devices that prevents booting unsigned software if the bootloader is locked. This can prevent flashing malicious firmware, OS or revovery onto a device. But since it also prevents booting TWRP you'd likely be walking around with an unlocked bootloader anyway even if your device were to support this security feature.
Funnily enough, this leads to the conclusion that running your OnePlus X with stock OxygenOS, Recovery and locked bootloader is about as insecure as running TWRP and having an unlocked bootloader if we are talking about an attacker with physical access to the device who also knows about this tool. And since such a tool exists for pretty much every android device as it is originally used to flash these devices in their factories and can be publicly found for most devices, it can be assumed that any attacker has access to this tool.

So remember, the only protection you can have on a OnePlus X is encrypting your data with a strong passcode and hoping that your data stays private even if you might lose your device.
 

emilianoheyns

Member
Sep 7, 2010
42
3
I have no problems with having an unlocked bootloader -- I thought this device had one already. Yesterday it was running TWRP3.0.2-1 and LOS Marshmellow, I just screwed it up trying to upgrade it to an unofficial LOS16. It would first bootloop constantly, then I tried QDL, and now it doesn't even seem to turn on; I can hold the power button for a full minute but the screen remains black, and there's no vibration as I'm used to. It does show up in QDL mode; I tried the procedure as per point 3, using twrp-3.0.2-1 as the recovery image. QDL says:

Code:
HELLO version: 0x2 compatible: 0x1 max_len: 1024 mode: 0
READ image: 13 offset: 0x0 length: 0x50
READ image: 13 offset: 0x50 length: 0x1000
READ image: 13 offset: 0x1050 length: 0x1000
READ image: 13 offset: 0x2050 length: 0x1000
READ image: 13 offset: 0x3050 length: 0x1000
READ image: 13 offset: 0x4050 length: 0x1000
READ image: 13 offset: 0x5050 length: 0x1000
READ image: 13 offset: 0x6050 length: 0x1000
READ image: 13 offset: 0x7050 length: 0x1000
READ image: 13 offset: 0x8050 length: 0x1000
READ image: 13 offset: 0x9050 length: 0x1000
READ image: 13 offset: 0xa050 length: 0x1000
READ image: 13 offset: 0xb050 length: 0x1000
READ image: 13 offset: 0xc050 length: 0x1000
READ image: 13 offset: 0xd050 length: 0x1000
READ image: 13 offset: 0xe050 length: 0x1000
READ image: 13 offset: 0xf050 length: 0x1000
READ image: 13 offset: 0x10050 length: 0x1000
READ image: 13 offset: 0x11050 length: 0x1000
READ image: 13 offset: 0x12050 length: 0x1000
READ image: 13 offset: 0x13050 length: 0x1000
READ image: 13 offset: 0x14050 length: 0x890
END OF IMAGE image: 13 status: 0
DONE status: 0
qdl: failed to read: Connection timed out
LOG: Host's payload to target size is too large
LOG: [email protected] [email protected]
LOG: [email protected] [email protected]
LOG: [email protected] [email protected]E0
LOG: start 1409024, num 31680
LOG: Finished sector address 1440704
[PROGRAM] flashed "recovery" successfully at 3960kB/s
no boot partition found

but the OPX still won't boot.
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
Is your bootloader actually unlocked?
The OnePlus X ships with a locked bootloader that prevents flashing files to the device using fastboot.
The usual steps to modify the OnePlus X and installing custom ROMs are:
- Unlock the bootloader by running "fastboot oem unlock" on a desktop PC while the phone is connected in fastboot mode.
- Flash TWRP by running "fastboot flash recovery TWRP.img" on a desktop PC while the phone is connected in fastboot mode.

Pressing the volume up button while turning on the device normally puts it into fastboot mode and "Fasboot Mode" will be displayed in the middle of the screen along with the oneplus logo.
Unlocking only works with the original OnePlus recovery and if the option "Allow OEM unlocking" is checked in the developer settings. Unlocking requires wiping all userdata.

Did you never do this yourself with your OnePlus X? Did you get this device as a used phone from someone else who already unlocked the bootloader?


What do you mean by "bootloop constantly"? Could you not boot the recovery?


Are you saying you already ran QDL with the unmodified files from the UnBrick tool?
If you really had TWRP 3.0.2-1 running before all your problems started, then doing so initially soft-bricked your device to begin with, as i outlined in footnote [1] of my original post.

I am not sure of the precise timeline and order of your descriptions. I currently assume that you're saying:
1. Had a working device with ROM: "LineageOS 13.0" Recovery: "TWRP version 3.0.2-1" Firmware: Unknown
2. Flashed some "lineage-16.0-unofficial.zip" in TWRP
3. When rebooting, "bootloops" appeared [How did that look? What was affected - just ROM or recovery as well?]
4. Run QDL with the unmodified files from the UnBrick tool that is linked in my original post
5. Phone does not react to button presses except when putting into EDL mode
6. Run QDL with recovery only as described in Point 3 of my follow up post, with the image file of TWRP version 3.0.2-1, QDL repoted success
7. Still not booting [What exactly does this mean? Still no reaction to button presses? Dees the phone vibrate and bring up the OnePlus logo?]
 

BolitaBolita

New member
Apr 27, 2020
4
0
I've followed the mentioned steps and Im still stuck on linux logo..
I desesperately need help, bought a bricked second hand Oneplus X which I know nothing of in terms of past actions but previous owner
 
Last edited:

SebiderSushi

Senior Member
Dec 4, 2016
69
36
I've followed the mentioned steps and Im still stuck on linux logo..
I desesperately need help, bought a bricked second hand Oneplus X which I know nothing of in terms of past actions but previous owner

If you did not modify any files from the unbrick tool by Naman Bhalla and qdl ran through sucessfully, it should have flashed a compatible combination of bootloader and stock recovery so you should be able to reboot to that one.

If this is not the case, you can also go with flashing just a TWRP image. Since there are really just two possible versions of the bootloader (at least in regards to booting compatibility) this should succeed after the second try at most. If not, it means that some other stuff might be broken as well.
As i wrote in my OP, for the OnePlus X any TWRP v3.0.2-0 or older is compatible with the "old bootloader" (Lollipop) and any TWRP v3.0.2-1 or newer is compatible with the "new bootloader" (Marshmallow).

What you basically want to achieve is to just get any recovery booting (be it Stock, TWRP, orangefox or any other useful recovery). From that point, it is fairly easy to get anywhere else on the OnePlus X.

As for other things that can break:
Most of the partitions in your device can be restored to an intact state by flashing an official OxygenOS zip (https://www.oneplus.com/support/softwareupgrade). There are some other ways but this is the safe and easy method.
Only a few partitions cannot be restored once tampered, since they are unique to the specific device. If this happens to be the case, then it can be fairly hard to fix. If the previous owner had unlocked the devices bootloader and flashed some stuff on it, you should ask them whether they might have some TWRP backups around, namely of the partitions "Persist" and "EFS".
 

BolitaBolita

New member
Apr 27, 2020
4
0
If you did not modify any files from the unbrick tool by Naman Bhalla and qdl ran through sucessfully, it should have flashed a compatible combination of bootloader and stock recovery so you should be able to reboot to that one.

If this is not the case, you can also go with flashing just a TWRP image. Since there are really just two possible versions of the bootloader (at least in regards to booting compatibility) this should succeed after the second try at most. If not, it means that some other stuff might be broken as well.
As i wrote in my OP, for the OnePlus X any TWRP v3.0.2-0 or older is compatible with the "old bootloader" (Lollipop) and any TWRP v3.0.2-1 or newer is compatible with the "new bootloader" (Marshmallow).

What you basically want to achieve is to just get any recovery booting (be it Stock, TWRP, orangefox or any other useful recovery). From that point, it is fairly easy to get anywhere else on the OnePlus X.

As for other things that can break:
Most of the partitions in your device can be restored to an intact state by flashing an official OxygenOS zip (https://www.oneplus.com/support/softwareupgrade). There are some other ways but this is the safe and easy method.
Only a few partitions cannot be restored once tampered, since they are unique to the specific device. If this happens to be the case, then it can be fairly hard to fix. If the previous owner had unlocked the devices bootloader and flashed some stuff on it, you should ask them whether they might have some TWRP backups around, namely of the partitions "Persist" and "EFS".

Thank you for your reply SebiderSushi.

The only option I have in terms of recovery booting is the Oneplus original one since I bought the phone bricked (can't access dev options and can't connect through ADB for oem unlock).
I've managed to unlock the bootloader and tried to flash the official OsOxygen zip. The update stopped halfway and the phone bricked once again.
I've tried the Naman Bhalla unbrick tool with the MSMdownloadtool 2.1 (previously attempted 2.0). The process runs successfully, until its marked in green 'download complete'. Phone still bricked.
I'm currently attempting with QFIL through this thread https://www.droidsavvy.com/unbrick-qualcomm-mobiles/
Drivers correctly installed, port 9008 is detected and QFIL is currently. I'm using the files from the unbrick tool by Naman Bhalla for this. The output is the following:


Process Index:0
Programmer Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\prog_emmc_firehose_8974.mbn
Image Search Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla
Please select the XML file
Start Download
Program Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\prog_emmc_firehose_8974.mbn
COM Port number:3
Sahara Connecting ...
Sahara Version:0
Start Sending Programmer
Download Fail:System.Exception: Unable to download Flash Programmer using Sahara Protocol

at QC.QMSLPhone.Phone.QPHONEMS_SaharaArmPrgDownload(String sFileName)

at QC.SwDownloadDLL.SwDownload.QPHONEMSSaharaDownloadArmPrg(UInt64& version, String armPrgPath)
Download Fail:Sahara FailSahara Fail
Finish Download
Start Download
Program Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\prog_emmc_firehose_8974.mbn
COM Port number:3
Sahara Connecting ...
Sahara Version:0
Start Sending Programmer
Download Fail:System.Exception: Unable to download Flash Programmer using Sahara Protocol

at QC.QMSLPhone.Phone.QPHONEMS_SaharaArmPrgDownload(String sFileName)

at QC.SwDownloadDLL.SwDownload.QPHONEMSSaharaDownloadArmPrg(UInt64& version, String armPrgPath)
Download Fail:Sahara FailSahara Fail
Finish Download
Start Download
Program Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\prog_emmc_firehose_8974.mbn
COM Port number:3
Sahara Connecting ...
Sahara Version:0
Start Sending Programmer
Download Fail:System.Exception: Unable to download Flash Programmer using Sahara Protocol

at QC.QMSLPhone.Phone.QPHONEMS_SaharaArmPrgDownload(String sFileName)

at QC.SwDownloadDLL.SwDownload.QPHONEMSSaharaDownloadArmPrg(UInt64& version, String armPrgPath)
Download Fail:Sahara FailSahara Fail
Finish Download
Start Download
Program Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\prog_emmc_firehose_8974.mbn
COM Port number:3
Sahara Connecting ...
Sahara Version:0
Start Sending Programmer
Download Fail:System.Exception: Unable to download Flash Programmer using Sahara Protocol

at QC.QMSLPhone.Phone.QPHONEMS_SaharaArmPrgDownload(String sFileName)

at QC.SwDownloadDLL.SwDownload.QPHONEMSSaharaDownloadArmPrg(UInt64& version, String armPrgPath)
Download Fail:Sahara FailSahara Fail
Finish Download
Start Download
Program Path:C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\prog_emmc_firehose_8974.mbn
COM Port number:3
Sahara Connecting ...
Sahara Version:2
Start Sending Programmer
Sending Programmer Finished
Switch To FireHose
Max Payload Size to Target:49152 Bytes
Device Type:eMMC
Platform:8x26
Disable Ack Raw Data Every N Packets
Ack Raw Data:False
Skip Write:False
Always Validate:False
Use Verbose:False
COM Port number:3
Sending NOP
FireHose NOP sent successfully
Sending Configuration
Device Type:eMMC
Platform:8x26
Request payload size 0xc000 is not the same as support payload size, change to 0x20000
Set TxBuffer 0x20000, RxBuffer 0x4000
Firehose configure packet sent successfully!
Total Bytes To Program 0x62AE4A0
Download Image
PROGRAM: Partition 0, Sector: 0, Length: 33 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\gpt_backup0.bin
PROGRAM: Written Bytes 0x4200 (64)
Program Size: 0.02 MB
PROGRAM: Partition 0, Sector: 0, Length: 34 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\gpt_main0.bin
PROGRAM: Written Bytes 0x4400 (64)
Program Size: 0.02 MB
PROGRAM: Partition 0, Sector: 1609554, Length: 1024 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\config.bin
PROGRAM: Written Bytes 0x80000 (64)
Program Size: 0.50 MB
PROGRAM: Replace the partition sectors number 0x8000 to file size in sector 0x254
PROGRAM: Partition 0, Sector: 1460242, Length: 596 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\logo.bin
PROGRAM: Written Bytes 0x4a800 (64)
Program Size: 0.29 MB
PROGRAM: Replace the partition sectors number 0x8000 to file size in sector 0x74f0
PROGRAM: Partition 0, Sector: 1409024, Length: 29936 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\recovery.img
PROGRAM: Written Bytes 0xe9e000 (64)
Program Size: 14.62 MB
PROGRAM: Replace the partition sectors number 0x10000 to file size in sector 0x26a3
PROGRAM: Partition 0, Sector: 294912, Length: 9891 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\persist.img
PROGRAM: Written Bytes 0x4d4600 (64)
Program Size: 4.83 MB
PROGRAM: Partition 0, Sector: 259048, Length: 20480 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\static_nvbk.bin
PROGRAM: Written Bytes 0xa00000 (64)
Program Size: 10.00 MB
PROGRAM: Partition 0, Sector: 238568, Length: 20480 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\dynamic_nvbk.bin
PROGRAM: Written Bytes 0xa00000 (64)
Program Size: 10.00 MB
PROGRAM: Replace the partition sectors number 0x3e8 to file size in sector 0x28d
PROGRAM: Partition 0, Sector: 229376, Length: 653 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\tz.mbn
PROGRAM: Written Bytes 0x51a00 (64)
Program Size: 0.32 MB
PROGRAM: Replace the partition sectors number 0x3e8 to file size in sector 0x174
PROGRAM: Partition 0, Sector: 182272, Length: 372 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\rpm.mbn
PROGRAM: Written Bytes 0x2e800 (64)
Program Size: 0.18 MB
PROGRAM: Replace the partition sectors number 0x800 to file size in sector 0x380
PROGRAM: Partition 0, Sector: 180224, Length: 896 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\emmc_appsboot.mbn
PROGRAM: Written Bytes 0x70000 (64)
Program Size: 0.44 MB
PROGRAM: Replace the partition sectors number 0x40 to file size in sector 0x17
PROGRAM: Partition 0, Sector: 148480, Length: 23 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\sdi.mbn
PROGRAM: Written Bytes 0x2e00 (64)
Program Size: 0.01 MB
PROGRAM: Replace the partition sectors number 0x400 to file size in sector 0x22d
PROGRAM: Partition 0, Sector: 147456, Length: 557 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\sbl1.mbn
PROGRAM: Written Bytes 0x45a00 (64)
Program Size: 0.27 MB
PROGRAM: Replace the partition sectors number 0x20000 to file size in sector 0x1c983
PROGRAM: Partition 0, Sector: 16384, Length: 117123 Sectors, Sector Size: 512 Bytes
File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\NON-HLOS.bin
PROGRAM: Written Bytes 0x3930600 (64)
Program Size: 57.19 MB
Total Size: 98.68 MB
Total Size: 28 Seconds
Throughput: 3.52 MB/Seconds
PATCH: Partition 0, Sector: 9, Offset 40 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-34.
PATCH: Partition 0, Sector: 0, Offset 40 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-34.
PATCH: Partition 0, Sector: 1, Offset 48 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-34.
PATCH: Partition 0, Sector: 0, Offset 48 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-34.
PATCH: Partition 0, Sector: 1, Offset 32 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-1.
PATCH: Partition 0, Sector: 0, Offset 24 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-1.
PATCH: Partition 0, Sector: 0, Offset 72 Bytes, Size: 8 Bytes, Value: NUM_DISK_SECTORS-33.
PATCH: Partition 0, Sector: 1, Offset 88 Bytes, Size: 4 Bytes, Value: CRC32(2,4096)
PATCH: Partition 0, Sector: 0, Offset 88 Bytes, Size: 4 Bytes, Value: CRC32(NUM_DISK_SECTORS-33.,4096)
PATCH: Partition 0, Sector: 1, Offset 16 Bytes, Size: 4 Bytes, Value: 0
PATCH: Partition 0, Sector: 1, Offset 16 Bytes, Size: 4 Bytes, Value: CRC32(1,92)
PATCH: Partition 0, Sector: 0, Offset 16 Bytes, Size: 4 Bytes, Value: 0
PATCH: Partition 0, Sector: 0, Offset 16 Bytes, Size: 4 Bytes, Value: CRC32(NUM_DISK_SECTORS-1.,92)
Total download file size: 98.68066MB
Throughput: 3.524309M/s
Reset Phone
Waiting for reset done...
Download Fail:FireHose Fail Fail to find QDLoader port after switch
Finish Download
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
The only option I have in terms of recovery booting is the Oneplus original one since I bought the phone bricked (can't access dev options and can't connect through ADB for oem unlock).

Now what exactly do you even mean when you say "Bricked"?
If you can boot into recovery, then your device is usually not bricked, but even if, it is usually not in a state where using a flashing tool and risking to **** up the device for good has any real advantage over solving whatever problem in the recovery.

As long as your device doesn't have any hardware errors (broken storage) then the official OnePlus Recovery should almost always be able to install the official OxygenOS.

Under what terms did you even buy this device? How did the previous owner describe the state of the device and its defects if they mentioned them?

File: C:\Users\simao\Desktop\AAA\OPX_UnBrick_Mini_By_Naman_Bhalla\config.bin
You are using windows, so how did you even end up in this thread?
 

emilianoheyns

Member
Sep 7, 2010
42
3
Sorry for the delay -- I thought I had set up notifications and didn't want to push on the point until you had time, but I did not receive a notification for this.

Is your bootloader actually unlocked?
The OnePlus X ships with a locked bootloader that prevents flashing files to the device using fastboot.
The usual steps to modify the OnePlus X and installing custom ROMs are:
- Unlock the bootloader by running "fastboot oem unlock" on a desktop PC while the phone is connected in fastboot mode.
- Flash TWRP by running "fastboot flash recovery TWRP.img" on a desktop PC while the phone is connected in fastboot mode.

I had a LineageOS running on the OPX before I screwed up an upgrade of LOS. I had TWRP on the phone. The bootloader must be unlocked then yes?

Pressing the volume up button while turning on the device normally puts it into fastboot mode and "Fasboot Mode" will be displayed in the middle of the screen along with the oneplus logo.

broadly, that is what I had done before, but right now I don't even get the fastboot logo.

Unlocking only works with the original OnePlus recovery and if the option "Allow OEM unlocking" is checked in the developer settings. Unlocking requires wiping all userdata.
Right, but I had passed that station before, as it was running LOS.

Did you never do this yourself with your OnePlus X? Did you get this device as a used phone from someone else who already unlocked the bootloader?
No, I did all this myself, but screwed up the update to a non-official LOS.

What do you mean by "bootloop constantly"? Could you not boot the recovery?
I could not, no, but now I'm not even getting the fastboot logo


Are you saying you already ran QDL with the unmodified files from the UnBrick tool?
Correct, yes.

I am not sure of the precise timeline and order of your descriptions. I currently assume that you're saying:
1. Had a working device with ROM: "LineageOS 13.0" Recovery: "TWRP version 3.0.2-1" Firmware: Unknown
2. Flashed some "lineage-16.0-unofficial.zip" in TWRP
3. When rebooting, "bootloops" appeared [How did that look? What was affected - just ROM or recovery as well?]
Initially I could get to recovery, I tried to upgrade to the latest TWRP for the OPX, when I tried to restart that to recovery, it would just vibrate and reboot continuously

7. Still not booting [What exactly does this mean? Still no reaction to button presses? Dees the phone vibrate and bring up the OnePlus logo?]
Currently, the screen stays black, and I can hold volume up or power for 20 seconds with no reaction (no vibrate, no logo)
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
First off, i'm extremely sorry for my delay! I also happened to notice your message just today.

Right now i got around and tried reproducing your scenario on my own OnePlus X.
As you said that you ran the unmodified setup from the unbrick tool according to my guide, i did as well - and ran into the same issue you were describing.
After some fiddling around, i realized that you must supply the patch0.xml file as well for a complete flash on the OnePlus X when you also modify the GPT (partition table), which the unmodified rawprogram0.xml does. This is not the case if you only install a recovery or other individual partitions so it slipped my mind. I deeply apologize for not testing the command line for the unmodified UnBrick tool package well enough while writing my Guide.

If nothing else is wrong, running
"/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn rawprogram0.xml patch0.xml"
with the unmodified UnBrick tool will fix the device back to a booting state with the stock recovery and Lollipop Bootloader installed on the device., it did so in my case.
Alternatively, if you don't want to reflash all partitions from the package, you can also just try running
"/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn patch0.xml"

Short of any good documentation, i guessed that the problem appeared because the unmodified rawprogram0.xml also writes the GPT table in its last two program elements. If you look in patch0.xml, you can see that it takes care of the GPT in some way. Once i removed the two program items regarding the GPT, rawprogram0.xml could be applied without needing to flash patch0.xml together with it.
So i assume that it is safe to individually flash any partition listed it rawprogram0.xml apart from the GPT. If your GPT is not in a valid state, there's not much booting going on, since your device won't be able to even read your bootloader from the disk without a partition table.


I had a LineageOS running on the OPX before I screwed up an upgrade of LOS. I had TWRP on the phone. The bootloader must be unlocked then yes?

While this implies that you very likely once had an unlocked bootloader to allow installation of TWRP to your device, it is not necessarily the case. For one, it is possible to re-lock the bootloader on the OnePlus X and still boot and use custom recoveries and software. Only flashing images via fastboot becomes impossible again if you relock the bootloader. This is because the OnePlus X is a fairly old device (remember it came out with android 5.1). Such old devices don't support features like Android Verified Boot yet. This is the standard on modern android devices and it implies that a locked bootloader should only load and boot untampered system partitions as signed by the device vendor.

Also, qdl (or any othe software using the Qualcomm Emergency Download Mode) can also install custom Recoveries or ROMs to the devices without unlocking the bootloader and flashing stuff through fastboot.
 
Last edited:

SebiderSushi

Senior Member
Dec 4, 2016
69
36
After that, you can also boot back into fastboot mode and the run
fastboot oem device-info
from your computer to check if your devices bootloader is currently unlocked or not. If it is not, this is a perfect chance to unlock it, since you already got the official recovery installed and probably no user data to take care of anyway.
 

emilianoheyns

Member
Sep 7, 2010
42
3
Hi, thanks for getting back to me. The problem I'm facing currently is that the OPX currently seems unresponsive -- the screen stays black, and no vibration, seemingly regardless of what button combination I use or how long I keep it on the charger. Any idea what key combo is most likely to bring it up in a state that QDL would see it?

I have fetched a fresh copy of OPX_UnBrick_Mini_By_Naman_Bhalla; I'm sorry to have to ask again, but I should then copy over prog_emmc_firehose_8974.mbn, rawprogram0.xml and patch0.xml unchanged, and run `/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn rawprogram0.xml patch0.xml`? I think I'd prefer to get it back to a booting state to then figure out what I can safely flash on it.

---------- Post added at 04:35 PM ---------- Previous post was at 04:30 PM ----------

I should note, if I connect the charger, the red charging light comes on for a second, maybe two, end then goes out again. It does not come back on unless I plug in again, even if I let it charge overnight.
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
In my case the usual route to enter EDL mode worked fine - that is, disconnect your OnePlus X from any power source for a few seconds, then press and hold the Volume Up button and after a few seconds reconnect it to your PC where you run qdl, then release the button and execute qdl.

If you want to flash the default confuguration of the unbrick tool you must open your terminal window in the folder you extracted from the download (or cd to it). This is because the files that are flashed to the device are in this folder as you caj see and they are being referenced with relative paths / their filenames from within "rawprogram0.xml".
 

emilianoheyns

Member
Sep 7, 2010
42
3
In my case the usual route to enter EDL mode worked fine - that is, disconnect your OnePlus X from any power source for a few seconds, then press and hold the Volume Up button and after a few seconds reconnect it to your PC where you run qdl, then release the button and execute qdl.

Ah well, it must have died somewhere along the way then. When I do that, even after having it on the charger, nothing shows up in dmesg. Thanks in any case!
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
I wouldn't give up just yet. The actual rule for entering EDL mode on the OnePlus X is:
- The device must be powered off at the beginning
- The Volume Up button must be in pressed state when connecting it to the computer

Everything else, like waiting few seconds here and there is mostly safeties to ensure each state is entered or recognized cleanly.

I mostly had my phone running fresh from the last flashing process, which means that qdl had turned it off cleanly for me. So i definitely had good conditions to enter EDL mode.
I don't know what's going on with your notification LED since i didn't notice this on my device or payed any attention to it - but it might indicate that your phone could be in a not cleanly powered off state.

You can still try pressing the power button for a longer time (maybe about 10 to 30 seconds) to see if that switches off your device the right way before you retry entering EDL mode.
Or do any other experiments pressing buttons or try with different cables.

When was the last time you could successfully connect your device in any mode and which mode was it?
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
The symptoms you described about black screen, no vibrations or any reaction to button presses were also present on my device as well so this is i'd guess it's just normal for the state.
 

SebiderSushi

Senior Member
Dec 4, 2016
69
36
If you get it back to a booting state you should be able to install the official OxygenOS right from the stock recovery, or flash a compatible TWRP image using qdl or fastboot and copy any remaining data that you want to keep.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    DISCLAIMER: This guide describes procedures with tools that are designed to write directly to the storage of your device. This has the potential to lead to data loss or bricking your device. If you follow this guide carefully, none of these things should happen. That being said, you are still responsible for your own actions and how you handle the tools mentioned in this guide. Caution is advised.


    When do i need this?
    The following procedure can be used to get your device back into a booting state if all else fails. Usually you'd want to use this tool to get a working recovery running on your device and then go from there, since apart from flashing ROMs, recoveries like TWRP offer direct access to the internal storage as well.

    This tool is usually not needed if:
    - The device still boots into recovery and it is possible to access the internal storage through it or flash ROMs. Flashing the official OxgenOS downloaded from OnePlus can fix many issues and the stock recovery is just fine for this purpose.
    - The devices bootloader is unlocked. In this case fastboot boot <recovery-image.img> can be used to get into a useful recovery
    - The Android ROM still boots and offers root access. This can also be used to flash a useful recovery to the device


    Now, if you made sure that you are desperate enough to go on, let's cut to the chase.

    You may know the legendary guide by Naman Bhalla about unbricking your OnePlus X: https://forum.xda-developers.com/oneplus-x/general/guide-mega-unbrick-guide-hard-bricked-t3272108
    It utilizes the interface that's used in factories to flash the OnePlus X and does not rely on an unlocked bootloader - it allows direct read/write access to the devices flash storage. The original guide requires you to install drivers and run an executable from an unknown source on a windows machine. What if you mistrust this or don't have access to a windows machine?
    Well, i know i'm hella late but i was happy to find this so i'm going to share it now:
    There is an open source tool to flash your device using Qualcomms EDL mode and it can be used on a Linux machine!

    Since the same protocol is used to flash onto the device, the procedure is mostly analogous to the original guide by Naman Bhalla. It simply uses another program on your PC to achieve this.
    You'll need to know how to use a terminal, how to open a terminal in a specific directory and how to install missing software in the Linux distribution you are using. It is very likely that you also need root access or sudo on your machine.
    Once all that is settled, follow these steps:

    • To download and compile QDL, the open source flashing tool that will be used in this guide, follow the section "Get the Linux flashing tool" from these instructions
    • Download and extract the "UnBrick tool mini" linked in a follow up post by Naman Bhalla and open a terminal in the extracted folder with all the files
    • Before the next steps, make sure that everything is configured correctly. Everything else might flash something you don't want and even has the potential brick and/or overwrite anything in your phone's storage. Apart from that, you might also flash just a recovery instead of the complete package that comes with the download. [1] [2]
    • With your OnePlus X powered off, hold the volume up key, then establish a USB-connection to your PC
      (To make sure the device connected properly, you can check the output of "dmesg". It should print something like "Qualcomm USB modem converter now attached to ttyUSB".)
    • On the terminal in the extracted folder, run the following for the default configuration:
      "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn rawprogram0.xml patch0.xml"
      For a customized configuration, edit "rawprogram0.xml" and save it as "customprogram.xml" for example, then run
      "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn customprogram.xml"
      Be careful about the last two "<program />" elements from "rawprogram0.xml" which flash to the "PrimaryGPT" or "BackupGPT" respectively. If you include them in your "customprogram.xml" you must also flash the "patch0.xml" program like in the unmodified configuration, or your device won't boot, like so:
      "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn customprogram.xml patch0.xml"
      If qdl gets stuck at "waiting for device", try running the command with root privileges, e.g. with "sudo <command>".
      If everything worked, you'll see several lines of output and the tool will report what is flashed etc.
    • Once it's done, QDL will reset power on your device to kick it out of EDL mode. If everything is alright your phone should react to being connected via USB by vibrating and booting into the charging screen. Just before this happens, you can already press and hold the volume down button to boot straight into recovery, or wait and boot your device normally into whatever mode you're up to.

    Congratulations on unbricking your device on a Linux machine, enjoy. Also, props to you for still using your OnePlus X after all this time :)


    HELP, i've ran qdl and my device does not vibrate or boot or ANYTHING AT ALL!
    If this happens, you have likely flashed to the GPT without patching it, either accidentaly because you left the "<program />" tags which flash to "PrimaryGPT" and "BackupGPT" in your "customprogram.xml" without adapting your command line as described or because you followed an older version of this guide which contained a serious error in that regard. Don't fret - it's not that serious, you probably just need to flash the "patch0.xml" program from the UnBrick tool to get your device up and running. It ensures that your GPT is intact again after flashing to it. This is your partition table so it is required to read the bootloader from your devices storage or literally anything else. If it can't be read there's nothing to do any booting with.
    To get back your device either run the full default configuration with
    "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn rawprogram0.xml path0.xml"
    or remove everything but the two "<program />" elements from "rawprogram0.xml", save it as "gptprogram.xml" and run
    "/path/to/qdl_source_code/qdl prog_emmc_firehose_8974.mbn gptprogram.xml patch0.xml"

    [1] The UnBrick tool comes with a flashing procedure along with the required files, which, without further modifications to rawprogram0.xml or removal of those files, will flash device drivers and bootloader and the recovery from some OxygenOS 2 OTA update by OnePlus onto your phone. If you have "the new bootloader" installed, [ i.e. you once flashed OxygenOS 3, have any modern (post-Marshmallow) ROM running on your device or TWRP v3.0.2-1 or newer ] then this will soft-brick your device, meaning your ROM won't boot anymore.
    By having a look at the rawprogram0.xml file, it's fairly easy to figure out how to tinker with it: You can A remove certain elements to flash only what you want or B replace the files that come with the UnBrick tool by anything you want. Want to flash the files from the OxygenOS 3.1.3 OTA? No problem - just obtain them, place them in the directory and give them the right names and go. Want to flash only a compatible TWRP? Put it in the directory and edit the program xml file accordingly and all is good.
    [2] Actual bricking should only occur if you use a program xml file meant for a different device or if you change any of the values that control at which offset the files are going to be flashed. QDL will write anything onto your device to any given storage area as specified in the xml program, independent from partition boundaries and even if it means overwriting something from your data partition or maybe your IMEI and MAC address - Remember that via EDL you can reflash most of the storage back to a working system, but not everything. The original rawprogram0.xml from the UnBrick tool mini only writes to partitions that you are able to reflash to a working condition - as long as you haven't edited it, you should be able to restore to a working condition if something goes wrong.