Home Forum

Support GUIDE -->> How To Create Partition.xml [GPT] <<--

Creating the partition.xml file is key for building unbrick Roms.
I have not found any python or bash scripts that will create the partition.xml.
And many of the Qualcomm Proprietary tools floating around are out of date and no longer apply.

I have created a OPEN OFFICE CALC spreadsheet to create the data you need to put in the partition.xml file automatically. There is still a process that must be followed in order to do this correctly.


See here to make a bootable flash drive. If you aren't running linux.


Step 1 is to download this spreadsheet.
Download and unzip the generator spreadsheet.

I will go over the process of filling in the data you need to generate the partition.xml
Please hold off on posting until I let you know I am finished with the tutorial.
The tutorial will be several post long.

Big Country:cool:


#1 Bigcountry907, Mar 2, 2017
Get the GPT Partition Table.

The first thing we need is the GPT Partition Table.

There are a couple of different ways to do this.

#1 Any file saying gpt_main.img or gpt_main.bin that is in a Firmware package is most likely the GPT Table.
HTC has the GPT Table in their RUU firmware.

@samsight has asked about the LG G PAD II 8.0 LTE Tablet
@samsight Could have made this easier by posting more specific model info. So I will assume it is the LG V497.

Firmwares list for LG V497

So I will use this as the example for the tutorial.
File name
File size Date Downloads
North America
CA/Canada V49710b_00.kdz

Download the firmware package.
Now you will need to extract the .kdz to image files.
I'm gonna go do that so ill BRB
#2 Bigcountry907, Mar 2, 2017
OK finally I got the .kdz unpacked. What a PITA.

For anyone trying to unpack the .kdz the only tool that worked on this rom was the version from here.

Now that we have the factory flash files we can actually get something done.
The files we have now are the same as what we would have if we used DD to pull a backup from the device.

The GPT files.

So now if you did this you would have


These are the files that you can parse with parsebinarypartition.bl and other similar tools.
These files are the main gpt and the backup gpt.

This is exactly what we need.
But at any rate. Because I like the dragonboard tools.
For Dragonboard 410 c Dragonboard 410 e.

These tools apply to all the qualcomm chips. And there publicly available


There are instructions on that page.
Read them all and actually do them even though you dont have a dragonboard.
So you can get a feel for whats going on.

Next I will show you how to use a couple of the tools.
Then I will show you how to use the spreadsheet and the PrimaryGPT_0.bin to make the dreaded Partition.xml

Don't worry its easier than you think. Just pay close attention to my instructions.
I will start the next post momentarily
#3 Bigcountry907, Mar 2, 2017
Create gpt_both0.bin
gpt_both0.bin is a special format file for GPT that can be used with fastboot

For example
fastboot flash partition gpt_both0.bin

That would write the partition info to the emmc of the device.
You will also find the gpt_both0.bin in the unbrick roms along with gpt_main0.bin and gpt_backup0.bin.

If you renamed the PrimaryGPT_0.bin from the .kdz file to gpt_main0.bin they are exactly the same.

So we have gpt_main0.bin how do we make gpt_both0.bin or the gpt_backup0.bin???

Download the dragonboard tools.

git clone https://git.linaro.org/landing-teams/working/qualcomm/db-boot-tools.git

Make a folder on your desktop called Create-Part and extract copy the tools there.
Make a folder inside the Create-Part folder called ROM and copy all the files from the extracted .kdz or other device firmware there.

Your folders need to look like this


Make one more folder inside Create-Part folder called TARGET

After you have done that open up a terminal window in LINUX.
cd to the Create-Part directory.
Then run this command in the terminal

./mkgpt -i ~/Desktop/Create-Part/ROM/PrimaryGPT_0.bin -o ~/Desktop/Create-Part/TARGET/gpt_both0.bin

Lets copy the primary gpt into the TARGET folder.
Run this command in the terminal

cp -rf ~/Desktop/Create-Part/ROM/PrimaryGPT_0.bin ~/Desktop/Create-Part/TARGET/gpt_main0.bin

