Skip to content

Commit 9fd7b7a

Browse files
committed
fix(elf2image): fix elf2image for ram app when sha256 offset not specified
This commit fixes issue where elf2image fails to generate image for ram app when sha256 offset is not specified. This commit adds a check to verify if the app description segment is in the flash region and if not it will not add the sha256 offset to the image header.
1 parent 5520963 commit 9fd7b7a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

esptool/cmds.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,14 @@ def elf2image(args):
11641164
if args.elf_sha256_offset:
11651165
image.elf_sha256 = e.sha256()
11661166
image.elf_sha256_offset = args.elf_sha256_offset
1167-
# If the ELF file contains an app_desc section, put the SHA256 digest at the correct offset
1168-
elif any(".flash.appdesc" in seg.name for seg in image.segments):
1169-
image.elf_sha256 = e.sha256()
1170-
image.elf_sha256_offset = 0xB0
1167+
else:
1168+
# If ELF file contains an app_desc section and it is in flash,
1169+
# put the SHA256 digest at correct offset.
1170+
# If it is flash build, it should always be 0xB0.
1171+
appdesc_segs = [seg for seg in image.segments if ".flash.appdesc" in seg.name]
1172+
if appdesc_segs and image.is_flash_addr(appdesc_segs[0].addr):
1173+
image.elf_sha256 = e.sha256()
1174+
image.elf_sha256_offset = 0xB0
11711175

11721176
if args.ram_only_header:
11731177
print(

0 commit comments

Comments
 (0)