forked from rtlopez/esp-fc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge_firmware.py
43 lines (37 loc) · 1.28 KB
/
merge_firmware.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Import("env")
APP_BIN = "$BUILD_DIR/${PROGNAME}.bin"
MERGED_BIN = "$BUILD_DIR/${PROGNAME}_0x00.bin"
BOARD_CONFIG = env.BoardConfig()
def merge_bin(source, target, env):
# The list contains all extra images (bootloader, partitions, eboot) and
# the final application binary
flash_images = env.Flatten(env.get("FLASH_EXTRA_IMAGES", [])) + ["$ESP32_APP_OFFSET", APP_BIN]
# Run esptool to merge images into a single binary
env.Execute(
" ".join(
[
"$PYTHONEXE",
"$OBJCOPY",
"--chip",
BOARD_CONFIG.get("build.mcu", "esp32"),
"merge_bin",
"--flash_size",
BOARD_CONFIG.get("upload.flash_size", "4MB"),
"-o",
MERGED_BIN,
]
+ flash_images
)
)
# Add a post action that runs esptoolpy to merge available flash images
env.AddPostAction(APP_BIN , merge_bin)
# Patch the upload command to flash the merged binary at address 0x0
#env.Replace(
# UPLOADERFLAGS=[
# f
# for f in env.get("UPLOADERFLAGS")
# if f not in env.Flatten(env.get("FLASH_EXTRA_IMAGES"))
# ]
# + ["0x0", MERGED_BIN],
# UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS',
#)