[OnePlus X General] SebiderSushi:
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://xdaforums.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://xdaforums.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.

Edit 2022-09-04: This whole paragraph only applies to the OxygenOS 2 bootloader. A locked OxygenOS 3 bootloader will only boot a signed ROM or a signed recovery. However, the device storage can always be dumped through EDL and the final point about encryption always applies.

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.