[PATCH v2 4/7] binman: add support for building Qualcomm signed MBN ELF images
Casey Connolly
casey.connolly at linaro.org
Mon Jun 2 18:10:55 CEST 2025
Implement support for building u-boot.mbn files using the new mkmbn
tool.
Signed-off-by: Casey Connolly <casey.connolly at linaro.org>
---
tools/binman/btool/mkmbn.py | 29 +++++++++++++++++++++++
tools/binman/etype/u_boot_mbn.py | 51 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/tools/binman/btool/mkmbn.py b/tools/binman/btool/mkmbn.py
new file mode 100644
index 0000000000000000000000000000000000000000..232e2b442a166f9e86a4d4eb5f55f624eee0dc62
--- /dev/null
+++ b/tools/binman/btool/mkmbn.py
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2025, Linaro Ltd.
+#
+"""Bintool implementation for mkmbn"""
+
+from binman import bintool
+from u_boot_pylib.command import CommandResult
+
+class Bintoolmkmbn(bintool.Bintool):
+ """Qualcomm MBN generator for U-Boot
+ """
+ def __init__(self, name):
+ super().__init__(name, 'Generate MBN (signed ELF) image for U-Boot')
+
+ # pylint: disable=R0913
+ def run(self, infile: str) -> CommandResult:
+ """Run mkmbn.py
+ """
+ args = [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
new file mode 100644
index 0000000000000000000000000000000000000000..35c271a45e3ce75f10d1852eb0ac290b38913d84
--- /dev/null
+++ b/tools/binman/etype/u_boot_mbn.py
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2025 Linaro Ltd
+# Authored by Casey Connolly <casey.connolly at linaro.org>
+#
+# Entry-type module for 'u-boot.mbn'
+#
+
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
+from u_boot_pylib import tout
+from u_boot_pylib import tools
+from binman.btool.mkmbn import Bintoolmkmbn
+
+"""
+Casey TODO:
+
+* move qcom-binman.dts back to arch/arm/dts and figure out how to make it build...
+* set CONFIG_BINMAN_DTB in qcom_defconfig
+* update docs
+
+"""
+
+class Entry_u_boot_mbn(Entry_blob):
+ """U-Boot Qualcomm signed MBN ELF image
+
+ This is an ELF file with custom program headers containing Qualcomm
+ specific hashes, signatures and other metadata. It contains the
+ u-boot.bin image.
+ """
+ mkmbn: Bintoolmkmbn
+ 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)
+ 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.
+ # however we print the stderr which indicates how to add MBN support
+ # if it is actually needed for this platform.
+ if res.return_code == 61:
+ print(res.stderr, end='')
+ return self.ReadBlobContents()
+
+ def GetDefaultFilename(self):
+ return 'u-boot.mbn'
+
+ def AddBintools(self, btools):
+ self.mkmbn = self.AddBintool(btools, 'mkmbn')
--
2.49.0
More information about the U-Boot
mailing list