binman: fix mkmbn integration and tests
PATCH 1/1 binman: fix mkmbn integration and tests
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.
---
Changes since v1:
- Remove mkmbn elf class fixup, it's a separate patch now
- Link to v1: https://lore.kernel.org/u-boot/[email protected]
--- 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(-)
tools/binman/btool/mkmbn.py +2 -7
@@ -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
tools/binman/etype/u_boot_mbn.py +3 -2
@@ -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.
tools/binman/main.py +3 -1
@@ -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
tools/binman/requirements.txt +1 -0
@@ -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
Signature · 1 line
2.51.0
Quoted 85 lines · Casey Connolly via groups.io
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_mbnsince it has some weird requirements due to how mkmbn works and can't be easily integrated into binman.Signed-off-by Casey Connolly <[email protected]>---
Changes since v1:
- Remove mkmbn elf class fixup, it's a separate patch now
- Link to v1: https://lore.kernel.org/u-boot/[email protected]--- 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(-)tools/binman/btool/mkmbn.py +2
-7@@ -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 Truetools/binman/etype/u_boot_mbn.py +3
-2@@ -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.tools/binman/main.py +3
-1@@ -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 parsedtools/binman/requirements.txt +0
-0
tools/binman/requirements.txt importlib_resources==6.5.2 · line 7
Quoted 5 lines
tools/binman/requirements.txt +1
-0@@ -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