[PATCH v2 4/5] binman: Use an exit code when blobs are missing

Simon Glass sjg at chromium.org
Tue Oct 11 16:15:40 CEST 2022


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 <sjg at chromium.org>
---

Changes in v2:
- Fix missing usage of the msg variable
- Simplify code to remove the 'else'

 tools/binman/binman.rst | 4 ++++
 tools/binman/cmdline.py | 3 +++
 tools/binman/control.py | 6 +++++-
 3 files changed, 12 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..da52abad077 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -742,7 +742,11 @@ def Binman(args):
                 elf.UpdateFile(*elf_params, data)
 
             if invalid:
-                tout.warning("\nSome images are invalid")
+                msg = '\nSome images are invalid'
+                if not args.ignore_missing_blobs:
+                    tout.error(msg)
+                    return 103
+                tout.warning(msg)
 
             # Use this to debug the time take to pack the image
             #state.TimingShow()
-- 
2.38.0.rc1.362.ged0d419d3c-goog



More information about the U-Boot mailing list