Directory Instructions:  

This directory is generated by the QCTool's full-partition readback function and is used to create a universal 9008 unbrick firmware.  
If you need to flash, ignore the files in this directory. They are not for flashing and do not belong to the firmware. The XML files in the **images** directory are for 9008 flashing.  

The **orig** directory contains the device's original GPT and XML files, as well as the **partition.xml** file generated based on the original GPT.  
The **generate** directory contains the standard GPT and XML files generated by **ptool.exe** using the **partition.xml** file.  

How to create firmware:  

1. It is recommended that the readback device system be an unmodified official version and able to boot normally. Devices with locked bootloader will not boot if flashed with a modified system.  
2. For A/B partition devices, ensure the device is in **slot A** and can boot normally before readback. Most 9008 tools do not support switching to **slot B**, and flashing a system readback from **slot B** will result in a failure to boot.  
3. After readback, for A/B partition devices, go to the **images** directory and delete all ***_b.img** files. Rename all ***_a.img** files by removing the **_a** suffix.  
4. Check if there are files in the **generate** directory. If not, manually use the command **ptool.exe -x partition.xml** to attempt generation and troubleshoot. Typically, this issue arises when the size of a last partition (e.g., **userdata**) contains a decimal. In such cases, simply truncate the decimal and regenerate, as the size of last partitions is automatically adjusted, the value in **partition.xml** has no effect.  
5. Overwrite the **rawprogram?.xml**, **patch?.xml**, **gpt_main?.bin**, **gpt_backup?.bin**, and **gpt_both?.bin** files from the **generate** directory into the **images** directory.  
6. Edit all **rawprogram?.xml** files in the **images** directory. Replace all instances of **_a.img** and **_b.img** with **.img** in bulk, ensuring both slots flash the same set of image files.  
7. Edit all **rawprogram?.xml** files in the **images** directory. For partitions that do not need to be flashed (e.g., nv partitions), leave the **filename="xxx"** field empty by modifying it to **filename=""**. This will skip those partitions during flashing. It is recommended to compare with the official firmware's XML to determine which partitions should be excluded.  
8. If Fastboot flashing support is required, modify **flash_all.bat** by similarly replacing all instances of **_a.img** and **_b.img** with **.img**, and delete or comment out lines corresponding to partitions that do not need to be flashed.  
9. If Fastboot flashing support is not needed, delete **flash_all.bat**.  
10. Package and release.

by xda@SYXZ 2025.6.29
