Skip to contentSkip to conversation

binman: Allow FIT binaries to have missing external blobs

PATCH New Simon Glass 2 participants 4 messages Sep 1, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 binman: Allow FIT binaries to have missing external blobs

At present if a FIT references a missing external blob, binman reports an error, even if the image is supposed to allow this.

Propagate this setting down to the child sections of the FIT, so that the behaviour is consistent.

This is a fix-up patch to:

binman: Build FIT image subentries with the section etype

and will be squashed into that.

---

 tools/binman/etype/fit.py                  | 15 ++++++++
 tools/binman/ftest.py                      |  8 +++++
 tools/binman/test/168_fit_missing_blob.dts | 41 ++++++++++++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 tools/binman/test/168_fit_missing_blob.dts
tools/binman/etype/fit.py +15 -0
index acba53aa92c..615b2fd8778 100644
@@ -169,3 +169,18 @@ class Entry_fit(Entry):
         fdt.Sync(auto_resize=True)
         data = fdt.GetContents()
         return data
+
+    def CheckMissing(self, missing_list):
+        """Check if any entries in this FIT have missing external blobs
+
+        If there are missing blobs, the entries are added to the list
+
+        Args:
+            missing_list: List of Entry objects to be added to
+        """
+        for path, section in self._fit_sections.items():
+            section.CheckMissing(missing_list)
+
+    def SetAllowMissing(self, allow_missing):
+        for section in self._fit_sections.values():
+            section.SetAllowMissing(allow_missing)
tools/binman/ftest.py +8 -0
index 762535b5a74..e672967dbaa 100644
@@ -3515,5 +3515,13 @@ class TestFunctional(unittest.TestCase):
                     U_BOOT_DTB_DATA)
         self.assertEqual(expected, data)
 
+    def testFitExtblobMissingOk(self):
+        """Test a FIT with a missing external blob that is allowed"""
+        with test_util.capture_sys_output() as (stdout, stderr):
+            self._DoTestFile('168_fit_missing_blob.dts',
+                             allow_missing=True)
+        err = stderr.getvalue()
+        self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
+
 if __name__ == "__main__":
     unittest.main()
tools/binman/test/168_fit_missing_blob.dts new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.28.0.402.g5ffc5be6b7-goog
#1 lore raw

PATCH 1/1 binman: Allow FIT binaries to have missing external blobs

Hi Alper,

Quoted 13 lines · Simon Glass

At present if a FIT references a missing external blob, binman reports an error, even if the image is supposed to allow this.

Propagate this setting down to the child sections of the FIT, so that the behaviour is consistent.

This is a fix-up patch to:

binman: Build FIT image subentries with the section etype

and will be squashed into that.

Quoted 8 lines

---

 tools/binman/etype/fit.py                  | 15 ++++++++
 tools/binman/ftest.py                      |  8 +++++
 tools/binman/test/168_fit_missing_blob.dts | 41 ++++++++++++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 tools/binman/test/168_fit_missing_blob.dts

I found that evb-rk3288 fails to build with the final patch from your series. See u-boot-dm/testing for the tree.

Regards,
Simon

#2 lore raw

PATCH 1/1 binman: Allow FIT binaries to have missing external blobs

Quoted 4 lines · Simon Glass

Hi Alper,

I found that evb-rk3288 fails to build with the final patch from your series. See u-boot-dm/testing for the tree.

I had seen your patch and assumed that nothing was already using the allow-missing functionality in its FITs (since you're adding it now). Looks like the version in your tree (aa3f219e) succeeds in the pipeline, so I think there's nothing for me to do now. Thanks for fixing it.

Quoted 34 lines

At present if a FIT references a missing external blob, binman reports an error, even if the image is supposed to allow this.

Propagate this setting down to the child sections of the FIT, so that the behaviour is consistent.

This is a fix-up patch to:

binman: Build FIT image subentries with the section etype

and will be squashed into that.

---

 tools/binman/etype/fit.py                  | 15 ++++++++
 tools/binman/ftest.py                      |  8 +++++
 tools/binman/test/168_fit_missing_blob.dts | 41 ++++++++++++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 tools/binman/test/168_fit_missing_blob.dts
tools/binman/etype/fit.py +5 -0
index acba53aa92c..615b2fd8778 100644
@@ -169,3 +169,18 @@ class Entry_fit(Entry):
         fdt.Sync(auto_resize=True)
         data = fdt.GetContents()
         return data
+
+    def CheckMissing(self, missing_list):
+        """Check if any entries in this FIT have missing external blobs
+
+        If there are missing blobs, the entries are added to the list

tools/binman/etype/fit.py class Entry_fit(Entry): · line 186

Quoted 10 lines
tools/binman/etype/fit.py +10 -0
+
+        Args:
+            missing_list: List of Entry objects to be added to
+        """
+        for path, section in self._fit_sections.items():
+            section.CheckMissing(missing_list)
+
+    def SetAllowMissing(self, allow_missing):
+        for section in self._fit_sections.values():
+            section.SetAllowMissing(allow_missing)

I saw GetAllowMissing() in section.py, doesn't this also need it?

Quoted 55 lines
tools/binman/ftest.py +8 -0
index 762535b5a74..e672967dbaa 100644
@@ -3515,5 +3515,13 @@ class TestFunctional(unittest.TestCase):
                     U_BOOT_DTB_DATA)
         self.assertEqual(expected, data)
 
+    def testFitExtblobMissingOk(self):
+        """Test a FIT with a missing external blob that is allowed"""
+        with test_util.capture_sys_output() as (stdout, stderr):
+            self._DoTestFile('168_fit_missing_blob.dts',
+                             allow_missing=True)
+        err = stderr.getvalue()
+        self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
+
 if __name__ == "__main__":
     unittest.main()
