[U-Boot,39/53] binman: Place Intel descriptor at image start
diff mbox series

Message ID 20190720182416.183626-40-sjg@chromium.org
State Accepted
Commit 27145fd3a836173390c2d2adcd267fa3005b7fbe
Delegated to: Simon Glass
Headers show
Series
  • binman: Support replacing entries in an existing image
Related show

Commit Message

Simon Glass July 20, 2019, 6:24 p.m. UTC
The Intel descriptor must always appear at the start of an (x86) image,
so it is supposed to position itself there always. However there is no
explicit test for this. Add one and fix a bug introduced by the recent
change to adjust Entry to read the node in a separate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/etype/intel_descriptor.py      |  6 +++++-
 tools/binman/ftest.py                       |  9 +++++++++
 tools/binman/test/141_descriptor_offset.dts | 20 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/141_descriptor_offset.dts

Comments

Simon Glass July 29, 2019, 9:22 p.m. UTC | #1
The Intel descriptor must always appear at the start of an (x86) image,
so it is supposed to position itself there always. However there is no
explicit test for this. Add one and fix a bug introduced by the recent
change to adjust Entry to read the node in a separate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/binman/etype/intel_descriptor.py      |  6 +++++-
 tools/binman/ftest.py                       |  9 +++++++++
 tools/binman/test/141_descriptor_offset.dts | 20 ++++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/141_descriptor_offset.dts

Applied to u-boot-dm, thanks!

Patch
diff mbox series

diff --git a/tools/binman/etype/intel_descriptor.py b/tools/binman/etype/intel_descriptor.py
index adea578080c..fb5e889ebff 100644
--- a/tools/binman/etype/intel_descriptor.py
+++ b/tools/binman/etype/intel_descriptor.py
@@ -47,8 +47,12 @@  class Entry_intel_descriptor(Entry_blob):
     def __init__(self, section, etype, node):
         Entry_blob.__init__(self, section, etype, node)
         self._regions = []
+
+    def Pack(self, offset):
+        """Put this entry at the start of the image"""
         if self.offset is None:
-            self.offset = self.section.GetStartOffset()
+            offset = self.section.GetStartOffset()
+        return Entry_blob.Pack(self, offset)
 
     def GetOffsets(self):
         offset = self.data.find(FD_SIGNATURE)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 11155ced709..d1ecd65c2c3 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -2975,6 +2975,15 @@  class TestFunctional(unittest.TestCase):
         self.assertEqual(U_BOOT_DATA, data[2:2 + len(U_BOOT_DATA)])
         self.assertEqual(b'a\0', data[-2:])
 
+    def testDescriptorOffset(self):
+        """Test that the Intel descriptor is always placed at at the start"""
+        data = self._DoReadFileDtb('141_descriptor_offset.dts')
+        image = control.images['image']
+        entries = image.GetEntries()
+        desc = entries['intel-descriptor']
+        self.assertEqual(0xff800000, desc.offset);
+        self.assertEqual(0xff800000, desc.image_pos);
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/141_descriptor_offset.dts b/tools/binman/test/141_descriptor_offset.dts
new file mode 100644
index 00000000000..f9bff016aa8
--- /dev/null
+++ b/tools/binman/test/141_descriptor_offset.dts
@@ -0,0 +1,20 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		sort-by-offset;
+		end-at-4gb;
+		size = <0x800000>;
+		u-boot {
+			offset = <0xffff0000>;
+		};
+		intel-descriptor {
+			filename = "descriptor.bin";
+		};
+	};
+};