Skip to content

Commit 90aafe2

Browse files
committed
check FW bin file size when creating factory.bin
1 parent c22ae2b commit 90aafe2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pio-scripts/create_factory_bin.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
platform = env.PioPlatform()
2222

2323
import sys
24-
from os.path import join
24+
from os.path import join, getsize
2525

2626
sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
2727
import esptool
@@ -60,6 +60,14 @@ def esp32_create_combined_bin(source, target, env):
6060
flash_size,
6161
]
6262

63+
# platformio estimates the amount of flash used to store the firmware. this
64+
# estimate is not accurate. we perform a final check on the firmware bin
65+
# size by comparing it against the respective partition size.
66+
max_size = env.BoardConfig().get("upload.maximum_size", 1)
67+
fw_size = getsize(firmware_name)
68+
if (fw_size > max_size):
69+
raise Exception("firmware binary too large: %d > %d" % (fw_size, max_size))
70+
6371
print(" Offset | File")
6472
for section in sections:
6573
sect_adr, sect_file = section.split(" ", 1)

0 commit comments

Comments
 (0)