When your all done the terminal will look like this.

Now that we have the gpt_main0.bin and gpt_both0.bin we can start using the spreadsheet to make the partition.xml

We will start that on the next post.
#4 Bigcountry907, Mar 2, 2017
Alright Lets get down to business.

Open the gpt_main0.bin in a hex editor and take a look at it.
I use bless hex editor but any will do.

Thats what were looking for. Most GPT partition tables should have the same format. By standards they are supposed to. But that doesn't mean that all manufactures follow the standard even though there required to.

So we know we have a good GPT Partition Table.
We need to create a text file of the gpt_main0.bin so we can copy the data into our spreadsheet.
Linux includes a utility called hexdump. Were gonna use it. It dumps the binary hex file.

Use this command to create the dump.

hexdump -C -v ~/Desktop/Create-Part/TARGET/gpt_main0.bin > ~/Desktop/Create-Part/TARGET/gpt_main0.txt

Now you will have gpt_main0.txt in the TARGET Folder.
Double click on it to open it in a text editor.

Open the Spreadsheet and on the bottom click the tab that says template-sheet.
We will use template-sheet to format the hexdump data before we paste it into the spreadsheet.

Click anywhere on the gpt_main0.txt that is open in the editor.
Right Click and choose select all
Right Click and choose copy.

No click on the spreadsheet.
Click on cell C4

Cell C4 has 0000000 in it.
right click on cell C4
This GPT is extra big so give it a bit and then you will get a format dialog box.
For SEPERATOR OPTIONS pick Fixed width.
Then click on the first box that says standard.
Hold the shift key and pick the last box that says standard
The whole section should be highlighted black.
Choose Text as COLUM TYPE

There should be little red dots that seperate the colums.
Hopefully the formatting in my spreadsheet stays the right way for you.
On my computer once i select fixed width the seperators are right where they need to be.

Your format window needs to look like this.


Click on ok and the data will populate the spreadsheet.
We need to delete some extra colums.
They are all empty with no data.
By holding the ctrl key and clicking on the letter at the top of the columns we need to delete we can select the whole column.

We need to delete

F, H, J, N, P, R, V,X,Z,AB,AD,AF,AH

The columns should be highlighted like this.


Once they are right click and choose delete
Pick delete columns

Your spreadsheet should now look like this.


Now we are ready to copy the data into the Generator.
Click on cell C4
Scroll all the way down to the last line of data .
Hold the shift key and then click on cell W32771
The data should be highlighted.
Right click cell W32771 and choose copy.

The spreadsheet should look like this.


Noe click on the Tab GPT-Decoder-Blank4-Your-Partiton.xml


Right click on the burgandy color cell B5 the select PASTE ONLY ( PASTE ONLY )
The choose text.

Your generator data is now populated.
If you scroll down a little It should look like this.


The top section is all the GPT Header data.
Down further is the data for each partition.

We will look at the rest of the process in the next post
#5 Bigcountry907, Mar 2, 2017
To finish this up we need to check the read only and boot flags for each partition.
Scroll down through the partition info and look here.


The default setting of my ggenertor is false.
For any readonly = true partitions you will need to set the flag.
Go through all the partitions and write down ant that are read only.

Theese partitions are read only 16 TOTAL.


We Need to set the readonly flag for all these partitions to true.
Scroll over to the right a little and you will see the flag section of the spreadsheet,
After you set all the flags it should look like this. Except I Added Color To Mine.


That takes care of the Read Only and Bootable Flags.
You can see that we need to fill in the sizes of the partitions in KB.
We will do that next.
It is a little more work because I dont have the device.
But if you run these commands in a terminal window you can easily get the sizes.

adb devices
adb shell
cat /proc/partitions
cat /proc/emmc

You would then have the rest of the data.
Im gonna go find the sizes.
Be back soon.
#6 Bigcountry907, Mar 2, 2017 Last edited: Mar 2, 2017
Sorry for the delay. I am re-writing the spreadsheet to simplify the importing of the GPT into the spreadsheet.
I am trying to reduce the number of steps required to get the partition.xml file.
Right now I have added in automatic conversion of the Start LBA and End LBA. Using the converted addresses I was able to calculate the KB sizes and Sector Sizes so now the only data required is the hex dump of the GPT table.

I am glad that I decided to do this tutorial with the LG V497.
This is an interesting partition table that includes all of the features we would ever run into for the partition.xml.
There are read only partitions.
I have added to the spreadsheet automatic setting of the read only flag.
You no longer have to set the readonly flag it will be determined automatically.
The boot flag has always been false in every case i have worked on so far.
There is a byte in the partition attributes that sets the partition bootable but I have not found a GPT table with this flag set yet.

Basically the spread sheet is set up to handle a max of 128 partition entries. This is the max number for a GPT partition table.
Any standard GPT Table can be used with this spreadsheet.
If you have a non standard GPT then you will need to adjust the spreadsheet to accommodate it.
I will attach a pdf file that explains the MBR and GPT partitions standards.
It's available here. and attached to this post.

At any rate this should make everything Automatic and very easy to use.
After I have finished and tested the new sheet I will Post instructions and the new spreadsheet.

In the meantime.....
#7 Bigcountry907, Mar 4, 2017
Hi Bigcountry907, you rock man, your help is very much appreciated. you provided the great help making the partition.xml file. I have to start making the partition.xml now.

But do you know how to make the eMMC Flash Programer file MPRG8926.hex or .bin for LGv497? because I like to use the tool studio software but I need the flash programmer MPRG8926.mbn . i was told that not any MPRG8926 will work, each device has different MPRG file. if i find this flash programmer file for my device LGv497 I have a great chance to recover my bricked LGv497 tablet.

as i mentioned before, i have a full mmcblk0.img backup of a fully working same device because i have two devices one is bricked and the other is fully new.
can you extract the MPRG8926.mbn from the mmcblk0.img backup??????

thank you so much you really rock man. thumbs up ..

cheers .
#8 samsight, Mar 8, 2017
The MPRG8926.mbn comes from the Qualcomm Source Code.
I have not determined the exact requirements of this yet. But I have the source for several chips.
Basically far as I know the MPRG is just the flash programmer, and I believe one is the same as any other with the exception of how they are signed. If your device requires signed bootloaders ect. then it is likely going to require a signed MPRG but I have read otherwise as well. The file you must create is the msimage.mbn. The msimage.mbn is created using the main boot partitions , SBL1 Sbl2, Non-Hlos.mbn aboot .ect. The problem is the signing and that there really is no one answer fits all.

All I can really recommend is to keep reading threads about unbricking devices with the same chipset. As far as I remember throughout my research, LG is a PITA. and was unable to use this method until recently. (SIGNING ISSUES).

If I remember correctly there are some post on ANDROIDBRICK forum that talk about a update / repair tool that was released by LG. Pretty sure that if you find that Official LG tool you can use it to flash your own images.

My reasons and method for generating an image like this are slightly different.

#1 You can make an exact clone of your Tablet / Phone to a sd card. Some devices will boot a sd card made this way and not boot the emmc. This gives you a chance to get into fastboot mode or download mode and if you know how you can fix things.

Right now my primary interest is in the MSM8909 chip.
That's the one i'm working on and its much different than the 8226.

Lucky for you I know for fact there is a unlimited amount of information on the 8226 chip you can find on google.

When it comes to things like this you just have to keep reading and reading and reading and trying until you get something to work.
#9 Bigcountry907, Mar 8, 2017
Ok , Bigcountry907 , I have started to work with this tutorials and i got stuck at certain level which is , copying gpt_main0.txt file content to the partition.xml_Generator_spreadsheet file. and here is what I am facing.

