mirror of
https://github.com/espressif/esptool.git
synced 2025-10-15 21:07:25 +08:00
remove(make_image): Remove the make_image command in favor of other workflows
BREAKING CHANGE
This commit is contained in:
@@ -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``
|
||||
|
@@ -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`
|
||||
|
@@ -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
|
||||
|
@@ -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``.
|
||||
|
@@ -15,7 +15,6 @@ __all__ = [
|
||||
"get_security_info",
|
||||
"image_info",
|
||||
"load_ram",
|
||||
"make_image",
|
||||
"merge_bin",
|
||||
"read_flash",
|
||||
"read_flash_status",
|
||||
@@ -55,7 +54,6 @@ from esptool.cmds import (
|
||||
get_security_info,
|
||||
image_info,
|
||||
load_ram,
|
||||
make_image,
|
||||
merge_bin,
|
||||
read_flash,
|
||||
read_flash_status,
|
||||
@@ -168,7 +166,6 @@ click.rich_click.COMMAND_GROUPS = {
|
||||
"write_flash_status",
|
||||
"read_flash_sfdp",
|
||||
"chip_id",
|
||||
"make_image",
|
||||
"run",
|
||||
"get_security_info",
|
||||
],
|
||||
@@ -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(
|
||||
|
@@ -16,7 +16,7 @@ from intelhex import IntelHex
|
||||
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,
|
||||
@@ -1911,53 +1911,6 @@ def image_info(filename: str, chip: str = "auto") -> None:
|
||||
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,
|
||||
|
@@ -1533,39 +1533,6 @@ class TestReadWriteMemory(EsptoolTestCase):
|
||||
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, "
|
||||
|
Reference in New Issue
Block a user