[PATCH 6/9] binman: Mark mkimage entry missing when its subnodes is missing
Jonas Karlman
jonas at kwiboo.se
Sun Feb 19 23:02:05 CET 2023
Using the mkimage entry with the multiple-data-files prop and having a
missing external blob result in an unexpected ValueError exception using
the --allow-missing flag.
ValueError: Filename 'missing.bin' not found in input path (...)
Fix this by using _pathname that is resolved by ObtainContents for blob
entries, ObtainContents also handles allow missing for external blobs.
Mark mkimage entry as missing and return without running mkimage when
missing entries is reported by CheckMissing.
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
tools/binman/etype/mkimage.py | 10 +++++++++-
tools/binman/ftest.py | 9 +++++++++
.../test/278_mkimage_missing_multiple.dts | 19 +++++++++++++++++++
3 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index 49d3462a154c..2673a8607f37 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -156,7 +156,8 @@ class Entry_mkimage(Entry):
for entry in self._mkimage_entries.values():
if not entry.ObtainContents(fake_size=fake_size):
return False
- fnames.append(tools.get_input_filename(entry.GetDefaultFilename()))
+ if entry._pathname:
+ fnames.append(entry._pathname)
input_fname = ":".join(fnames)
else:
data, input_fname, uniq = self.collect_contents_to_file(
@@ -171,6 +172,13 @@ class Entry_mkimage(Entry):
outfile = self._filename if self._filename else 'mkimage-out.%s' % uniq
output_fname = tools.get_output_filename(outfile)
+ missing_list = []
+ self.CheckMissing(missing_list)
+ self.missing = bool(missing_list)
+ if self.missing:
+ self.SetContents(b'')
+ return self.allow_missing
+
args = ['-d', input_fname]
if self._data_to_imagename:
args += ['-n', input_fname]
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 48ac1540bfd8..803b8c5accf4 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6393,6 +6393,15 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
data = self._DoReadFile('277_rockchip_tpl.dts')
self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)])
+ def testMkimageMissingBlobMultiple(self):
+ """Test using mkimage to build an image"""
+ with test_util.capture_sys_output() as (stdout, stderr):
+ self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=True)
+ err = stderr.getvalue()
+ self.assertRegex(
+ err,
+ "Image '.*' is missing external blobs and is non-functional: .*")
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/test/278_mkimage_missing_multiple.dts b/tools/binman/test/278_mkimage_missing_multiple.dts
new file mode 100644
index 000000000000..f84aea49ead9
--- /dev/null
+++ b/tools/binman/test/278_mkimage_missing_multiple.dts
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ mkimage {
+ args = "-n test -T script";
+ multiple-data-files;
+
+ blob-ext {
+ filename = "missing.bin";
+ };
+ };
+ };
+};
--
2.39.2
More information about the U-Boot
mailing list