uboot-d1: add bootloader for upcoming d1 target
[openwrt/staging/mans0n.git] / package / boot / uboot-d1 / patches / 0024-binman-Prevent-entries-in-a-section-from-overlapping.patch
1 From b7150f7dd885012868c94b29ac4fe6152c065a95 Mon Sep 17 00:00:00 2001
2 From: Samuel Holland <samuel@sholland.org>
3 Date: Sat, 9 Oct 2021 10:43:56 -0500
4 Subject: [PATCH 24/90] binman: Prevent entries in a section from overlapping
5
6 Currently, if the "offset" property is given for an entry, the section's
7 running offset is completely ignored. This causes entries to overlap if
8 the provided offset is less than the size of the entries earlier in the
9 section. Avoid the overlap by only using the provided offset when it is
10 greater than the running offset.
11
12 The motivation for this change is the rule used by SPL to find U-Boot on
13 sunxi boards: U-Boot starts 32 KiB after the start of SPL, unless SPL is
14 larger than 32 KiB, in which case U-Boot immediately follows SPL.
15
16 Signed-off-by: Samuel Holland <samuel@sholland.org>
17 ---
18 tools/binman/entry.py | 4 +++-
19 1 file changed, 3 insertions(+), 1 deletion(-)
20
21 --- a/tools/binman/entry.py
22 +++ b/tools/binman/entry.py
23 @@ -483,7 +483,9 @@ class Entry(object):
24 if self.offset_unset:
25 self.Raise('No offset set with offset-unset: should another '
26 'entry provide this correct offset?')
27 - self.offset = tools.align(offset, self.align)
28 + elif self.offset > offset:
29 + offset = self.offset
30 + self.offset = tools.align(offset, self.align)
31 needed = self.pad_before + self.contents_size + self.pad_after
32 needed = tools.align(needed, self.align_size)
33 size = self.size