Skip to content

Commit d83dd3b

Browse files
committed
docs: add note about Intel Hex merging limitations
espressif#960 espressif#959
1 parent e170bcc commit d83dd3b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

docs/en/esptool/basic-commands.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ Intel Hex format offers distinct advantages when compared to the binary format,
285285
286286
esptool.py --chip {IDF_TARGET_NAME} merge_bin --format hex -o merged-flash.hex --flash_mode dio --flash_size 4MB 0x1000 bootloader.bin 0x8000 partition-table.bin 0x10000 app.bin
287287
288+
.. note::
289+
290+
Please note that during the conversion to the `Intel Hex` format, the binary input file is treated as a black box. The conversion process does not consider the actual contents of the binary file. This means that the `Intel Hex` file will contain the same data as the binary file (including the padding), but the data will be represented in a different format.
291+
When merging multiple files, the `Intel Hex` format, unlike the binary format, does not include any padding between the input files.
292+
It is recommended to merge multiple files instead of converting one already merged to get smaller merged outputs.
288293

289294
RAW Output Format
290295
^^^^^^^^^^^^^^^^^

esptool/cmds.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,13 @@ def pad_to(flash_offs):
14131413
)
14141414
elif args.format == "hex":
14151415
out = IntelHex()
1416+
if len(input_files) == 1:
1417+
print(
1418+
"WARNING: Only one input file specified, output may include "
1419+
"additional padding if input file was previously merged. "
1420+
"Please refer to the documentation for more information: "
1421+
"https://docs.espressif.com/projects/esptool/en/latest/esptool/basic-commands.html#hex-output-format" # noqa E501
1422+
)
14161423
for addr, argfile in input_files:
14171424
ihex = IntelHex()
14181425
image = argfile.read()

test/test_merge_bin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def read_image(filename):
3131

3232
@pytest.mark.host_test
3333
class TestMergeBin:
34-
def run_merge_bin(self, chip, offsets_names, options=[]):
34+
def run_merge_bin(self, chip, offsets_names, options=[], allow_warnings=False):
3535
"""Run merge_bin on a list of (offset, filename) tuples
3636
with output to a named temporary file.
3737
@@ -62,9 +62,10 @@ def run_merge_bin(self, chip, offsets_names, options=[]):
6262
)
6363
output = output.decode("utf-8")
6464
print(output)
65-
assert (
66-
"warning" not in output.lower()
67-
), "merge_bin should not output warnings"
65+
if not allow_warnings:
66+
assert (
67+
"warning" not in output.lower()
68+
), "merge_bin should not output warnings"
6869

6970
with open(output_file.name, "rb") as f:
7071
return f.read()
@@ -203,6 +204,7 @@ def test_merge_mixed(self):
203204
"esp32",
204205
[(0x1000, "bootloader_esp32.bin")],
205206
options=["--format", "hex"],
207+
allow_warnings=True,
206208
)
207209
# create a temp file with hex content
208210
with tempfile.NamedTemporaryFile(suffix=".hex", delete=False) as f:
@@ -233,6 +235,7 @@ def test_merge_bin2hex(self):
233235
(0x1000, "bootloader_esp32.bin"),
234236
],
235237
options=["--format", "hex"],
238+
allow_warnings=True,
236239
)
237240
lines = merged.splitlines()
238241
# hex format - :0300300002337A1E

0 commit comments

Comments
 (0)