fix(elf2image): Print correct MMU page size in error message

This commit is contained in:
Jaroslav Burian
2025-02-06 10:49:57 +01:00
parent 74d27ae253
commit 447de60158

View File

@@ -606,7 +606,7 @@ class ESP32FirmwareImage(BaseFirmwareImage):
"""ESP32 firmware image is very similar to V1 ESP8266 image, """ESP32 firmware image is very similar to V1 ESP8266 image,
except with an additional 16 byte reserved header at top of image, except with an additional 16 byte reserved header at top of image,
and because of new flash mapping capabilities the flash-mapped regions and because of new flash mapping capabilities the flash-mapped regions
can be placed in the normal image (just @ 64kB padded offsets). can be placed in the normal image (just @ MMU page size padded offsets).
""" """
ROM_LOADER = ESP32ROM ROM_LOADER = ESP32ROM
@@ -730,10 +730,9 @@ class ESP32FirmwareImage(BaseFirmwareImage):
for segment in flash_segments[1:]: for segment in flash_segments[1:]:
if segment.addr // self.IROM_ALIGN == last_addr // self.IROM_ALIGN: if segment.addr // self.IROM_ALIGN == last_addr // self.IROM_ALIGN:
raise FatalError( raise FatalError(
"Segment loaded at 0x%08x lands in same 64KB flash mapping " f"Segment loaded at {segment.addr:#010x} lands in same {self.IROM_ALIGN // 1024} KB flash mapping "
"as segment loaded at 0x%08x. Can't generate binary. " f"as segment loaded at {last_addr:#010x}. Can't generate binary. "
"Suggest changing linker script or ELF to merge sections." "Suggest changing linker script or ELF to merge sections."
% (segment.addr, last_addr)
) )
last_addr = segment.addr last_addr = segment.addr
@@ -795,7 +794,7 @@ class ESP32FirmwareImage(BaseFirmwareImage):
self.save_flash_segment(f, segment) self.save_flash_segment(f, segment)
total_segments += 1 total_segments += 1
else: # not self.ram_only_header else: # not self.ram_only_header
# try to fit each flash segment on a 64kB aligned boundary # try to fit each flash segment on a MMU page size aligned boundary
# by padding with parts of the non-flash segments... # by padding with parts of the non-flash segments...
while len(flash_segments) > 0: while len(flash_segments) > 0:
segment = flash_segments[0] segment = flash_segments[0]
@@ -826,7 +825,7 @@ class ESP32FirmwareImage(BaseFirmwareImage):
total_segments += 1 total_segments += 1
if self.secure_pad: if self.secure_pad:
# pad the image so that after signing it will end on a a 64KB boundary. # pad the image so that after signing it will end on a a MMU page size boundary.
# This ensures all mapped flash content will be verified. # This ensures all mapped flash content will be verified.
if not self.append_digest: if not self.append_digest:
raise FatalError( raise FatalError(
@@ -845,7 +844,7 @@ class ESP32FirmwareImage(BaseFirmwareImage):
elif self.secure_pad == "2": # Secure Boot V2 elif self.secure_pad == "2": # Secure Boot V2
# after checksum: SHA-256 digest + # after checksum: SHA-256 digest +
# signature sector, # signature sector,
# but we place signature sector after the 64KB boundary # but we place signature sector after the MMU page size boundary
space_after_checksum = 32 space_after_checksum = 32
pad_len = ( pad_len = (
self.IROM_ALIGN - align_past - checksum_space - space_after_checksum self.IROM_ALIGN - align_past - checksum_space - space_after_checksum
@@ -986,14 +985,13 @@ class ESP8266V3FirmwareImage(ESP32FirmwareImage):
for segment in flash_segments[1:]: for segment in flash_segments[1:]:
if segment.addr // self.IROM_ALIGN == last_addr // self.IROM_ALIGN: if segment.addr // self.IROM_ALIGN == last_addr // self.IROM_ALIGN:
raise FatalError( raise FatalError(
"Segment loaded at 0x%08x lands in same 64KB flash mapping " f"Segment loaded at {segment.addr:#010x} lands in same {self.IROM_ALIGN // 1024} KB flash mapping "
"as segment loaded at 0x%08x. Can't generate binary. " f"as segment loaded at {last_addr:#010x}. Can't generate binary. "
"Suggest changing linker script or ELF to merge sections." "Suggest changing linker script or ELF to merge sections."
% (segment.addr, last_addr)
) )
last_addr = segment.addr last_addr = segment.addr
# try to fit each flash segment on a 64kB aligned boundary # try to fit each flash segment on a MMU page size aligned boundary
# by padding with parts of the non-flash segments... # by padding with parts of the non-flash segments...
while len(flash_segments) > 0: while len(flash_segments) > 0:
segment = flash_segments[0] segment = flash_segments[0]