Add bpi partition support

This commit is contained in:
Bjoern Kerler 2023-03-20 12:36:52 +01:00
parent 66198345ef
commit 287dd9a066
No known key found for this signature in database
GPG key ID: 52E823BB96A55380
2 changed files with 15 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import argparse
import os
import sys
import logging
from io import BytesIO
from enum import Enum
from struct import unpack, pack
from binascii import hexlify
@ -160,7 +161,7 @@ class gpt(metaclass=LogBase):
def parseheader(self, gptdata, sectorsize=512):
return self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C])
def parse_bpi(self, gptdata):
def parse_bpi(self, gptdata, pagesize=0x200):
class partf:
unique = b""
first_lba = 0
@ -171,7 +172,7 @@ class gpt(metaclass=LogBase):
type = b""
name = ""
entryoffset = 0
self.sectorsize = 0x200
self.sectorsize = pagesize
self.totalsectors = 0
self.partentries = []
for pos in range(0x800,len(gptdata),0x80):

View file

@ -29,6 +29,18 @@ class Partition(metaclass=LogBase):
def get_gpt(self, gpt_settings, parttype="user"):
data = self.readflash(addr=0, length=2 * self.config.pagesize, filename="", parttype=parttype, display=False)
if data[:4] == b"BPI\x00":
guid_gpt = gpt(
num_part_entries=gpt_settings.gpt_num_part_entries,
part_entry_size=gpt_settings.gpt_part_entry_size,
part_entry_start_lba=gpt_settings.gpt_part_entry_start_lba,
)
data = self.readflash(addr=0, length=32 * self.config.pagesize, filename="",
parttype=parttype, display=False)
if data == b"":
return None, None
guid_gpt.parse_bpi(data, self.config.pagesize)
return data, guid_gpt
if data[:9] == b"EMMC_BOOT" and self.read_pmt is not None:
partdata, partentries = self.read_pmt()
if partdata == b"":