i managed to dump the gtp_main0.bin to txt file and copy all selected all and copied all the content and then opened the spreadsheet file in Ubuntu 16.04 and i clicke template tab at the bottom and then i right click on Cell C4 the one with 00000 and then i chose past, I waited for a bit as your tutorials says its a long file need sometime to make the dialog box show up, so finally the dialog box showed up and i selected Fixed Width and here is where i got stuck. your tutorial says click on the first standard box and hold shift key and then click on the second standard and then chose Text for the format. the problem is the i don't see the second standard even i scrolled all the way to the buttom of the spreadsheet cell number 27000 and it had hex value 80000 in it and i did not see the second starndard label that is mentioned in the tutorials. also as soon i clicked on the first standard box the hole information got dark without continuing to the second standard label. and when i change the first standard box to text nothing happen i did not see the TEXT red dog seperators.

does the red do takes time to show or they will show right away when i change standard to text?? please tell me how to fix this issue because i am stuck on this level now.

thank you for your cooperations.
#10 samsight, Mar 9, 2017
My dear, i just like to say nevermind about my spreadsheet question above because i figured it out, it was straight forward and your info was clean it was my mistake. so far i am working with you in this tutorial, so my spreadsheet is done to the level you posted the information for, I will wait for the sizes in KB for each partition and then continue to the last point to come up with partition.xml file.

just forgot to mention, the PDF file

Rajewski_CEIC_2013_UEFI is corrupt when i click on it to save it it says i need admin rights to view it so can you zip it and repost the PDF . i also noticed that the file extension of it says .pdf.part is not it suppose to be only .pdf?? what is this pdf file ?

thank you so much man i will look forward with you to continue the spreadsheet tutorial till the end. cheers.
#11 samsight, Mar 9, 2017
Hello. The pdf is a breakdown of the gpt structure.
It's a presentation from some kind of class.

I will upload the new spreadsheet for you.
I have finished patching it up to automatically generate the size information. So the spreadsheet is all the way filled in.

We need to look at each of your partition backup files. Of the good device. Do you have a backup of each partition?

Ill post you the commands to pull all of them.

If you have them then what wen need to do is hexdump each one the same way we dump the gpt file. Right now im dowloading in windows. When im done and can boot my ubuntu back up i will give you the commands and post the completed spreadsheet.
#12 Bigcountry907, Mar 9, 2017
are you referring to the mmcblk0.img back of the good device as a back files?? or you you need each partition file separate? . here is what i dont to come
up with the full mmcblk0.img backup its almost 16GB file size.

1) i formatted an SD card to NTFS file system as the max file size FAT32 can accept is 4GB so NTFS takes larger file sizes.
2) i opened the working LGv497 tablet and rooted it with kingroot and installed busybox
3) i downloaded terminal APK from the play store
4) i opened terminal and issue this command : su (Enter) and switched from $ to # root prompt
5) I issued this command to backup the mmcblk0.img:
sudo dd if=/dev/block/mmcblk0 of=/storage/external_SD/mmcblk0.img bs=1024
6) at the end i found the mmcblk0.img file size almost 16GB on my SD card.
7)transferred the mmcblk0.img to my PC using card reader
8)used win32 disk imager tool to burn the mmcblk0.img on my SD card
9) after step 8 i inserted the SD card in the bricked unit and nothing happen the only difference is when i press power and vol+ or vol- the display lights up with 0% battery and then it goes off , at the computer sometimes while the sd card is still in the device manager detect it s QHS-USB BULK with yellow exclamation mark. but when i take the sd card out of the device and then reconnect the device to PC it gets detected as QHS-USB_QDLoader 9008 (COM x) fine with no yellow exclamation mark. so not sure how to make it boot into fastboot so i can load TWRP or Clockworkmod recovery using :
fastboot boot TWRP.img and then recover my device fully.

so please let me know what partition backup files your referring to on the working device. also write me the command so i can try to pull them up

#13 samsight, Mar 9, 2017
Well it sounds like we can fix your bricked tablet.
First put that sd card in and leave the tablet plugged into the charger. Need to get battery 100% charged.

Maybe take the tablet apart and put the battery in the good tablet to charge it. Then put it back in the bricked device.

