From ceafaa7c176c18875538886b35e7291b2635f64a Mon Sep 17 00:00:00 2001 From: valeros Date: Wed, 30 Aug 2023 17:32:34 +0300 Subject: [PATCH] Update dynamic partition offset calculation process Resolves #1178 --- builder/main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/main.py b/builder/main.py index d6706ae28..1f493503a 100644 --- a/builder/main.py +++ b/builder/main.py @@ -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() @@ -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 } @@ -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