Hi Simon,

On 10/10/22 22:00, Simon Glass wrote:
At present binman returns success when told to handle missing blobs.
This is confusing this in fact the resulting image cannot work.

Use exit code 103 to signal this problem, with a -W option to convert
it to a warning.

Signed-off-by: Simon Glass <s...@chromium.org>
---

  tools/binman/binman.rst | 4 ++++
  tools/binman/cmdline.py | 3 +++
  tools/binman/control.py | 7 ++++++-
  3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 4ee6f41f35e..c0512e68e67 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -1458,6 +1458,10 @@ space-separated list of directories to search for binary 
blobs::
         odroid-c4/build/board/hardkernel/odroidc4/firmware \
         odroid-c4/build/scp_task" binman ...
+Note that binman fails with error code 103 when there are missing blobs. If you
+wish to continue anyway, you can pass `-W` to binman.
+
+
  Code coverage
  -------------
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 1d1ca43993d..144c0c916a2 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -128,6 +128,9 @@ controlled by a description in the board device tree.'''
          default=False, help='Update the binman node with offset/size info')
      build_parser.add_argument('--update-fdt-in-elf', type=str,
          help='Update an ELF file with the output dtb: 
infile,outfile,begin_sym,end_sym')
+    build_parser.add_argument(
+        '-W', '--ignore-missing-blobs', action='store_true', default=False,
+        help='Return success even if there are missing blobs')
subparsers.add_parser(
          'bintool-docs', help='Write out bintool documentation (see 
bintool.rst)')
diff --git a/tools/binman/control.py b/tools/binman/control.py
index bfe63a15204..119b1176b7a 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -742,7 +742,12 @@ def Binman(args):
                  elf.UpdateFile(*elf_params, data)
if invalid:
-                tout.warning("\nSome images are invalid")
+                msg = '\nSome images are invalid'
+                if args.ignore_missing_blobs:
+                    tout.warning(msg)
+                else:
+                    tout.error("\nSome images are invalid")

I think you meant to have msg variable used here.

Also, you could flatten this by having a if not args.ingore_missing_blobs which has the return and then the new tout.warning left on the same indentation level of the current one.

Cheers,
Quentin

Reply via email to