bkerler / edl

Inofficial Qualcomm Firehose / Sahara / Streaming / Diag Tools :)
GNU General Public License v3.0
1.47k stars 354 forks source link

Fix broken gpt on MSM8916 device #521

Closed ElectroBoy404NotFound closed 2 months ago

ElectroBoy404NotFound commented 3 months ago

Hi!

I recently corrupted the GPT on my device. I only have the output of the printgpt command from a few months ago:

Parsing Lun 0:

GPT Table:
-------------
modem:               Offset 0x0000000004000000, Length 0x0000000004000000, Flags 0x1000000000000000, UUID 139c3c30-a316-96e4-08c9-2dd527b7c79b, Type EFI_BASIC_DATA, Active False
sbl1:                Offset 0x0000000008000000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID e0bf0e13-537c-1e50-35d7-9107be253b6a, Type 0xdea0ba2c, Active False
sbl1bak:             Offset 0x0000000008080000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID a6170790-538b-d806-3bfb-14ce24f4291d, Type EFI_BASIC_DATA, Active False
aboot:               Offset 0x0000000008100000, Length 0x0000000000100000, Flags 0x0000000000000000, UUID dabbd507-c0ba-b6fa-354b-8b834e5b4331, Type 0x400ffdcd, Active False
abootbak:            Offset 0x0000000008200000, Length 0x0000000000100000, Flags 0x0000000000000000, UUID e90bb264-ae25-94dc-61f9-a94404879362, Type EFI_BASIC_DATA, Active False
rpm:                 Offset 0x0000000008300000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID 2b70c469-5a4d-f15a-64ec-d0004873718e, Type 0x98df793, Active False
rpmbak:              Offset 0x0000000008380000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID c55b7629-8000-989b-5044-fa133e284061, Type EFI_BASIC_DATA, Active False
tz:                  Offset 0x0000000008400000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID 3fe27334-2591-10b9-d58b-f937c51d8b5f, Type 0xa053aa7f, Active False
tzbak:               Offset 0x0000000008480000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID 988ad99d-da72-4670-8f0f-db1f7c777e22, Type EFI_BASIC_DATA, Active False
hyp:                 Offset 0x0000000008500000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID 805ccc31-d233-781a-dda6-77d56e251db9, Type 0xe1a6a689, Active False
hypbak:              Offset 0x0000000008580000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID 2c16bedc-2fcf-0a96-ba84-35a57804b51a, Type EFI_BASIC_DATA, Active False
pad:                 Offset 0x0000000008600000, Length 0x0000000000100000, Flags 0x0000000000000000, UUID 4507499f-7884-3a69-c178-ba0175c68e9d, Type EFI_BASIC_DATA, Active False
modemst1:            Offset 0x0000000008700000, Length 0x0000000000180000, Flags 0x0000000000000000, UUID e7398daa-89da-29a0-9107-7afab3dfb752, Type 0xebbeadaf, Active False
modemst2:            Offset 0x0000000008880000, Length 0x0000000000180000, Flags 0x0000000000000000, UUID 20713022-54ea-df29-c85e-d4c3983e8c18, Type 0xa288b1f, Active False
misc:                Offset 0x0000000008a00000, Length 0x0000000000100000, Flags 0x0000000000000000, UUID de98b0b9-f228-4ed4-6ff8-dffc0eb4defa, Type 0x20117f86, Active False
fsc:                 Offset 0x0000000008b00000, Length 0x0000000000000400, Flags 0x0000000000000000, UUID 54e54d54-e058-4665-c768-949fa83def10, Type 0x57b90a16, Active False
ssd:                 Offset 0x0000000008b00400, Length 0x0000000000002000, Flags 0x0000000000000000, UUID 7b3f7d8c-9270-bd1d-de5d-724ba0d78dbf, Type 0x2c86e742, Active False
splash:              Offset 0x0000000008b02400, Length 0x0000000000a00000, Flags 0x0000000000000000, UUID 286f3284-fb42-9ced-0cc0-bf054ed1f8a1, Type 0x20117f86, Active False
DDR:                 Offset 0x000000000c000000, Length 0x0000000000008000, Flags 0x1000000000000000, UUID 2ffd23a1-a4ef-9334-5636-8d45771b84c9, Type 0x20a0c19c, Active False
fsg:                 Offset 0x000000000c008000, Length 0x0000000000180000, Flags 0x1000000000000000, UUID 63646187-86d0-44d6-ea87-7ea6f19b88ba, Type 0x638ff8e2, Active False
sec:                 Offset 0x000000000c188000, Length 0x0000000000004000, Flags 0x1000000000000000, UUID 59a9b81f-e48f-e4cd-890c-e491407c91cf, Type 0x303e6ac3, Active False
boot:                Offset 0x000000000c18c000, Length 0x0000000002000000, Flags 0x1000000000000000, UUID 82f4a6c8-8b98-e662-5b07-a16bd0979977, Type 0x20117f86, Active False
system:              Offset 0x000000000e18c000, Length 0x0000000070800000, Flags 0x1000000000000000, UUID 955979db-a855-a518-1b54-1a44b16f77a4, Type EFI_BASIC_DATA, Active False
persist:             Offset 0x000000007e98c000, Length 0x0000000002000000, Flags 0x1000000000000000, UUID 0f8f2ce2-7b5b-3135-1a61-b81f6f048839, Type EFI_BASIC_DATA, Active False
cache:               Offset 0x000000008098c000, Length 0x0000000010600000, Flags 0x1000000000000000, UUID 6da5a955-f9fc-9552-f3ea-72b43f2bcb73, Type EFI_BASIC_DATA, Active False
recovery:            Offset 0x0000000090f8c000, Length 0x0000000002000000, Flags 0x1000000000000000, UUID 5ad0f84d-5b2b-cea1-537f-a30c894c0f20, Type 0x20117f86, Active False
keystore:            Offset 0x0000000094000000, Length 0x0000000000080000, Flags 0x0000000000000000, UUID 541ab26a-caec-fd54-89e4-fff0c1964b5c, Type 0xde7d4029, Active False
config:              Offset 0x0000000094080000, Length 0x0000000000008000, Flags 0x0000000000000000, UUID 5f2578c2-98ea-0961-c109-242272bbddec, Type 0x91b72d4d, Active False
oem:                 Offset 0x0000000094088000, Length 0x0000000004000000, Flags 0x0000000000000000, UUID 235c237f-3fa7-900c-ee2b-f5e5dce0d722, Type 0x7db6ac55, Active False
userdata:            Offset 0x000000009c000000, Length 0x0000000135ffbe00, Flags 0x1000000000000000, UUID 5a3eeaa6-c4ee-59aa-8f25-a59b0a031ef0, Type EFI_BASIC_DATA, Active False

Total disk size:0x00000001d2000000, sectors:0x0000000000e90000

Any way to fix it?

bongbui321 commented 3 months ago

edl gpt . --genxml --memory=ufs. run something like this --> high chance that your backup gpt header partition is uncorrupted --> write to primary gpt header partition with the backup .bin

Edit: Not sure if your device has backup gpt header partition but it is good to try. hmm I looked at the code for gpt header dump, and you might want to make sure it is correct, since I suspect that the dump of the backup is not correct.

ElectroBoy404NotFound commented 3 months ago

edl gpt . --genxml --memory=ufs. run something like this --> high chance that your backup gpt header partition is uncorrupted --> write to primary gpt header partition with the backup .bin

Edit: Not sure if your device has backup gpt header partition but it is good to try. hmm I looked at the code for gpt header dump, and you might want to make sure it is correct, since I suspect that the dump of the backup is not correct.

Nope; My device doesn't have backup gpt

ElectroBoy404NotFound commented 2 months ago

Finally, I found the stock rom for this device. It has the gpt backup