Allow specifying custom application partition name // Issue #1166

This way developers can select an arbitrary partition which will be used
for dynamic memory checks.
This commit is contained in:
valeros
2023-08-07 14:54:11 +03:00
parent 95e0a731cc
commit f1fdbc5838
+20 -5
View File
@@ -144,12 +144,27 @@ def _update_max_upload_size(env):
if p["type"] in ("0", "app")
}
# One of the `factory` or `ota_0` partitions is used to determine available memory
# size. If both partitions are set, we should prefer the `factory`, but there are
# cases (e.g. Adafruit's `partitions-4MB-tinyuf2.csv`) that uses the `factory`
# partition for their UF2 bootloader. So let's use the first match
partitions = {p["name"]: p for p in _parse_partitions(env)}
# User-specified partition name has the highest priority
custom_app_partition_name = board.get("build.app_partition_name", "")
if custom_app_partition_name:
selected_partition = partitions.get(custom_app_partition_name, {})
if selected_partition:
board.update("upload.maximum_size", _parse_size(selected_partition["size"]))
return
else:
print(
"Warning! Selected partition `%s` is not available in the partition " \
"table! Default partition will be used!" % custom_app_partition_name
)
# Otherwise, one of the `factory` or `ota_0` partitions is used to determine
# available memory size. If both partitions are set, we should prefer the `factory`,
# but there are cases (e.g. Adafruit's `partitions-4MB-tinyuf2.csv`) that uses the
# `factory` partition for their UF2 bootloader. So let's use the first match
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#subtype
for p in _parse_partitions(env):
for p in partitions.values():
if p["type"] in ("0", "app") and p["subtype"] in ("factory", "ota_0"):
board.update("upload.maximum_size", _parse_size(p["size"]))
break