binman: Expand docs and test for padding

Padding becomes part of the entry once the image is written out, but
within binman the entry contents does not include the padding. Add
documentation to make this clear, as well as a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2020-10-26 17:40:09 -06:00
parent ef439ed191
commit f90d906a27
3 changed files with 45 additions and 7 deletions

View File

@ -290,14 +290,20 @@ size:
pad-before:
Padding before the contents of the entry. Normally this is 0, meaning
that the contents start at the beginning of the entry. This can be
offset the entry contents a little. Defaults to 0.
that the contents start at the beginning of the entry. This can be used
to offset the entry contents a little. While this does not affect the
contents of the entry within binman itself (the padding is performed
only when its parent section is assembled), the end result will be that
the entry starts with the padding bytes, so may grow. Defaults to 0.
pad-after:
Padding after the contents of the entry. Normally this is 0, meaning
that the entry ends at the last byte of content (unless adjusted by
other properties). This allows room to be created in the image for
this entry to expand later. Defaults to 0.
this entry to expand later. While this does not affect the contents of
the entry within binman itself (the padding is performed only when its
parent section is assembled), the end result will be that the entry ends
with the padding bytes, so may grow. Defaults to 0.
align-size:
This sets the alignment of the entry size. For example, to ensure

View File

@ -51,9 +51,14 @@ class Entry(object):
align: Entry start offset alignment, or None
align_size: Entry size alignment, or None
align_end: Entry end offset alignment, or None
pad_before: Number of pad bytes before the contents, 0 if none
pad_after: Number of pad bytes after the contents, 0 if none
data: Contents of entry (string of bytes)
pad_before: Number of pad bytes before the contents when it is placed
in the containing section, 0 if none. The pad bytes become part of
the entry.
pad_after: Number of pad bytes after the contents when it is placed in
the containing section, 0 if none. The pad bytes become part of
the entry.
data: Contents of entry (string of bytes). This does not include
padding created by pad_before or pad_after
compress: Compression algoithm used (e.g. 'lz4'), 'none' if none
orig_offset: Original offset value read from node
orig_size: Original size value read from node

View File

@ -3548,12 +3548,39 @@ class TestFunctional(unittest.TestCase):
def testPadInSections(self):
"""Test pad-before, pad-after for entries in sections"""
data = self._DoReadFile('166_pad_in_sections.dts')
data, _, _, out_dtb_fname = self._DoReadFileDtb(
'166_pad_in_sections.dts', update_dtb=True)
expected = (U_BOOT_DATA + tools.GetBytes(ord('!'), 12) +
U_BOOT_DATA + tools.GetBytes(ord('!'), 6) +
U_BOOT_DATA)
self.assertEqual(expected, data)
dtb = fdt.Fdt(out_dtb_fname)
dtb.Scan()
props = self._GetPropTree(dtb, ['size', 'image-pos', 'offset'])
expected = {
'image-pos': 0,
'offset': 0,
'size': 12 + 6 + 3 * len(U_BOOT_DATA),
'section:image-pos': 0,
'section:offset': 0,
'section:size': 12 + 6 + 3 * len(U_BOOT_DATA),
'section/before:image-pos': 0,
'section/before:offset': 0,
'section/before:size': len(U_BOOT_DATA),
'section/u-boot:image-pos': 4,
'section/u-boot:offset': 4,
'section/u-boot:size': 12 + len(U_BOOT_DATA) + 6,
'section/after:image-pos': 26,
'section/after:offset': 26,
'section/after:size': len(U_BOOT_DATA),
}
self.assertEqual(expected, props)
def testFitImageSubentryAlignment(self):
"""Test relative alignability of FIT image subentries"""
entry_args = {