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.
This commit is contained in:
Tiago Medicci Serrano
2024-05-28 09:41:01 -03:00
parent e87cc3ec62
commit 5d9d5bebf5
2 changed files with 9 additions and 3 deletions

View File

@@ -496,7 +496,7 @@ def main(argv=None, esp=None):
"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,
)

View File

@@ -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)