Fix ESP32 Full Companion partition policy

This commit is contained in:
mikecarper committed 2026-08-29 20:26:27 -07:00
1 parent fdf528bb27
commit f873e51b43
5 files changed
+266 -2

No files matched your search

+37
View File
@@ -3,6 +3,15 @@ Import("env")
import os
# These layouts encode board-specific data-placement contracts, not merely an
# application-size preference. A Full merged image must retain them so an
# application/partition-table migration does not silently move or orphan the
# board's persistent data.
PRESERVED_FULL_PARTITION_TABLES = {
"variants/sensecap_indicator-espnow/dual_ota_2560k_preserve_spiffs.csv",
}
def parse_flash_size(value):
text = str(value).strip().upper()
multipliers = {"KB": 1024, "MB": 1024 * 1024}
@@ -12,9 +21,35 @@ def parse_flash_size(value):
return int(text, 0)
def preserved_full_partition_table(value):
path = str(value or "").strip().replace("\\", "/")
return next(
(
table
for table in PRESERVED_FULL_PARTITION_TABLES
if path == table or path.endswith("/" + table)
),
None,
)
if os.environ.get("MESHCORE_ESP32_FULL_BUILD") == "1":
board = env.BoardConfig()
flash_size = parse_flash_size(board.get("upload.flash_size", "4MB"))
requested_partitions = os.environ.get(
"MESHCORE_ESP32_FULL_PARTITION_TABLE", ""
).strip()
required_partitions = preserved_full_partition_table(
requested_partitions
)
if requested_partitions and not required_partitions:
raise ValueError(
"unsupported required Full partition table: "
+ requested_partitions
)
preserved_partitions = required_partitions or preserved_full_partition_table(
board.get("build.partitions", "")
)
if str(board.get("build.mcu", "")).lower() == "esp32s3":
# Every S3 Full image must remain ROM-bootable across the supported
# flash parts. Some board manifests default to QIO even though their
@@ -33,6 +68,8 @@ if os.environ.get("MESHCORE_ESP32_FULL_BUILD") == "1":
# a merged recovery image changes only the application, not the proven
# boot/partition chain. The 3 MiB app slot has ample room for this role.
partitions = "huge_app.csv"
elif preserved_partitions:
partitions = preserved_partitions
elif flash_size >= 16 * 1024 * 1024:
partitions = "default_16MB.csv"
elif flash_size >= 8 * 1024 * 1024: