mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-09-14 05:25:33 +00:00
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
#!/usr/bin/python3
|
|
|
|
# Adds PlatformIO post-processing to merge all the ESP flash images into a single image.
|
|
|
|
import os
|
|
|
|
Import("env")
|
|
|
|
board_config = env.BoardConfig()
|
|
firmware_bin = "${BUILD_DIR}/${PROGNAME}.bin"
|
|
merged_bin = os.environ.get("MERGED_BIN_PATH", "${BUILD_DIR}/${PROGNAME}-merged.bin")
|
|
|
|
|
|
def merge_bin_action(source, target, env):
|
|
extra_images = env.Flatten(env.get("FLASH_EXTRA_IMAGES", []))
|
|
if not extra_images:
|
|
print("Cannot merge a bootable image without the bootloader/partition "
|
|
"flash layout. Run the mergebin target without nobuild.")
|
|
return 1
|
|
flash_images = [
|
|
*extra_images,
|
|
"$ESP32_APP_OFFSET",
|
|
source[0].get_abspath(),
|
|
]
|
|
merge_cmd = " ".join(
|
|
[
|
|
'"$PYTHONEXE"',
|
|
'"$OBJCOPY"',
|
|
"--chip",
|
|
board_config.get("build.mcu", "esp32"),
|
|
"merge_bin",
|
|
"-o",
|
|
merged_bin,
|
|
"--flash_mode",
|
|
board_config.get("build.flash_mode", "dio"),
|
|
"--flash_freq",
|
|
"${__get_board_f_flash(__env__)}",
|
|
"--flash_size",
|
|
board_config.get("upload.flash_size", "4MB"),
|
|
*flash_images,
|
|
]
|
|
)
|
|
return env.Execute(merge_cmd)
|
|
|
|
|
|
env.AddCustomTarget(
|
|
name="mergebin",
|
|
dependencies=firmware_bin,
|
|
actions=merge_bin_action,
|
|
title="Merge binary",
|
|
description="Build combined image",
|
|
always_build=True,
|
|
)
|