In most instances, it’s just a softbrick or bootloop which could easily be recited by flashing the stock firmware via Fastboot Commands. But sometimes, the issue might be much more concerning and your device could end up in a hard-brick state. Fortunately, if you own a device with the Qualcomm chipset, then there’s a handy way out. You could boot your device to the Emergency Download Mode and then flash the MBN firmware file via the Qualcomm Flash Image Loader (QFIL) Tool. As soon as you do so, your device will end up in Fastboot Mode and from then onwards, you could flash the firmware via device-specific tools or using Fastboot Commands. However, the MBN file isn’t the only requirement for the QFIL Tool. It also requires you to have the rawprogam0 and patch0 XML files. But more often than not, you wouldn’t find these files inside the stock firmware. So what could be done? Well, let’s create both these files on our own! So without further ado, let’s check out the steps to create rawprogram0.xml and patch0.xml files and unbrick Qualcomm devices.
Create rawprogram0.xml and patch0.xml files and Unbrick Qualcomm Devices
The below instructions are listed under separate sections for ease of understanding. Make sure to follow in the exact same sequence as mentioned. Droidwin and its members wouldn’t be held responsible in case of a thermonuclear war, your alarm doesn’t wake you up, or if anything happens to your device (well, it’s already bricked, but still) and data by performing the below steps.
STEP 1: Install Python
First and foremost, you will have to install Python on your PC. As for this guide, we require version 2.x. So download it from the official site [direct link] and proceed with on-screen instructions to install it. However, if you have the latest 3.x version installed, then do not uninstall it, rather install version 2.x in a separate directory.
STEP 2: Download Qualcomm GPT Tool
Next up, download the Qualcomm GPT Tool [download link] and extract it inside the same folder where you have installed Python. So both the files of the GPT Tool (GPTAnalyzer and PTool) should be inside the Python folder itself.
STEP 3: Get GPT.Bin from Stock Firmware
Next up, download the stock firmware for your device and extract it to any convenient location. Then copy the GPT.bin file from the extracted firmware folder and transfer it to the Python folder. The GPT file might be named either primaryGPT.bin, gpt_backup0.bin, gpt_main0.bin, or gpt_both0.bin.
In some instances, the firmware might have the “backup0, main0, and both0” all these three GPT files. In that case, you should choose the ‘main’ file. Likewise, there could be numerous instances of the GPT main file. So you should choose the one that has 0 in its name. In simpler terms, it is recommended to choose the gpt_main0.bin file.
STEP 4: Create rawprogram0.xml and patch0.xml Files
So with this, we round off the guide on how you could create the rawprogram0.xml and patch0.xml files and then use them to unbrick your Qualcomm device. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution at the earliest. To make the Qualcomm GPT Tool compatible with the latest Python, you will have to rectify the below-mentioned errors. So start off by downloading an advanced text editor (like Notepad++) and keeping both the tool files GPTAnalyzer and PTool files nearby.
Then select the GPTAnalyzer file, right-click on it and select Show More Options. After that, choose Open With > Notepad++. Likewise, do the same for PTool. Once both the files are opened in Notepad++, you may proceed with the below instructions.
Fix Invalid Hexadecimal Literal 0xFFFFFFFFL Error in Python 3.x
To rectify this issue, you will have to remove L from the end of 0xFFFFFFFFL. It would be in line 55 of the GPTAnalyzer.py file.
Fix Missing parentheses in call to print. Did you mean Print (….)? Error in Python 3.x
To fix this issue, enclose all the Print commands under parenthesis (). This will take a lot of time as the change has to be done across both the GPTAnalyzer and PTool files.
Fix: Multiple Exception Types must be Paranthesized Error in Python 3.x
To resolve this error, add the ‘except’ values under brackets, and instead of a comma, use the ‘as’ keyword. Taking an example from this GPTAnalyzer file, line 591 is: So you will have to change it to:
Once you have made the changes and fixed all the aforementioned issues, use the Ctrl+S to save the changes. That’s it. The tool is now compatible with the latest Python build and you may use it without any issues.
So on that note, we round off the guide on how you could create the rawprogram0.xml and patch0.xml files and then use them to unbrick your Qualcomm device. Likewise, we also made you aware of the steps to make the tool compatible with the latest Python version. You may now drop in your queries regarding the tool conversion, QFIL usage, or the creation of raw program and XML files in the comments section below.