It is useful to be able to quickly locate the FDT map in the image. An
easy way to do this is with a pointer at the start or end of the image.
Add an 'image header' entry, which places a magic number followed by a
pointer to the FDT map. This can be located at the start or end of the
image, or at a chosen location.
As part of this, update GetSiblingImagePos() to detect missing siblings.
Signed-off-by: Simon Glass
---
Changes in v2:
- Update test to use _DoReadFileRealDtb() helper
tools/binman/README | 5 +-
tools/binman/README.entries | 19 +
tools/binman/entry.py| 11 +++
tools/binman/etype/image_header.py | 76
tools/binman/ftest.py| 47 +++-
tools/binman/test/116_fdtmap_hdr.dts | 17 +
tools/binman/test/117_fdtmap_hdr_start.dts | 19 +
tools/binman/test/118_fdtmap_hdr_pos.dts | 19 +
tools/binman/test/119_fdtmap_hdr_missing.dts | 16 +
tools/binman/test/120_hdr_no_location.dts| 16 +
10 files changed, 242 insertions(+), 3 deletions(-)
create mode 100644 tools/binman/etype/image_header.py
create mode 100644 tools/binman/test/116_fdtmap_hdr.dts
create mode 100644 tools/binman/test/117_fdtmap_hdr_start.dts
create mode 100644 tools/binman/test/118_fdtmap_hdr_pos.dts
create mode 100644 tools/binman/test/119_fdtmap_hdr_missing.dts
create mode 100644 tools/binman/test/120_hdr_no_location.dts
diff --git a/tools/binman/README b/tools/binman/README
index 8a5f3320dcb..ef62d1f1ec7 100644
--- a/tools/binman/README
+++ b/tools/binman/README
@@ -640,7 +640,9 @@ of each entry.
Alternatively, an FDT map entry can be used to add a special FDT containing
just the information about the image. This is preceded by a magic string so can
-be located anywhere in the image.
+be located anywhere in the image. An image header (typically at the start or
end
+of the image) can be used to point to the FDT map. See fdtmap and image-header
+entries for more information.
Compression
@@ -817,7 +819,6 @@ Some ideas:
- Add an option to decode an image into the constituent binaries
- Support building an image for a board (-b) more completely, with a
configurable build directory
-- Support putting the FDT in an image with a suitable magic number
- Support listing files in images
- Support logging of binman's operations, with different levels of verbosity
- Support updating binaries in an image (with no size change / repacking)
diff --git a/tools/binman/README.entries b/tools/binman/README.entries
index 7014d36f5ff..598d8278a70 100644
--- a/tools/binman/README.entries
+++ b/tools/binman/README.entries
@@ -331,6 +331,25 @@ README.chromium for how to obtain the required keys and
tools.
+Entry: image-header: An entry which contains a pointer to the FDT map
+-
+
+Properties / Entry arguments:
+location: Location of header ("start" or "end" of image). This is
+optional. If omitted then the entry must have an offset property.
+
+This adds an 8-byte entry to the start or end of the image, pointing to the
+location of the FDT map. The format is a magic number followed by an offset
+from the start or end of the image, in twos-compliment format.
+
+This entry must be in the top-level part of the image.
+
+NOTE: If the location is at the start/end, you will probably need to specify
+sort-by-offset for the image, unless you actually put the image header
+first/last in the entry list.
+
+
+
Entry: intel-cmc: Entry containing an Intel Chipset Micro Code (CMC) file
-
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 7356c49c626..e1cd0d3a882 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -561,3 +561,14 @@ features to produce new behaviours.
else False
"""
return name in self.section.GetEntries()
+
+def GetSiblingImagePos(self, name):
+"""Return the image position of the given sibling
+
+Returns:
+Image position of sibling, or None if the sibling has no position,
+or False if there is no such sibling
+"""
+if not self.HasSibling(name):
+return False
+return self.section.GetEntries()[name].image_pos
diff --git a/tools/binman/etype/image_header.py
b/tools/binman/etype/image_header.py
new file mode 100644
index 000..9bc84ec01d4
--- /dev/null
+++ b/tools/binman/etype/image_header.py
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2018 Google, Inc
+# Written by Simon Glass
+
+"""Entry-type module for an image header which points to the FDT map
+
+This creates an 8-byte entry with a magic number and the offset of the FDT map
+(which is another entry in the image), relative to the start or end of the
+image.
+"""
+
+import