From 5d9d5bebf583e1335ffca9aca181d1dcd7ba2acd Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Tue, 28 May 2024 09:41:01 -0300 Subject: [PATCH] fix: Do not append SHA256 when `--ram-only-header` When called with `--ram-only-header`, the ROM segments are hidden. In this case, the end of the first two visible segments (in RAM) is not the end of the image and is not suitable for appending the SHA256 digest. --- esptool/__init__.py | 2 +- esptool/cmds.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/esptool/__init__.py b/esptool/__init__.py index 252f34ace..bc4d102c7 100644 --- a/esptool/__init__.py +++ b/esptool/__init__.py @@ -496,7 +496,7 @@ def add_spi_flash_subparsers( "quantity. This will make the other segments invisible to the ROM " "loader. Use this argument with care because the ROM loader will load " "only the RAM segments although the other segments being present in " - "the output.", + "the output. Implies --dont-append-digest", action="store_true", default=None, ) diff --git a/esptool/cmds.py b/esptool/cmds.py index b7b483894..4d9975ea4 100644 --- a/esptool/cmds.py +++ b/esptool/cmds.py @@ -1050,7 +1050,10 @@ def elf2image(args): image.min_rev_full = args.min_rev_full image.max_rev_full = args.max_rev_full image.ram_only_header = args.ram_only_header - image.append_digest = args.append_digest + if image.ram_only_header: + image.append_digest = False + else: + image.append_digest = args.append_digest elif args.version == "1": # ESP8266 image = ESP8266ROMFirmwareImage() elif args.version == "2": @@ -1075,7 +1078,10 @@ def elf2image(args): image.elf_sha256_offset = args.elf_sha256_offset if args.ram_only_header: - print("ROM segments hidden - only RAM segments are visible to the ROM loader!") + print( + "Image has only RAM segments visible. " + "ROM segments are hidden and SHA256 digest is not appended." + ) image.sort_segments() before = len(image.segments)