Skip to content

Commit

Permalink
fix: ram_only_header: pad flash segment to next boundary
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sylvioalves authored and radimkarnis committed May 22, 2024
1 parent 4c5874a commit 4394a65
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions esptool/bin_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4394a65

Please sign in to comment.