[PATCH] binman: fix mkmbn integration and tests

Casey Connolly casey.connolly at linaro.org
Tue Oct 28 12:15:07 CET 2025


Add the missing cryptography requirement to binman so that mkmbn
will work correctly, fix a pylint error, and adjust mkmbn to properly
integrate into binman rather than writing the output file directly.

For now skip testing u_boot_mbn since it has some weird requirements due
to how mkmbn works and can't be easily integrated into binman.

Signed-off-by: Casey Connolly <casey.connolly at linaro.org>
---
Changes since v1:
- Remove mkmbn elf class fixup, it's a separate patch now
- Link to v1: https://lore.kernel.org/u-boot/20251023133850.3686431-1-casey.connolly@linaro.org

---
 tools/binman/btool/mkmbn.py      | 9 ++-------
 tools/binman/etype/u_boot_mbn.py | 5 +++--
 tools/binman/main.py             | 4 +++-
 tools/binman/requirements.txt    | 1 +
 4 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/tools/binman/btool/mkmbn.py b/tools/binman/btool/mkmbn.py
index 232e2b442a16..c1439977833e 100644
--- a/tools/binman/btool/mkmbn.py
+++ b/tools/binman/btool/mkmbn.py
@@ -12,18 +12,13 @@ class Bintoolmkmbn(bintool.Bintool):
     def __init__(self, name):
         super().__init__(name, 'Generate MBN (signed ELF) image for U-Boot')
 
     # pylint: disable=R0913
-    def run(self, infile: str) -> CommandResult:
+    def run(self, infile: str, outfile:  str) -> CommandResult:
         """Run mkmbn.py
         """
-        args = [infile]
+        args = ['-o', outfile, infile]
         return self.run_cmd_result(*args, raise_on_error=False)
 
 
-    def get_path(self):
-        path = super().get_path()
-        return path
-
-
     def fetch(self, _method):
         return True
diff --git a/tools/binman/etype/u_boot_mbn.py b/tools/binman/etype/u_boot_mbn.py
index e470b31fa318..6268397fd122 100644
--- a/tools/binman/etype/u_boot_mbn.py
+++ b/tools/binman/etype/u_boot_mbn.py
@@ -31,10 +31,11 @@ class Entry_u_boot_mbn(Entry_blob):
     def __init__(self, section, etype, node):
         super().__init__(section, etype, node)
 
     def ObtainContents(self):
-        self._pathname = tools.get_input_filename('u-boot.bin')
-        res = self.mkmbn.run(self._pathname)
+        pathname = tools.get_input_filename('u-boot.bin')
+        self._pathname = tools.get_output_filename('u-boot.mbn')
+        res = self.mkmbn.run(pathname, self._pathname)
         if res is None:
             self.Raise('mkmbn not found or failed!')
         # Exit code 61 (ENODATA) indicates that an MBN file can't be built
         # for this board. This is non-fatal since it may not be required.
diff --git a/tools/binman/main.py b/tools/binman/main.py
index fa5ad79ca0e8..bfd6e990d2e4 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -102,9 +102,11 @@ def RunTestCoverage(toolpath, build_dir, args):
              'tools/u_boot_pylib/*'],
             build_dir, all_set, extra_args or None, args=args,
             allow_failures=['tools/binman/btool/cst.py',
                             'tools/binman/etype/nxp_imx8mcst.py',
-                            'tools/binman/etype/nxp_imx8mimage.py'])
+                            'tools/binman/etype/nxp_imx8mimage.py',
+                            'tools/binman/etype/u_boot_mbn.py',
+                            'tools/binman/btool/mkmbn.py'])
 
 def RunBinman(args):
     """Main entry point to binman once arguments are parsed
 
diff --git a/tools/binman/requirements.txt b/tools/binman/requirements.txt
index 7db72e888e3e..51b8ecd73478 100644
--- a/tools/binman/requirements.txt
+++ b/tools/binman/requirements.txt
@@ -3,4 +3,5 @@ importlib_resources==6.5.2
 jsonschema==4.23.0
 pycryptodomex==3.21.0
 pyelftools==0.31
 yamllint==1.35.1
+cryptography==46.0.3 # for mkmbn
-- 
2.51.0



More information about the U-Boot mailing list