From: Jonas Karlman <jonas@kwiboo.se>
To: Simon Glass <sjg@chromium.org>,
Alper Nebi Yasak <alpernebiyasak@gmail.com>
Cc: "Pali Rohár" <pali@kernel.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Marek Behún" <kabel@kernel.org>,
"Quentin Schulz" <quentin.schulz@theobroma-systems.com>,
"Stefan Herbrechtsmeier" <stefan.herbrechtsmeier@weidmueller.com>,
u-boot@lists.denx.de, "Jonas Karlman" <jonas@kwiboo.se>
Subject: [PATCH 6/9] binman: Mark mkimage entry missing when its subnodes is missing
Date: Sun, 19 Feb 2023 22:02:05 +0000 (UTC) [thread overview]
Message-ID: <20230219220158.4160763-7-jonas@kwiboo.se> (raw)
In-Reply-To: <20230219220158.4160763-1-jonas@kwiboo.se>
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@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
next prev parent reply other threads:[~2023-02-19 22:02 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-19 22:02 [PATCH 0/9] binman: Show missing blob message when building U-Boot Jonas Karlman
2023-02-19 22:02 ` [PATCH 2/9] binman: Fix spelling of nodes in code comments Jonas Karlman
2023-02-21 19:35 ` Simon Glass
2023-03-08 22:17 ` Simon Glass
2023-02-19 22:02 ` [PATCH 1/9] binman: Remove redundant SetAllowFakeBlob from blob-ext entry Jonas Karlman
2023-02-21 19:35 ` Simon Glass
2023-03-08 22:17 ` Simon Glass
2023-02-19 22:02 ` [PATCH 4/9] binman: Override CheckOptional in fit entry Jonas Karlman
2023-02-21 19:35 ` Simon Glass
2023-02-19 22:02 ` [PATCH 3/9] binman: Use correct argument name in docstrings Jonas Karlman
2023-02-21 19:35 ` Simon Glass
2023-03-08 22:17 ` Simon Glass
2023-02-19 22:02 ` [PATCH 5/9] binman: Implement missing check functions in mkimage entry Jonas Karlman
2023-02-21 19:41 ` Simon Glass
2023-02-19 22:02 ` Jonas Karlman [this message]
2023-02-21 19:41 ` [PATCH 6/9] binman: Mark mkimage entry missing when its subnodes is missing Simon Glass
2023-02-19 22:02 ` [PATCH 7/9] binman: Fix blank line usage for invalid images warning text Jonas Karlman
2023-02-21 19:41 ` Simon Glass
2023-02-19 22:02 ` [PATCH 8/9] binman: Show filename in missing blob help message Jonas Karlman
2023-02-21 19:41 ` Simon Glass
2023-02-19 22:02 ` [PATCH 9/9] Makefile: Show binman missing blob message Jonas Karlman
2023-02-21 19:41 ` Simon Glass
2023-02-21 23:09 ` Tom Rini
2023-02-22 21:20 ` Simon Glass
2023-02-22 21:45 ` Tom Rini
2023-02-22 22:56 ` Simon Glass
2023-03-10 20:49 ` [PATCH 0/9] binman: Show missing blob message when building U-Boot Simon Glass
2023-03-16 7:45 ` Jonas Karlman
2023-03-16 13:48 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230219220158.4160763-7-jonas@kwiboo.se \
--to=jonas@kwiboo.se \
--cc=alpernebiyasak@gmail.com \
--cc=kabel@kernel.org \
--cc=pali@kernel.org \
--cc=quentin.schulz@theobroma-systems.com \
--cc=sjg@chromium.org \
--cc=stefan.herbrechtsmeier@weidmueller.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox