From 4394a658c40b73cc6d593797a42b665e68f84cf7 Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Sun, 19 May 2024 12:36:56 +0200 Subject: [PATCH] fix: ram_only_header: pad flash segment to next boundary When flash segment does not fit minimum alignment requirement, pad it to next alignment boundary so that the flash placement fits properly. Otherwise ELF won't be created due to wrong alignment. Signed-off-by: Sylvio Alves --- esptool/bin_image.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esptool/bin_image.py b/esptool/bin_image.py index 98b8b365c..082f4fb01 100644 --- a/esptool/bin_image.py +++ b/esptool/bin_image.py @@ -760,8 +760,10 @@ def get_alignment_data_needed(segment): self.ROM_LOADER.BOOTLOADER_FLASH_OFFSET - self.SEG_HEADER_LEN ) if pad_len < align_min: - print("Unable to align the segment!") - break + # in case pad_len does not fit minimum alignment, + # pad it to next aligned boundary + pad_len += self.IROM_ALIGN + pad_len -= self.ROM_LOADER.BOOTLOADER_FLASH_OFFSET pad_segment = ImageSegment(0, b"\x00" * pad_len, f.tell()) self.save_segment(f, pad_segment)