Skip to content

Commit

Permalink
fix: Do not append SHA256 when --ram-only-header
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tmedicci committed May 29, 2024
1 parent e87cc3e commit 5d9d5be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion esptool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
10 changes: 8 additions & 2 deletions esptool/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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)
Expand Down

0 comments on commit 5d9d5be

Please sign in to comment.