Skip to content

Commit

Permalink
remove(make_image): Remove the make_image command in favor of other w…
Browse files Browse the repository at this point in the history
…orkflows

BREAKING CHANGE
  • Loading branch information
radimkarnis committed Mar 2, 2025
1 parent 8016455 commit 955a7c8
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 124 deletions.
17 changes: 0 additions & 17 deletions docs/en/esptool/advanced-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,6 @@ This will read 4 bytes from SFDP address 16.

esptool.py chip_id

.. _make-image:

Assemble a Firmware Image: ``make_image``
-----------------------------------------

``make_image`` allows you to manually assemble a firmware image from binary segments (such as those extracted from objcopy). For example:

::

esptool.py --chip esp8266 make_image -f app.text.bin -a 0x40100000 -f app.data.bin -a 0x3ffe8000 -f app.rodata.bin -a 0x3ffe8c00 app.flash.bin

This command does not require a serial connection.

.. note::

In general, it is better to create an ELF image (including any binary data as part of the ELF, by using objcopy or other tools) and then use ``elf2image`` to generate the ``.bin`` file.

.. _run:

Boot Application Code: ``run``
Expand Down
1 change: 0 additions & 1 deletion docs/en/esptool/basic-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,4 @@ The following commands are less commonly used, or only of interest to advanced u
* :ref:`write-flash-status`
* :ref:`read-flash-sfdp`
:esp8266: * :ref:`chip-id`
:esp8266: * :ref:`make-image`
:esp8266: * :ref:`run`
2 changes: 0 additions & 2 deletions docs/en/esptool/scripting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ The following commands can run without the need for a connected chip:

.. autofunction:: esptool.cmds.image_info

.. autofunction:: esptool.cmds.make_image

------------

Utility Functions
Expand Down
9 changes: 9 additions & 0 deletions docs/en/migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,12 @@ The ``--ignore-flash-encryption-efuse-setting`` option of the :ref:`write_flash
**Migration Steps:**

1. Rename the ``--ignore-flash-encryption-efuse-setting`` to ``--ignore-flash-enc-efuse`` in any existing ``write_flash`` commands in scripts/CI pipelines.

``make_image`` Command Removal
******************************

The ``make_image`` command for the ESP8266 has been **removed in v5**. This command has been deprecated in favor of using **objcopy** (or other tools) to generate ELF images and then using ``elf2image`` to create the final ``.bin`` file.

**Migration Steps:**

1. Replace any ``make_image`` workflows with the recommended way of assembling firmware images using **objcopy** and ``elf2image``.
23 changes: 0 additions & 23 deletions esptool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"get_security_info",
"image_info",
"load_ram",
"make_image",
"merge_bin",
"read_flash",
"read_flash_status",
Expand Down Expand Up @@ -55,7 +54,6 @@
get_security_info,
image_info,
load_ram,
make_image,
merge_bin,
read_flash,
read_flash_status,
Expand Down Expand Up @@ -168,7 +166,6 @@
"write_flash_status",
"read_flash_sfdp",
"chip_id",
"make_image",
"run",
"get_security_info",
],
Expand Down Expand Up @@ -633,26 +630,6 @@ def image_info_cli(ctx, filename):
image_info(filename, ctx.obj["chip"])


@cli.command("make_image")
@click.argument("output", type=click.Path())
@click.option(
"--segfile",
"-f",
multiple=True,
type=click.Path(exists=True),
help="Segment input file",
)
@click.option(
"--segaddr", "-a", multiple=True, type=AnyIntType(), help="Segment base address"
)
@click.option(
"--entrypoint", "-e", type=AnyIntType(), default=0, help="Address of entry point"
)
def make_image_cli(output, segfile, segaddr, entrypoint):
"""Create an application image from binary files"""
make_image(segfile, segaddr, output, entrypoint)


@cli.command("elf2image")
@click.argument("input", type=click.Path(exists=True))
@click.option(
Expand Down
49 changes: 1 addition & 48 deletions esptool/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from serial import SerialException
from typing import BinaryIO

from .bin_image import ELFFile, ImageSegment, LoadFirmwareImage
from .bin_image import ELFFile, LoadFirmwareImage
from .bin_image import (
ESP8266ROMFirmwareImage,
ESP8266V2FirmwareImage,
Expand Down Expand Up @@ -1911,53 +1911,6 @@ def get_key_from_value(dict, val):
log.print(f"Compile time: {bootloader_desc['date_time']}")


def make_image(
segfile: list[str],
segaddr: list[int],
output: str | None = None,
entrypoint: int = 0,
) -> bytes | None:
"""
Assemble an ESP8266 firmware image using binary segments. ESP8266-only.
Args:
segfile: List of file paths containing binary segment data.
segaddr: List of memory addresses corresponding to each segment.
output: Path to save the output firmware image file.
If None, the function returns the image as bytes.
entrypoint: Entry point address for the firmware.
Returns:
None if output is provided; otherwise, returns the assembled
firmware image as bytes.
"""
log.print("Creating ESP8266 image...")
image = ESP8266ROMFirmwareImage()
if len(segfile) == 0:
raise FatalError("No segments specified")
if len(segfile) != len(segaddr):
raise FatalError(
"Number of specified files does not match the number of specified addresses"
)
for seg, addr in zip(segfile, segaddr):
with open(seg, "rb") as f:
data = f.read()
image.segments.append(ImageSegment(addr, data))
image.entrypoint = entrypoint
if output is not None:
# Save image to the provided file path.
image.save(output)
log.print("Successfully created ESP8266 image.")
return None
else:
# Save image to a BytesIO buffer and return the bytes.
buf = io.BytesIO()
image.save(buf)
result = buf.getvalue()
log.print("Successfully created ESP8266 image.")
return result


def merge_bin(
addr_filename: list[tuple[int, BinaryIO]],
output: str,
Expand Down
33 changes: 0 additions & 33 deletions test/test_esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1533,39 +1533,6 @@ def test_read_get_chip_features(self):
esp._port.close()


@pytest.mark.skipif(
arg_chip != "esp8266", reason="Make image option is supported only on ESP8266"
)
class TestMakeImage(EsptoolTestCase):
def verify_image(self, offset, length, image, compare_to):
with open(image, "rb") as f:
f.seek(offset)
rb = f.read(length)
with open(compare_to, "rb") as f:
ct = f.read()
if len(rb) != len(ct):
print(
f"WARNING: Expected length {len(ct)} doesn't match comparison {len(rb)}"
)
print(f"Readback {len(rb)} bytes")
self.diff(rb, ct)

def test_make_image(self):
output = self.run_esptool(
"make_image test"
" -a 0x0 -f images/sector.bin -a 0x1000 -f images/fifty_kb.bin"
)
try:
assert "Successfully created ESP8266 image." in output
assert os.path.exists("test0x00000.bin")
self.verify_image(16, 4096, "test0x00000.bin", "images/sector.bin")
self.verify_image(
4096 + 24, 50 * 1024, "test0x00000.bin", "images/fifty_kb.bin"
)
finally:
os.remove("test0x00000.bin")


@pytest.mark.skipif(
"ESPTOOL_TEST_USB_OTG" in os.environ or arg_preload_port is not False,
reason="Boot mode strapping pin pulled constantly low, "
Expand Down

0 comments on commit 955a7c8

Please sign in to comment.