Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions qcom_ptool/gen_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def usage() -> NoReturn:
"readonly": "true",
"filename": "",
"sparse": "false",
"active": "false",
"successful": "false",
"unbootable": "false",
}

##################################################################
Expand Down Expand Up @@ -135,6 +138,12 @@ def partition_options(argv):
partition_entry["readonly"] = "true"
else:
partition_entry["readonly"] = "false"
elif opt in ["--active"]:
partition_entry["active"] = arg
elif opt in ["--successful"]:
partition_entry["successful"] = arg
elif opt in ["--unbootable"]:
partition_entry["unbootable"] = arg
elif opt in ["--filename"]:
partition_entry["filename"] = arg
elif opt in ["--sparse"]:
Expand Down Expand Up @@ -162,6 +171,9 @@ def parse_partition_entries(partition_entries):
"type-guid=",
"filename=",
"attributes=",
"active=",
"successful=",
"unbootable=",
"sparse=",
],
)
Expand Down
12 changes: 10 additions & 2 deletions qcom_ptool/ptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,9 +1004,7 @@ def CreateGPTPartitionTable(PhysicalPartitionNumber, UserProvided=False):
% (FirstLBA, LastLBA, LastLBA - FirstLBA + 1)
)

# Attributes
Attributes = 0x0
# import pdb; pdb.set_trace()

if PhyPartition[k][j]["readonly"] == "true":
Attributes |= 1 << 60 ## Bit 60 is read only
Expand All @@ -1020,6 +1018,13 @@ def CreateGPTPartitionTable(PhysicalPartitionNumber, UserProvided=False):
Attributes |= PhyPartition[k][j]["tries_remaining"] << 52
if PhyPartition[k][j]["priority"] > 0:
Attributes |= PhyPartition[k][j]["priority"] << 48
# qbootctl A/B slot flags (qbootctl gpt-utils.h)
if PhyPartition[k][j]["active"] == "true":
Attributes |= 1 << 50
if PhyPartition[k][j]["successful"] == "true":
Attributes |= 1 << 54
if PhyPartition[k][j]["unbootable"] == "true":
Attributes |= 1 << 55

print("Attributes\t\t0x%X" % Attributes)

Expand Down Expand Up @@ -2002,6 +2007,9 @@ def ParseXML(XMLFile):
Partition["readbackverify"] = "false"
Partition["tries_remaining"] = 0
Partition["priority"] = 0
Partition["active"] = "false"
Partition["successful"] = "false"
Partition["unbootable"] = "false"

##import pdb; pdb.set_trace()

Expand Down