mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-11 07:34:31 +00:00
binman: Respect pad-before property of section subentries
Other relevant properties (pad-after, offset, size, align, align-size, align-end) already work since Pack() sets correct ranges for subentries' data (.offset, .size variables), but some padding here is necessary to align the data within this range to match the pad-before property. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
8001d0b162
commit
3fdeb14d95
3 changed files with 35 additions and 1 deletions
|
@ -152,7 +152,7 @@ class Entry_section(Entry):
|
||||||
for entry in self._entries.values():
|
for entry in self._entries.values():
|
||||||
data = entry.GetData()
|
data = entry.GetData()
|
||||||
base = self.pad_before + (entry.offset or 0) - self._skip_at_start
|
base = self.pad_before + (entry.offset or 0) - self._skip_at_start
|
||||||
pad = base - len(section_data)
|
pad = base - len(section_data) + (entry.pad_before or 0)
|
||||||
if pad > 0:
|
if pad > 0:
|
||||||
section_data += tools.GetBytes(self._pad_byte, pad)
|
section_data += tools.GetBytes(self._pad_byte, pad)
|
||||||
section_data += data
|
section_data += data
|
||||||
|
|
|
@ -3483,5 +3483,13 @@ class TestFunctional(unittest.TestCase):
|
||||||
expected = (U_BOOT_DATA + U_BOOT_DATA)
|
expected = (U_BOOT_DATA + U_BOOT_DATA)
|
||||||
self.assertEqual(expected, data)
|
self.assertEqual(expected, data)
|
||||||
|
|
||||||
|
def testPadInSections(self):
|
||||||
|
"""Test pad-before, pad-after for entries in sections"""
|
||||||
|
data = self._DoReadFile('166_pad_in_sections.dts')
|
||||||
|
expected = (U_BOOT_DATA + tools.GetBytes(ord('!'), 12) +
|
||||||
|
U_BOOT_DATA + tools.GetBytes(ord('!'), 6) +
|
||||||
|
U_BOOT_DATA)
|
||||||
|
self.assertEqual(expected, data)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
26
tools/binman/test/166_pad_in_sections.dts
Normal file
26
tools/binman/test/166_pad_in_sections.dts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
binman {
|
||||||
|
pad-byte = <0x26>;
|
||||||
|
section {
|
||||||
|
pad-byte = <0x21>;
|
||||||
|
|
||||||
|
before {
|
||||||
|
type = "u-boot";
|
||||||
|
};
|
||||||
|
u-boot {
|
||||||
|
pad-before = <12>;
|
||||||
|
pad-after = <6>;
|
||||||
|
};
|
||||||
|
after {
|
||||||
|
type = "u-boot";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in a new issue