aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-11 16:10:14 -0700
committerSimon Glass <sjg@chromium.org>2023-01-18 14:55:40 -0700
commit62ef2f7bf3c442b6f717d2fbe823d579cf090dd8 (patch)
tree1a6739488ca8170a0bcd56d0f5ecbc05c66c0773
parent4331d66661566cd823086204636754f785bd5d45 (diff)
downloadu-boot-62ef2f7bf3c442b6f717d2fbe823d579cf090dd8.zip
u-boot-62ef2f7bf3c442b6f717d2fbe823d579cf090dd8.tar.gz
u-boot-62ef2f7bf3c442b6f717d2fbe823d579cf090dd8.tar.bz2
binman: Add a null entry
It is sometimes useful to define an entry which does not have its own contents but does appear in the image. The contents are set by the section which contains it, even though it appears as an entry in the fdtmap. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/binman/entries.rst13
-rw-r--r--tools/binman/entry.py5
-rw-r--r--tools/binman/etype/null.py25
-rw-r--r--tools/binman/etype/section.py6
-rw-r--r--tools/binman/ftest.py5
-rw-r--r--tools/binman/test/268_null.dts19
6 files changed, 71 insertions, 2 deletions
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index f6cc800..2b32c13 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 f99618d..e6ff026 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 0000000..c10d482
--- /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 85474f2..28f04cb 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 a4f78ae..ac9b050 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 0000000..3824ba8
--- /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 {
+ };
+ };
+};