Skip to content

Commit

Permalink
Update dynamic partition offset calculation process
Browse files Browse the repository at this point in the history
Resolves #1178
  • Loading branch information
valeros committed Aug 30, 2023
1 parent a846cb0 commit ceafaa7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def _parse_partitions(env):
return

result = []
next_offset = 0
# The first offset is 0x9000 because partition table is flashed to 0x8000 and
# occupies an entire flash sector, which size is 0x1000
next_offset = 0x9000
with open(partitions_csv) as fp:
for line in fp.readlines():
line = line.strip()
Expand All @@ -117,11 +119,14 @@ def _parse_partitions(env):
tokens = [t.strip() for t in line.split(",")]
if len(tokens) < 5:
continue

bound = 0x10000 if tokens[1] in ("0", "app") else 4
calculated_offset = (next_offset + bound - 1) & ~(bound - 1)
partition = {
"name": tokens[0],
"type": tokens[1],
"subtype": tokens[2],
"offset": tokens[3] or next_offset,
"offset": tokens[3] or calculated_offset,
"size": tokens[4],
"flags": tokens[5] if len(tokens) > 5 else None
}
Expand All @@ -130,9 +135,6 @@ def _parse_partitions(env):
partition["size"]
)

bound = 0x10000 if partition["type"] in ("0", "app") else 4
next_offset = (next_offset + bound - 1) & ~(bound - 1)

return result


Expand Down

0 comments on commit ceafaa7

Please sign in to comment.