summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-26 17:40:09 -0600
committerSimon Glass <sjg@chromium.org>2020-10-29 14:42:59 -0600
commitf90d906a275f85e7077d9a30ab82b20676b54645 (patch)
treeecce3b12a7a78d5ebcd90223e330719f9c2f6872
parentef439ed191a0655a86f5b4035cec9cc57e97d8b1 (diff)
downloadu-boot-f90d906a275f85e7077d9a30ab82b20676b54645.tar.gz
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>
-rw-r--r--tools/binman/README12
-rw-r--r--tools/binman/entry.py11
-rw-r--r--tools/binman/ftest.py29
3 files changed, 45 insertions, 7 deletions
diff --git a/tools/binman/README b/tools/binman/README
index fbcfdc77c3..0433cabce4 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -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
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 173c9131cb..e5d0aa52bd 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -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
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 481b8fd03c..35c1420681 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -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 = {