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.
This commit is contained in:
Jaroslav Burian
2025-03-10 23:49:40 +01:00
committed by Radim Karniš
parent ebe8ced46d
commit 6f8ff39c9e

View File

@@ -2228,10 +2228,14 @@ def elf2image(
if elf_sha256_offset:
image.elf_sha256 = e.sha256()
image.elf_sha256_offset = elf_sha256_offset
# If ELF file contains an app_desc section, put the SHA256 digest at correct offset
elif any(".flash.appdesc" in seg.name for seg in image.segments):
image.elf_sha256 = e.sha256()
image.elf_sha256_offset = 0xB0
else:
# If ELF file contains an app_desc section and it is in flash,
# put the SHA256 digest at correct offset.
# If it is flash build, it should always be 0xB0.
appdesc_segs = [seg for seg in image.segments if ".flash.appdesc" in seg.name]
if appdesc_segs and image.is_flash_addr(appdesc_segs[0].addr):
image.elf_sha256 = e.sha256()
image.elf_sha256_offset = 0xB0
if ram_only_header:
log.print(