]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
binman: blob_dtb: improve error message when SPL is not found
authorJérémie Dautheribes <jeremie.dautheribes@bootlin.com>
Fri, 28 Nov 2025 11:03:04 +0000 (12:03 +0100)
committerTom Rini <trini@konsulko.com>
Wed, 10 Dec 2025 19:45:29 +0000 (13:45 -0600)
When using binman with the '-a spl-dtb=y' flag, if the SPL blob is not
found, binman throws a cryptic error message:
binman: 'NoneType' object has no attribute 'startswith'

Let's improve the error message to explicitly state which SPL blob is
missing.
This is particularly useful when binman is used as a standalone tool
outside the U-Boot source tree.

Signed-off-by: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
[trini: Add '# pragma: no cover' because coverage doesn't seem to like
the documentation about this error]
Signed-off-by: Tom Rini <trini@konsulko.com>
tools/binman/etype/blob_dtb.py

index b234323d7cfccbd0685e78dbdd7c2ce2b4f2ad64..957d6e115d4e43e43175491028a0f31d69fe08f2 100644 (file)
@@ -8,6 +8,8 @@
 from binman.entry import Entry
 from binman.etype.blob import Entry_blob
 from dtoc import fdt_util
+import errno
+import os
 import struct
 
 # This is imported if needed
@@ -39,9 +41,16 @@ class Entry_blob_dtb(Entry_blob):
                        (self._node.name, self.prepend))
 
     def ObtainContents(self, fake_size=0):
-        """Get the device-tree from the list held by the 'state' module"""
+        """Get the device-tree from the list held by the 'state' module
+
+        Raises:
+            FileNotFoundError: If the device-tree blob is not found.
+        """
         self._filename = self.GetDefaultFilename()
         self._pathname, _ = self.FdtContents(self.GetFdtEtype())
+        if self._pathname is None:
+            raise FileNotFoundError(errno.ENOENT, # pragma: no cover
+                                    os.strerror(errno.ENOENT), self._filename)
         return super().ReadBlobContents()
 
     def ProcessContents(self):