Skip to content

Commit 07820cf

Browse files
committed
Update dynamic memory calculation process
The order of partitions should also be taken into account as the factory partition may be allocated for a bootloader (e.g. Adafruit's custom partition file with a UF2 bootloader) and appear after ota_0 used for app
1 parent 650fb5d commit 07820cf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

builder/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,14 @@ def _update_max_upload_size(env):
145145
}
146146

147147
# One of the `factory` or `ota_0` partitions is used to determine available memory
148-
# size. If both partitions are set, then the `factory` partition is used by default
148+
# size. If both partitions are set, we should prefer the `factory`, but there are
149+
# cases (e.g. Adafruit's `partitions-4MB-tinyuf2.csv`) that uses the `factory`
150+
# partition for their UF2 bootloader. So let's use the first match
149151
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#subtype
150-
max_upload_size = sizes.get("factory", sizes.get("ota_0", 0))
151-
if max_upload_size:
152-
board.update("upload.maximum_size", max_upload_size)
152+
for p in _parse_partitions(env):
153+
if p["type"] in ("0", "app") and p["subtype"] in ("factory", "ota_0"):
154+
board.update("upload.maximum_size", _parse_size(p["size"]))
155+
break
153156

154157

155158
def _to_unix_slashes(path):

0 commit comments

Comments
 (0)