[OnePlus X General] SebiderSushi:
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. If your bootloader is locked you can use this tool to flash the stock recovery again and unlock the bootloader as ususal.

If that is not sufficient, you can also reflash all of firmware, bootloader and stock recovery.

This guide is not needed if:​

- The device still boots into stock recovery or TWRP

Flashing the official OxygenOS can fix many issues and you can unlock your bootloader as needed.

- The bootloader is unlocked. Use fastboot flash recovery <twrp image>

Check it with fastboot oem device-info

Use TWRP v3.0.2-0 with the OxygenOS 2 bootloader and the latest TWRP with the OxygenOS 3 bootloader.

- The ROM still boots and is rooted. Flash a stock recovery in a root shell:

adb root && adb shell

dd of=/dev/block/platform/msm_sdcc.1/by-name/recovery if=/sdcard/OxygenOS_recovery.img

OxygenOS 2 Lollipop recovery - OxygenOS 3 Marshmallow recovery

On custom ROMs, you can usually enable root access for ADB in developer settings, even if you didn't root them youself.

If any link is dead, search for it on https://web.archive.org

Spoiler content hidden.

Don't continue unless you actually checked if your bootloader is still unlocked. Sometime it is re-locked on accident if some things go wrong.

Recovery and ROM only boot with a compatible bootloader. If you're not sure, try one then the other.

There are two major versions of the OnePlus X bootloader, one from OxygenOS 2 (Lollipop) and one from OxygenOS 3 (Marshmallow), released ca. September 2016, all newer ROMs should be compatible.

Trying to boot into a ROM or recovery that is incompatible with the installed bootloader will get you stuck on the bootlogo screen. On the OxygenOS 2 bootloader the "Powered by Android" part will disappear.

A locked OxygenOS 2 bootloader will boot any compatible software.

A locked OxygenOS 3 bootloader will only boot software signed by OnePlus. When trying to boot an unsigned ROM or recovery the device will vibrate, splash the bootlogo for a second and reboot, resulting in an endless loop.

If all else fails: Flashing through EDL​

You may know the legendary Mega Unbrick Guide for A Hard Bricked OnePlus X by Naman Bhalla but it only works on Windows.

It uses EDL, a hidden Qualcomm interface that allows direct read/write access to the devices flash storage to restore firmware, bootloader and stock recovery.

EDL is a powerful tool. A device in EDL mode will follow all instructions given to it without checking whether it would be a good idea to do so. If the instructions tell your device to overwrite userdata, IMEI or MAC address it will do so. Only flash files that are meant for your device. Don't edit any file unless you know what it does.

Preparation:​

You need to be at least somewhat familiar with the command line to do this.

- Install git from your distribution

- Download and compile the open source flashing tool QDL. Follow the section "Get the Linux flashing tool" from these instructions.

- Temporarily add QDL to your $PATH with export PATH="$(pwd):$PATH"

QDL must be able to communicate with your device. You can install the appropriate udev rules right now or try it without them first.

- Open a text editor sudo nano /etc/udev/rules.d/51-edl.rules

- Copy these rules and paste them. Ctrl+S to save, Ctrl+X to exit

- The rules should apply the next time you connect your device

- If flashing does not work check the file contents: cat /etc/udev/rules.d/51-edl.rules

- If you can't read the file: sudo chmod a+r /etc/udev/rules.d/51-edl.rules

- If the new rules still don't load for some reason: sudo udevadm control --reload

- Download the "UnBrick tool mini" as uploaded by Naman Bhalla. (direct link)

- Create a clean working directory and extract the zip file.

Customize what to flash:​

By default, the UnBrick tool mini will flash OxygenOS 2 bootloader, firmware and stock recovery. From there you can flash the latest OxygenOS and unlock your bootloader again for a clean start.

Flashing OxygenOS will always install a compatible bootloader and firmware and OxygenOS will automatically upgrade the recovery during the boot process.

If this is what you want just skip to the next step.

The UnBrick tool will flash config.bin and persist.img and reset these partitions.

Resetting config will re-lock the bootloader.

Resetting persist will require it to be repopulated again. OxygenOS can do this but most Custom ROMs will have broken sensors.

If you don't want to flash certain files, rename them or move them to another directory.

If you only want to flash certain partitions like the recovery, create a new directory, e.g. flash_recovery-only. Download the recovery version you need:

OxygenOS 2 Lollipop recovery - OxygenOS 3 Marshmallow recovery

Copy it to the new directory and rename it to recovery.img to match the filename the UnBrick tool uses.

Additionaly, copy these files from the UnBrick tool:

gpt_main0.bin

gpt_backup0.bin

patch0.xml

prog_emmc_firehose_8974.mbn

rawprogram0.xml

Main procedure:​

cd to the directory with the files from the UnBrick tool. Go to your custom directory if you created one in the previous step.

Run qdl prog_emmc_firehose_8974.mbn rawprogram0.xml patch0.xml

QDL will wait for your device to connect.

If QDL asks for permissions go back to "Preparation" and install the udev rules.

With the OnePlus X powered off hold VolUp and connect it to the PC. Otherwise, connect it to the PC first and hold Power+VolUp until it connects in EDL mode.

To verify the connection you can check lsusb or sudo dmesg -w

Devices in EDL mode show up with idVendor=05c6 and idProduct=9008, usually as Product: QHSUSB__BULK

lsusb example: ID 05c6:9008 Qualcomm, Inc. Gobi Wireless Modem (QDL mode)

To filter the output: lsusb -d 05c6:9008

QDL should print several lines of output, reporting what is flashed etc.

Once it's done, QDL will kick your device out of EDL mode. If everything is alright your phone should vibrate and boot to the charging screen. You should be able to boot to recovery now.

Congratulations on unbricking your device on a Linux machine, enjoy. :)

Changelog:

2019-12-12 - Original post

??? - undocumented edits

2020-05-24 - Fix possible execution of QDL without patch0.xml which would break the partition table

2022-09-05 - Fix unnessesarily confusing instructions