Skip to content

Commit

Permalink
check FW bin file size when creating factory.bin
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Jun 1, 2024
1 parent c22ae2b commit 90aafe2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pio-scripts/create_factory_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
platform = env.PioPlatform()

import sys
from os.path import join
from os.path import join, getsize

sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
import esptool
Expand Down Expand Up @@ -60,6 +60,14 @@ def esp32_create_combined_bin(source, target, env):
flash_size,
]

# platformio estimates the amount of flash used to store the firmware. this
# estimate is not accurate. we perform a final check on the firmware bin
# size by comparing it against the respective partition size.
max_size = env.BoardConfig().get("upload.maximum_size", 1)
fw_size = getsize(firmware_name)
if (fw_size > max_size):
raise Exception("firmware binary too large: %d > %d" % (fw_size, max_size))

print(" Offset | File")
for section in sections:
sect_adr, sect_file = section.split(" ", 1)
Expand Down

0 comments on commit 90aafe2

Please sign in to comment.