When your not working on the bricked device then disconnect the batter so it stays charged.

Get the battery 100% first.
Then hold both volume up and down in wile pressing the power button. It might boot to fastboot with the sd card in.

Try the normal volume down + power
Volume up plus power.
Always with the sd card in.

My guess is that we are going to need to create the sd card by a different method. Upload your mmcblk0.img to meadiafire. Zip it first and the size will go wayy wayy down. like 2 gb. Ill build the sd card image you can try.

Then we need to install the right drivers. Thats why you get yellow exclamation point.
I have them so ill post those too.

Then if your device goes into QHS-USB BULK it will either show up as a removable media and you can flash it or we will find another way.

Get the battery charged and upload your backup.
Ill be back soon.
#14 Bigcountry907, Mar 10, 2017
Hi, I believe the battery is fully charged because I had it plugged in for one full night and the SD card was in it. its just shows 0% battery because its hard bricked. i believe if the battery has no juice the PC device manager will not detect it as Qualcomm QHS-USB_QDLoader (COM x) no exclamation mark, or with SD card (mmcblk0) in the device as QHS-USB BULK with yellow exclamation mark even though I have all the drivers installed. so what do you say next?

I was reading on the forum people says don't flash laf.bin or any of the system.bin files on the sd because it disables fastboot, after i burn the full backup 16GB mmcblk0.img on the SD card, how can i wipe the laf partition and the system partition and try after to see if it boot into fastboot mode??

can you write down the commands to pull out the backup files you were referring to in your previous post??? i will try to pull them out using Ubuntu 16.10

the weird thing is in Ubuntu its detected as Qualcomm QHS-USB BULK but when i go to terminal i type ls /dev/sd* it does not show up or ADB does not show it at all. so when i type lsusb command on terminal i see it on Bus 002 with ID and name as Qualcomm QHS-USB Gobi QD Loader so is there a way we can make dd work with the Bus to flash it all from ground zero???

please let me know when you post the new spreadsheet and continue the tutorial to save the final partition.xml file.

i tried to use Android tool studio and i was able to create the 8926_msimage.mbn (boot_image) file but when i try it with the tool studio it output an error about the flash programmer MPRG8926.mbn even though i tried lots of MPRG8926.mbn on the net but still no success, so the MPRG8926 flash pro must be a device specific thing, and this is what I am trying to get how to build that file , having all the partition bins from the kdz file.

#15 samsight, Mar 10, 2017
Well the battery could be dead. You have little options to figure out if it is or not.
A) Put the battery in a working device and charge it.

The problem is once the phone goes into qdl mode it stays in qdl mode which slowly drains the battery.
Until it is dead. If it shows Zero percent then it's dead.

If the battery is dead there is no chance you will be able to flash it.

When you plug the tablet into the computer it is being powered by the computer.
That is how it shows up as qdl. Same as with JTAG. With JTAG like riff box 2 the power over usb is enough to fire up the device processor.

As far as drivers there are many different drivers.
Bottom line is if you have yellow exclamation point in device manager you are missing a driver.

Let me go see what I can collect for you.
Just know that there are tons of things you can find on google.

And did you disable driver signing enforcement in windows.

Even though post like this are for different devices the drivers and methods may work. Just use your own files and not the files for other devices.

Take a look here.


The rest of your questions are not simple answers.
And it will take me more time to walk you through doing these things than it will for me to write some software to do these things automatically.

I have been working on a program to do all of this.

As far as the sd card and what partitions to flash I don't have that specific information.

But I would suggest getting a very specific SD Card for this project.
Sandisk EXTREME PLUS rated at 95mbs transfer rate.

It is the only card I have found so far that is fast enough to boot from.
On the newer htc devices you can use the SD Card as internal storage.
Some of the normal partitions are moved to and booted from the sd card during normal operation.
Marshmallow test the sdcard speed before it will allow it to be used as internal storage and this is the only card that passes.

So you need a SD card with a rating of 95mbs transfer or higher.
Even the really good cards that rate 85mbs 90mbs transfer rates don't work.

This card rates 95 mbs.

Make sure the card is rated 95 mbs transfer. Or higher.

After I have finished writing the program we will work on the next step.

These are the fastest sd cards on the market.
It should be easy to run a full android rom off of one of theese.
You will see the read and write is up around 250 mbs.

#16 Bigcountry907, Mar 11, 2017 Last edited: Mar 11, 2017
Thanks for this great help.
I have lg g stylo h631 which is dead now. It shows Qualcomm 9008 in device manager. Is it possible to repair it using the above mentioned methods. I have kdz I even extracted it, now I have all the mentioned file. But I don't have any Linux os.
#17 mrnice2, Mar 24, 2017
It could be possible. If you have a backup or can get a backup of all the device partitions from a working device. With a Factory Firmware package you can get some of the files but there are other files you will need that wont come in a firmware package.

Much of this could be done in windows I suppose. You can make a boot able flash drive to run Ubuntu without installing it.

I am working on a program to automate this process as much as possible but there is still alot of work i must do.
#18 Bigcountry907, Mar 24, 2017
Someone here dumped three partition. Can they be useful in recovering mine.
#19 mrnice2, Mar 24, 2017
Ive also been dealing with LG H631 Stylo hard brick..unfortunately Board Diag, SmartBoot, Bridge, nor LG UP have done much to help...I have 3 or 4 different versions Ive pulled from different places on the web...i even found the QPST tools..I am currently trying to figure out a way to use them since they offer the most help for me not knowing what I am doing..but since it is hard bricked, I figure I have nothing to lose and knowledge to gain
#20 SoonersChuck, Apr 19, 2017
I ended up getting sidetracked on the qdl-husb-9008 / 9006 repair flash.

This turned out to be quite good as I ended up figuring out how to flash the right partitions to a High Speed SD - Card and Boot off of the SD Card. This I have done for the HTC Qualcomm based devices.

I never had any luck with the Qfil / Qpst because the files you flash may need to be signed depending on the device you have.

I may be able to do a similar thing on LG devices but the only LG I have is a LG Volt 2.

To do this though we need a backup of every partition on the device.
Not just a factory firmware.
The factory firmware wont have files for every partition.

In the next week or so I will try this out on my LG.
If it works it might help you.
#21 Bigcountry907, Apr 21, 2017
hello sir, previously, sorry for my bad english.

It's been 4 months my phone dead (bad flashing because porting). In device manager detected as QHUSB_BULK, and can only be in flash using tools that use PORT & COM.
I've read and followed this guide and from the thread on XDA too, hoping someone can help me out.

Can this method be used for Xperia devices, sir? MSM8226 chipset 8GB ROM.

Just info, now i already have :
  1. mmcblk0 backup (dd method) & separated partition backup too (dd method)
  2. some output (parted, gdisk, fdisk, proc, mounts)
  3. Flashtool firmware
  4. Flashbox firmware from SEtool box (in this package, contains many info for the partition, such as name, file type, start block, number of blocks, gpt type, gpt id, gpt attributes, boot delivery-files for signing boot maybe)
  5. generated files from your spreadsheet and then build use build tools (partition.xml, rawprogram.xml, patch0.xml)

BUT, I do not have 8226_msimage.mbn, MPRG8226.mbn, emmc_prog_firehouse_8226.mbn and sahara file.
#22 Funsvcker, Jul 7, 2017
Congratulations for the work you've done. I have a LG G3 32GB, I would like to convert .kdz to .tot. I managed to get .bin but would like to get .mdb files, is there a faster procedure?

Thank you
#23 peterx21, Oct 3, 2017

I don't know if this will be of any help...but don't hurt to take a peak

I think today I'm gonna try...I'll try to post back if I get the opportunity to attempt it
#24 SoonersChuck, Oct 3, 2017
Nice but also explain how this will help in troubleshooting or creating some extra features.
#25 peter shahma, Oct 3, 2017