tools/binman/test/168_fit_missing_blob.dts new file +31 -0
new file mode 100644
index 00000000000..e007aa41d8a
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot {
+		};
+		fit {
+			description = "test-desc";
+			#address-cells = <1>;
+			fit,fdt-list = "of-list";
+
+			images {
+				kernel {
+					description = "ATF BL31";
+					type = "kernel";
+					arch = "ppc";
+					os = "linux";
+					compression = "gzip";
+					load = <00000000>;
+					entry = <00000000>;
+					hash-1 {
+						algo = "crc32";
+					};
+					hash-2 {
+						algo = "sha1";
+					};

tools/binman/test/168_fit_missing_blob.dts line 41

Quoted 10 lines
tools/binman/test/168_fit_missing_blob.dts new file +10 -0
+					blob-ext {
+						filename = "missing";
+					};
+				};
+			};
+		};
+		u-boot-nodtb {
+		};
+	};
+};

Anyway, feel free to add if you need to:

(or Acked-by, or neither)

#3 lore raw

PATCH 1/1 binman: Allow FIT binaries to have missing external blobs

Hi Alper,

Quoted 11 lines · Alper Nebi Yasak
Quoted 4 lines · Simon Glass

Hi Alper,

I found that evb-rk3288 fails to build with the final patch from your series. See u-boot-dm/testing for the tree.

I had seen your patch and assumed that nothing was already using the allow-missing functionality in its FITs (since you're adding it now). Looks like the version in your tree (aa3f219e) succeeds in the pipeline, so I think there's nothing for me to do now. Thanks for fixing it.

That's right. It's a little bit subtle. In fact we rely on support for missing entries already, but switching over to use sections for the FIT contents means that those sections are not marked to 'allow missing'. So in fact we fail when we cannot find the file.

I did try to do this as a separate patch, but switching to sections is what creates the issue which is why I think I have to squash the patch.

Quoted 39 lines
Quoted 39 lines

At present if a FIT references a missing external blob, binman reports an error, even if the image is supposed to allow this.

Propagate this setting down to the child sections of the FIT, so that the behaviour is consistent.

This is a fix-up patch to:

binman: Build FIT image subentries with the section etype

and will be squashed into that.

---

 tools/binman/etype/fit.py                  | 15 ++++++++
 tools/binman/ftest.py                      |  8 +++++
 tools/binman/test/168_fit_missing_blob.dts | 41 ++++++++++++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 tools/binman/test/168_fit_missing_blob.dts
tools/binman/etype/fit.py +9 -0
index acba53aa92c..615b2fd8778 100644
@@ -169,3 +169,18 @@ class Entry_fit(Entry):
         fdt.Sync(auto_resize=True)
         data = fdt.GetContents()
         return data
+
+    def CheckMissing(self, missing_list):
+        """Check if any entries in this FIT have missing external blobs
+
+        If there are missing blobs, the entries are added to the list
+
+        Args:
+            missing_list: List of Entry objects to be added to
+        """
Quoted 8 lines

tools/binman/etype/fit.py class Entry_fit(Entry): · line 186

Quoted 6 lines
tools/binman/etype/fit.py +6 -0
+        for path, section in self._fit_sections.items():
+            section.CheckMissing(missing_list)
+
+    def SetAllowMissing(self, allow_missing):
+        for section in self._fit_sections.values():
+            section.SetAllowMissing(allow_missing)

I saw GetAllowMissing() in section.py, doesn't this also need it?

That is in Entry so we can just rely on that. The FIT itself cannot be missing.

Quoted 69 lines
Quoted 56 lines
tools/binman/ftest.py +8 -0
index 762535b5a74..e672967dbaa 100644
@@ -3515,5 +3515,13 @@ class TestFunctional(unittest.TestCase):
                     U_BOOT_DTB_DATA)
         self.assertEqual(expected, data)
 
+    def testFitExtblobMissingOk(self):
+        """Test a FIT with a missing external blob that is allowed"""
+        with test_util.capture_sys_output() as (stdout, stderr):
+            self._DoTestFile('168_fit_missing_blob.dts',
+                             allow_missing=True)
+        err = stderr.getvalue()
+        self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext")
+
 if __name__ == "__main__":
     unittest.main()
tools/binman/test/168_fit_missing_blob.dts new file +31 -0
new file mode 100644
index 00000000000..e007aa41d8a
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+     #address-cells = <1>;
+     #size-cells = <1>;
+
+     binman {
+             u-boot {
+             };
+             fit {
+                     description = "test-desc";
+                     #address-cells = <1>;
+                     fit,fdt-list = "of-list";
+
+                     images {
+                             kernel {
+                                     description = "ATF BL31";
+                                     type = "kernel";
+                                     arch = "ppc";
+                                     os = "linux";
+                                     compression = "gzip";
+                                     load = <00000000>;
+                                     entry = <00000000>;
+                                     hash-1 {
+                                             algo = "crc32";
+                                     };
+                                     hash-2 {
+                                             algo = "sha1";
+                                     };

tools/binman/test/168_fit_missing_blob.dts line 41

Quoted 10 lines
tools/binman/test/168_fit_missing_blob.dts new file +10 -0
+                                     blob-ext {
+                                             filename = "missing";
+                                     };
+                             };
+                     };
+             };
+             u-boot-nodtb {
+             };
+     };
+};

Anyway, feel free to add if you need to:

Quoted 3 lines

(or Acked-by, or neither)

Thanks!

Regards,
Simon