diff options
-rw-r--r-- | tools/binman/entries.rst | 13 | ||||
-rw-r--r-- | tools/binman/entry.py | 5 | ||||
-rw-r--r-- | tools/binman/etype/null.py | 25 | ||||
-rw-r--r-- | tools/binman/etype/section.py | 6 | ||||
-rw-r--r-- | tools/binman/ftest.py | 5 | ||||
-rw-r--r-- | tools/binman/test/268_null.dts | 19 |
6 files changed, 71 insertions, 2 deletions
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index f6cc800385..2b32c131ed 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -1278,6 +1278,19 @@ This will pass in u-boot-spl as the input data and the .cfgout file as the +.. _etype_null: + +Entry: null: An entry which has no contents of its own +------------------------------------------------------ + +Note that the size property must be set since otherwise this entry does not +know how large it should be. + +The contents are set by the containing section, e.g. the section's pad +byte. + + + .. _etype_opensbi: Entry: opensbi: RISC-V OpenSBI fw_dynamic blob diff --git a/tools/binman/entry.py b/tools/binman/entry.py index f99618d453..e6ff026ddb 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -454,7 +454,7 @@ class Entry(object): Returns: True if the contents were found, False if another call is needed - after the other entries are processed. + after the other entries are processed, None if there is no contents """ # No contents by default: subclasses can implement this return True @@ -583,7 +583,8 @@ class Entry(object): Returns: bytes content of the entry, excluding any padding. If the entry is compressed, the compressed data is returned. If the entry data - is not yet available, False can be returned + is not yet available, False can be returned. If the entry data + is null, then None is returned. """ self.Detail('GetData: size %s' % to_hex_size(self.data)) return self.data diff --git a/tools/binman/etype/null.py b/tools/binman/etype/null.py new file mode 100644 index 0000000000..c10d482447 --- /dev/null +++ b/tools/binman/etype/null.py @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2023 Google LLC +# Written by Simon Glass <sjg@chromium.org> +# + +from binman.entry import Entry +from dtoc import fdt_util +from patman import tools + +class Entry_null(Entry): + """An entry which has no contents of its own + + Note that the size property must be set since otherwise this entry does not + know how large it should be. + + The contents are set by the containing section, e.g. the section's pad + byte. + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node) + self.required_props = ['size'] + + def ObtainContents(self): + # null contents + return None diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index 85474f2411..28f04cb84a 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -320,6 +320,12 @@ class Entry_section(Entry): # earlier in the image description. See testCollectionSection(). if not required and entry_data is None: return None + + if entry_data is None: + pad_byte = (entry._pad_byte if isinstance(entry, Entry_section) + else self._pad_byte) + entry_data = tools.get_bytes(self._pad_byte, entry.size) + data = self.GetPaddedDataForEntry(entry, entry_data) # Handle empty space before the entry pad = (entry.offset or 0) - self._skip_at_start - len(section_data) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index a4f78ae041..ac9b050fb6 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6194,6 +6194,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap expected = U_BOOT_DATA + tools.get_bytes(0, 12) self.assertEqual(expected, data) + def testNull(self): + """Test an image with a null entry""" + data = self._DoReadFile('268_null.dts') + self.assertEqual(U_BOOT_DATA + b'\xff\xff\xff\xff' + U_BOOT_IMG_DATA, data) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/268_null.dts b/tools/binman/test/268_null.dts new file mode 100644 index 0000000000..3824ba8509 --- /dev/null +++ b/tools/binman/test/268_null.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + pad-byte = <0xff>; + u-boot { + }; + null { + size = <4>; + }; + u-boot-img { + }; + }; +}; |