Skip to content

Commit 32ee6f2

Browse files
committed
Save merged binary under build
1 parent 88daaac commit 32ee6f2

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ node_modules
1111
/releases
1212
/src/certs
1313
/temp
14-
/build/firmware
15-
/build/elf
14+
/build
1615
/lib/framework/WWWData.h
1716
*WWWData.h
1817
lib/framework/WWWData.h

docs/buildprocess.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ The static files for the website are build using vite. By default vite adds a un
174174

175175
## Merged Firmware File for Web Flasher
176176

177-
The PIO build system calls a script `merge_bin.py` to create a merged firmware binary ready to be used with [ESP Web Tools](https://esphome.github.io/esp-web-tools/). The file is located under the PIO build folder. Typically `.pio/build/{env}/firmware_merged.bin`.
177+
The PIO build system calls a script `merge_bin.py` to create a merged firmware binary ready to be used with [ESP Web Tools](https://esphome.github.io/esp-web-tools/). The file is located under the PIO build folder. Typically `build/merged/{APP_NAME}_{$PIOENV}_{APP_VERSION}.bin`.

scripts/merge_bin.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
import os
2+
import re
13
Import("env")
24

35
APP_BIN = "$BUILD_DIR/${PROGNAME}.bin"
4-
MERGED_BIN = "$BUILD_DIR/firmware_merged.bin"
6+
OUTPUT_DIR = "$PROJECT_DIR{}build{}merged{}".format(os.path.sep, os.path.sep, os.path.sep)
7+
58
BOARD_CONFIG = env.BoardConfig()
69

10+
def readFlag(flag):
11+
buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
12+
# print(buildFlags.get("CPPDEFINES"))
13+
for define in buildFlags.get("CPPDEFINES"):
14+
if (define == flag or (isinstance(define, list) and define[0] == flag)):
15+
# print("Found "+flag+" = "+define[1])
16+
# strip quotes ("") from define[1]
17+
cleanedFlag = re.sub(r'^"|"$', '', define[1])
18+
return cleanedFlag
19+
return None
20+
721

822
def merge_bin(source, target, env):
923
# The list contains all extra images (bootloader, partitions, eboot) and
@@ -21,6 +35,8 @@ def merge_bin(source, target, env):
2135
if memory_type == "opi_opi" or memory_type == "opi_qspi":
2236
flash_mode = "dout"
2337

38+
MERGED_BIN = "{}{}_{}_{}.bin".format(OUTPUT_DIR, readFlag("APP_NAME"), env.get('PIOENV'), readFlag("APP_VERSION").replace(".", "-"))
39+
2440
# Run esptool to merge images into a single binary
2541
env.Execute(
2642
" ".join(

0 commit comments

Comments
 (0)