Fix handling of optional blobs in binman
cover Fix handling of optional blobs in binman
This series solves a contradiction regarding ext blobs packaged in binman. When they are marked as optional, by default they are faked, two messages are emitted. One says the image is not functional the other says the image is still functional. Both concern the same binman entry/blob. To solve this, don't emit a warning when an image is faked AND optional.
Make binman tests consistent with this behaviour.
Add regex to test cases checking that the non-functional message is indeed not emitted. Update the documentation to inform users of this interaction.
Binman is set up to have fake external blobs in case they are missing. This is regardless on whether they are optional or not.
The implementation does not allow different types of entries to override the faking decision; at least there wouldn't be much sense in doing so.
Here is an example build output of a phycore-imx8mp:
BINMAN .binman_stamp
Image 'image' is missing optional external blobs but is still functional: tee-os
/binman/section/fit/images/tee/tee-os (tee.bin):
See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin
Image 'image' has faked optional external blobs and is still functional: tee.bin
OFCHK .config
The first patch makes binman test with --fake_ext_blobs by default to be consistent with the default make target when building U-Boot. This exposes an error as one test is failing where it should not (loadables). Then, fix some tests that must not fake ext blobs and thus failed due to the change.
Further, fix the behaviour of binman itself as explained above. Fixing this bug also makes the loadables test pass again.
Finally, add test coverage for this new case and extend the documentation.
---
Yannic Moog (6):
tools: binman: ftest.py: fake ext blobs per default
tools: binman: ftest: pass allow_fake_blob to _DoReadFileDtb
tools: binman: ftest: fix tests that require non-faked ext blobs
binman: fix faked optional entry handling
binman: test: assert optional blobs don't cause non-functionality
binman: doc: update Optional entries
tools/binman/binman.rst | 9 ++++++++- tools/binman/control.py | 19 ++++++++++++++++--- tools/binman/ftest.py | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 15 deletions(-)
---
base-commit: a2b489b170f8382f746202c36616eaf2bc38fe86
change-id: 20250122-binman_faked_optional-5025f7046e25
Best regards,
Signature · 1 line
Yannic Moog <[email protected]>
RFC PATCH 1/6 tools: binman: ftest.py: fake ext blobs per default
The top level Makefile calls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.
--- tools/binman/ftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/binman/ftest.py +1 -1
@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, force_missing_bintools='', ignore_missing=False, output_dir=None): """Run binman with a given test file
Signature · 1 line
2.43.0
Re: [PATCH RFC 1/6] tools: binman: ftest.py: fake ext blobs per default
Hi Yannic,
Quoted 25 lines · Yannic Moog
The top level
Makefilecalls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/ftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/binman/ftest.py +1
-2@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, force_missing_bintools='', ignore_missing=False, output_dir=None): """Run binman with a given test file --
Quoted 2 lines
2.43.0
I would like this default to stay the same (False) because that is the normal case for Binman. We should expand the test-coverage as needed.
Regards,
Simon
Re: [PATCH RFC 1/6] tools: binman: ftest.py: fake ext blobs per default
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Yannic,
Quoted 24 lines · Yannic Moog
The top level
Makefilecalls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.Signed-off-by Yannic Moog <[email protected]>---
tools/binman/ftest.py | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/binman/ftest.py +1
-1@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None,force_missing_bintools='', ignore_missing=False, output_dir=None):
"""Run binman with a given test file
Quoted 6 lines
Quoted 3 lines
--
2.43.0I would like this default to stay the same (False) because that is the normal case for Binman. We should expand the test-coverage as needed.
Can you help me understand why we fake blobs in the call to binman when building U-Boot? You say that not faking is the normal case so why are we doing something abnormal in the top-level Makefile?
I think that this inconsistency is a potential for bugs going unnoticed so whatever we decide to do I would very much like to be consistent with testing and "normal" builds.
Yannic
Quoted 3 lines
Regards,
Simon
Re: [PATCH RFC 1/6] tools: binman: ftest.py: fake ext blobs per default
Hi Yannic,
Quoted 38 lines · Yannic Moog
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Yannic,
Quoted 24 lines · Yannic Moog
The top level
Makefilecalls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/ftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/binman/ftest.py +1
-1@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, force_missing_bintools='', ignore_missing=False, output_dir=None): """Run binman with a given test fileQuoted 6 lines
Quoted 3 lines
--
2.43.0I would like this default to stay the same (False) because that is the normal case for Binman. We should expand the test-coverage as needed.
Quoted 3 lines
Can you help me understand why we fake blobs in the call to binman when building U-Boot? You say that not faking is the normal case so why are we doing something abnormal in the top-level
Makefile?
I mean that not faking is the normal case for Binman's code base. Yes, U-Boot requests faking.
Quoted 3 lines
I think that this inconsistency is a potential for bugs going unnoticed so whatever we decide to do I would very much like to be consistent with testing and "normal" builds.
Binman is tested by its own tests which handle both cases, so we don't have a test gap there.
Regards,
Simon
Quoted 7 lines
Yannic
Quoted 3 lines
Regards,
Simon
Re: [PATCH RFC 1/6] tools: binman: ftest.py: fake ext blobs per default
Hi Simon,
Quoted 50 lines · Simon Glass
Hi Yannic,
Quoted 38 lines · Yannic Moog
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Yannic,
Quoted 24 lines · Yannic Moog
The top level
Makefilecalls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.Signed-off-by Yannic Moog <[email protected]>---
tools/binman/ftest.py | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/binman/ftest.py +1
-1@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None,force_missing_bintools='', ignore_missing=False, output_dir=None):
"""Run binman with a given test fileQuoted 6 lines
Quoted 3 lines
--
2.43.0I would like this default to stay the same (False) because that is the normal case for Binman. We should expand the test-coverage as needed.
Quoted 4 lines
Can you help me understand why we fake blobs in the call to binman when building U-Boot? You say that not faking is the normal case so why are we doing something abnormal in the top- level
Makefile?I mean that not faking is the normal case for Binman's code base. Yes, U-Boot requests faking.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
I think that this inconsistency is a potential for bugs going unnoticed so whatever we decide to do
I would very much like to be consistent with testing and "normal" builds.Binman is tested by its own tests which handle both cases, so we don't have a test gap there.
Sorry, I am still stumped here. I feel like my question as to why U-Boot requests faking has not been answered above. Can you please explain that again?
And I am left a bit confused since I thought these RFC patches show that there indeed was a test gap (in a single test case testFitFirmwareLoadables only, but still) due to not faking external blobs. Is it not possible that there are other potential problems in regards to faking blobs that we have not discovered, yet?
Yannic
Quoted 11 lines
Regards,
SimonQuoted 7 lines
Yannic
Quoted 3 lines
Regards,
Simon
Re: [PATCH RFC 1/6] tools: binman: ftest.py: fake ext blobs per default
Hi Yannic,
Quoted 58 lines · Yannic Moog
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Yannic,
Quoted 38 lines · Yannic Moog
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Yannic,
Quoted 24 lines · Yannic Moog
The top level
Makefilecalls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/ftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/binman/ftest.py +1
-1@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, force_missing_bintools='', ignore_missing=False, output_dir=None): """Run binman with a given test fileQuoted 6 lines
Quoted 3 lines
--
2.43.0I would like this default to stay the same (False) because that is the normal case for Binman. We should expand the test-coverage as needed.
Quoted 4 lines
Can you help me understand why we fake blobs in the call to binman when building U-Boot? You say that not faking is the normal case so why are we doing something abnormal in the top- level
Makefile?I mean that not faking is the normal case for Binman's code base. Yes, U-Boot requests faking.
Quoted 4 lines
I think that this inconsistency is a potential for bugs going unnoticed so whatever we decide to do
I would very much like to be consistent with testing and "normal" builds.
Quoted 5 lines
Quoted 2 lines
Binman is tested by its own tests which handle both cases, so we don't have a test gap there.
Sorry, I am still stumped here. I feel like my question as to why U-Boot requests faking has not been answered above. Can you please explain that again?
U-Boot needs to use fakes largely because in some cases the fake is passed to mkimage, which sometimes cannot operate at all if there is a missing or zero-sized file. So we create a fake just so that the build will succeed (with warnings).
Quoted 5 lines
And I am left a bit confused since I thought these RFC patches show that there indeed was a test gap (in a single test case testFitFirmwareLoadables only, but still) due to not faking external blobs. Is it not possible that there are other potential problems in regards to faking blobs that we have not discovered, yet?
Yes, please fix the test gap and if there are other tests we need to add, we should add them. The goal of Binman is 100% test coverage. But faked blobs are more of an unfortunate workaround, not the primary goal of Binman. So I would like tests to explicitly select faked blobs when needed, rather than having this on everywhere. It should only affect a very small amount of tests which deal with the pain of external blobs.
Regards,
Simon
Re: [PATCH RFC 1/6] tools: binman: ftest.py: fake ext blobs per default
Quoted 83 lines · Simon Glass
Hi Yannic,
Quoted 60 lines · Yannic Moog
Hi Simon,
Quoted 56 lines · Simon Glass
Hi Yannic,
Quoted 38 lines · Yannic Moog
Hi Simon,
Quoted 27 lines · Simon Glass
Hi Yannic,
Quoted 24 lines · Yannic Moog
The top level
Makefilecalls binman with fake-ext-blobs. The test setup should reflect this to spot potential bugs before reaching users.Signed-off-by Yannic Moog <[email protected]>---
tools/binman/ftest.py | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/binman/ftest.py +1
-1@@ -372,7 +372,7 @@ class TestFunctional(unittest.TestCase): def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, entry_args=None, images=None, use_real_dtb=False, use_expanded=False, verbosity=None, allow_missing=False, - allow_fake_blobs=False, extra_indirs=None, threads=None, + allow_fake_blobs=True, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None,force_missing_bintools='', ignore_missing=False, output_dir=None):
"""Run binman with a given test fileQuoted 6 lines
Quoted 3 lines
--
2.43.0I would like this default to stay the same (False) because that is the normal case for Binman. We should expand the test-coverage as needed.
Quoted 5 lines
Can you help me understand why we fake blobs in the call to binman when building U-Boot? You say that not faking is the normal case so why are we doing something abnormal in the top-
levelMakefile?I mean that not faking is the normal case for Binman's code base. Yes, U-Boot requests faking.
Quoted 5 lines
I think that this inconsistency is a potential for bugs going unnoticed so whatever we decide to
do
I would very much like to be consistent with testing and "normal" builds.Quoted 5 lines
Quoted 2 lines
Binman is tested by its own tests which handle both cases, so we don't have a test gap there.
Sorry, I am still stumped here. I feel like my question as to why U-Boot requests faking has not been answered above. Can you please explain that again?
U-Boot needs to use fakes largely because in some cases the fake is passed to mkimage, which sometimes cannot operate at all if there is a missing or zero-sized file. So we create a fake just so that the build will succeed (with warnings).
Quoted 8 lines
And I am left a bit confused since I thought these RFC patches show that there indeed was a test gap
(in a single test case testFitFirmwareLoadables only, but still) due to not faking external blobs.
Is it not possible that there are other potential problems in regards to faking blobs that we have
not discovered, yet?
Quoted 7 lines
Yes, please fix the test gap and if there are other tests we need to add, we should add them. The goal of Binman is 100% test coverage. But faked blobs are more of an unfortunate workaround, not the primary goal of Binman. So I would like tests to explicitly select faked blobs when needed, rather than having this on everywhere. It should only affect a very small amount of tests which deal with the pain of external blobs.
Thanks for taking the time to explain this to me, I got it now.
I will take your suggestion and review the test cases to see if any should explicitly set fake-blobs . And with that will drop the default fake blobs per you request.
Yannic
Quoted 3 lines
Regards,
Simon
RFC PATCH 2/6 tools: binman: ftest: pass allow_fake_blob to _DoReadFileDtb
In reply to Yannic MoogSome test cases don't use _DoTestFile directly which accepts allow_fake_blobs. However, they specifically test functionality that requires external blobs not to be faked. Extend the _DoReadFileDtb signature to allow passing that option to _DoTestFile.
--- tools/binman/ftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/binman/ftest.py +5 -4
@@ -505,9 +505,9 @@ class TestFunctional(unittest.TestCase): return dtb.GetContents() def _DoReadFileDtb(self, fname, use_real_dtb=False, use_expanded=False, - verbosity=None, map=False, update_dtb=False, - entry_args=None, reset_dtbs=True, extra_indirs=None, - threads=None): + verbosity=None, allow_fake_blobs=True, map=False, + update_dtb=False, entry_args=None, reset_dtbs=True, + extra_indirs=None, threads=None): """Run binman and return the resulting image This runs binman with a given test file and then reads the resulting
@@ -525,6 +525,7 @@ class TestFunctional(unittest.TestCase): use_expanded: True to use expanded entries where available, e.g. 'u-boot-expanded' instead of 'u-boot' verbosity: Verbosity level to use (0-3, None=don't set it) + allow_fake_blob: whether binman should fake missing ext blobs map: True to output map files for the images update_dtb: Update the offset and size of each entry in the device tree before packing it into the image
@@ -562,7 +563,7 @@ class TestFunctional(unittest.TestCase): retcode = self._DoTestFile(fname, map=map, update_dtb=update_dtb, entry_args=entry_args, use_real_dtb=use_real_dtb, use_expanded=use_expanded, verbosity=verbosity, - extra_indirs=extra_indirs, + allow_fake_blobs=allow_fake_blobs, extra_indirs=extra_indirs, threads=threads) self.assertEqual(0, retcode) out_dtb_fname = tools.get_output_filename('u-boot.dtb.out')
Signature · 1 line
2.43.0
Re: [PATCH RFC 2/6] tools: binman: ftest: pass allow_fake_blob to _DoReadFileDtb
Quoted 11 lines · Yannic Moog
Some test cases don't use
_DoTestFiledirectly which acceptsallow_fake_blobs. However, they specifically test functionality that requires external blobs not to be faked. Extend the_DoReadFileDtbsignature to allow passing that option to_DoTestFile.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/ftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
RFC PATCH 3/6 tools: binman: ftest: fix tests that require non-faked ext blobs
In reply to Yannic MoogBy default, external blobs are faked. Some tests care only about more basic functionality. In those cases no external blobs should be faked. That would trigger a different (binman) case which is not in scope for those particular tests.
Thus, disable faked blobs for those test cases.
--- tools/binman/ftest.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
tools/binman/ftest.py +11 -7
@@ -5188,13 +5188,15 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testExtblobList(self): """Test an image with an external blob list""" - data = self._DoReadFile('215_blob_ext_list.dts') - self.assertEqual(REFCODE_DATA + FSP_M_DATA, data) + data = self._DoReadFileDtb('215_blob_ext_list.dts', + allow_fake_blobs=False) + self.assertEqual(REFCODE_DATA + FSP_M_DATA, data[0]) def testExtblobListMissing(self): """Test an image with a missing external blob""" with self.assertRaises(ValueError) as e: - self._DoReadFile('216_blob_ext_list_missing.dts') + self._DoReadFileDtb('216_blob_ext_list_missing.dts', + allow_fake_blobs=False) self.assertIn("Filename 'missing-file' not found in input path", str(e.exception))
@@ -5202,7 +5204,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap """Test an image with an missing external blob that is allowed""" with test_util.capture_sys_output() as (stdout, stderr): self._DoTestFile('216_blob_ext_list_missing.dts', - allow_missing=True) + allow_missing=True, allow_fake_blobs=False) err = stderr.getvalue() self.assertRegex(err, "Image 'image'.*missing.*: blob-ext")
@@ -5739,10 +5741,10 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitSplitElfMissing(self): - """Test an split-elf FIT with a missing ELF file""" + """Test an split-elf FIT with a missing ELF file. Don't fake the file.""" if not elf.ELF_TOOLS: self.skipTest('Python elftools not available') - out, err = self.checkFitSplitElf(allow_missing=True) + out, err = self.checkFitSplitElf(allow_missing=True, allow_fake_blobs=False) self.assertRegex( err, "Image '.*' is missing external blobs and is non-functional: .*")
@@ -6506,7 +6508,9 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testExtblobOptional(self): """Test an image with an external blob that is optional""" with test_util.capture_sys_output() as (stdout, stderr): - data = self._DoReadFile('266_blob_ext_opt.dts') + data = self._DoReadFileDtb('266_blob_ext_opt.dts', + allow_fake_blobs=False)[0] + self.assertEqual(REFCODE_DATA, data) err = stderr.getvalue() self.assertRegex(
Signature · 1 line
2.43.0
Re: [PATCH RFC 3/6] tools: binman: ftest: fix tests that require non-faked ext blobs
Hi,
Quoted 6 lines · Yannic Moog
By default, external blobs are faked. Some tests care only about more basic functionality. In those cases no external blobs should be faked. That would trigger a different (binman) case which is not in scope for those particular tests.
Thus, disable faked blobs for those test cases.
As before, please keep the non-fake case as the primary one.
Something else to keep in mind is that the tests should pass with each commit.
Quoted 5 lines
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/ftest.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
Regards,
Simon
Re: [PATCH RFC 3/6] tools: binman: ftest: fix tests that require non-faked ext blobs
Quoted 10 lines · Simon Glass
Hi,
Quoted 6 lines · Yannic Moog
By default, external blobs are faked. Some tests care only about more basic functionality. In those cases no external blobs should be faked. That would trigger a different (binman) case which is not in scope for those particular tests.
Thus, disable faked blobs for those test cases.
Quoted 3 lines
As before, please keep the non-fake case as the primary one.
Something else to keep in mind is that the tests should pass with each commit.
Okay, got it. I will adjust that for the next version.
Quoted 9 lines
Quoted 6 lines
Signed-off-by Yannic Moog <[email protected]>---
tools/binman/ftest.py | 18 +++++++++++-------1 file changed, 11 insertions(+), 7 deletions(-)Regards,
Simon
RFC PATCH 4/6 binman: fix faked optional entry handling
In reply to Yannic MoogWhen having an entry that is marked as optional and is missing, the following output is observed:
CFGS spl/u-boot-spl.cfgout
BINMAN .binman_stamp
Image 'image' has faked external blobs and is non-functional: tee.bin
Image 'image' is missing optional external blobs but is still functional: tee-os
/binman/section/fit/images/tee/tee-os (tee.bin):
See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin
Some images are invalid
make: *** [Makefile:1135: .binman_stamp] Error 103
To solve this contradictory messaging, when checking the faked blob list, remove entries that are allowed to be missing.
This also fixes the testFitFirmwareLoadables binman test:
FAIL: testFitFirmwareLoadables (binman.ftest.TestFunctional.testFitFirmwareLoadables) Test an image with an FIT that use fit,firmware
----------------------------------------------------------------------
AssertionError: 0 != 103
This test failed due to the exposed bug when testing with faked external blobs.
--- tools/binman/control.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
tools/binman/control.py +16 -3
@@ -641,12 +641,19 @@ def CheckForProblems(image): _ShowHelpForMissingBlobs(tout.ERROR, missing_list) faked_list = [] + faked_optional_list = [] + faked_required_list = [] image.CheckFakedBlobs(faked_list) - if faked_list: + for e in faked_list: + if e.optional: + faked_optional_list.append(e) + else: + faked_required_list.append(e) + if faked_required_list: tout.warning( "Image '%s' has faked external blobs and is non-functional: %s\n" % (image.name, ' '.join([os.path.basename(e.GetDefaultFilename()) - for e in faked_list]))) + for e in faked_required_list]))) optional_list = [] image.CheckOptional(optional_list)
@@ -656,6 +663,12 @@ def CheckForProblems(image): (image.name, ' '.join([e.name for e in optional_list]))) _ShowHelpForMissingBlobs(tout.WARNING, optional_list) + if faked_optional_list: + tout.warning( + "Image '%s' has faked optional external blobs but is still functional: %s\n" % + (image.name, ' '.join([os.path.basename(e.GetDefaultFilename()) + for e in faked_optional_list]))) + missing_bintool_list = [] image.check_missing_bintools(missing_bintool_list) if missing_bintool_list:
@@ -663,7 +676,7 @@ def CheckForProblems(image): "Image '%s' has missing bintools and is non-functional: %s\n" % (image.name, ' '.join([os.path.basename(bintool.name) for bintool in missing_bintool_list]))) - return any([missing_list, faked_list, missing_bintool_list]) + return any([missing_list, faked_required_list, missing_bintool_list]) def ProcessImage(image, update_fdt, write_map, get_contents=True, allow_resize=True, allow_missing=False,
Signature · 1 line
2.43.0
Re: [PATCH RFC 4/6] binman: fix faked optional entry handling
Quoted 27 lines · Yannic Moog
When having an entry that is marked as optional and is missing, the following output is observed:
CFGS spl/u-boot-spl.cfgout
BINMAN .binman_stamp
Image 'image' has faked external blobs and is non-functional: tee.binImage 'image' is missing optional external blobs but is still functional: tee-os
/binman/section/fit/images/tee/tee-os (tee.bin):
See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.binSome images are invalid
make: *** [Makefile:1135: .binman_stamp] Error 103To solve this contradictory messaging, when checking the faked blob list, remove entries that are allowed to be missing.
This also fixes the testFitFirmwareLoadables binman test:
FAIL: testFitFirmwareLoadables (binman.ftest.TestFunctional.testFitFirmwareLoadables) Test an image with an FIT that use fit,firmware
----------------------------------------------------------------------
AssertionError: 0 != 103
Quoted 8 lines
This test failed due to the exposed bug when testing with faked external blobs.
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/control.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
Ideally your updated tests would be in this commit.
RFC PATCH 5/6 binman: test: assert optional blobs don't cause non-functionality
In reply to Yannic MoogWhen external blobs are marked optional, they should not cause a build to fail. Extend the test cases for FitTeeOsOptional and ExtblobOptional.
--- tools/binman/ftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/binman/ftest.py +16 -0
@@ -6480,6 +6480,9 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertRegex( err, "Image '.*' is missing optional external blobs but is still functional: tee-os") + self.assertNotRegex( + err, + "Image '.*' has faked external blobs and is non-functional: tee-os") def testFitTeeOsOptionalFitBad(self): """Test an image with a FIT with an optional OP-TEE binary"""
@@ -6517,6 +6520,19 @@ fdt fdtmap Extract the devicetree blob from the fdtmap err, "Image '.*' is missing optional external blobs but is still functional: missing") + def testExtblobFakedOptional(self): + """Test an image with an external blob that is optional""" + with test_util.capture_sys_output() as (stdout, stderr): + data = self._DoReadFile('266_blob_ext_opt.dts') + self.assertEqual(REFCODE_DATA, data) + err = stderr.getvalue() + self.assertRegex( + err, + "Image '.*' is missing optional external blobs but is still functional: missing") + self.assertNotRegex( + err, + "Image '.*' has faked external blobs and is non-functional: missing") + def testSectionInner(self): """Test an inner section with a size""" data = self._DoReadFile('267_section_inner.dts')
Signature · 1 line
2.43.0
Re: [PATCH RFC 5/6] binman: test: assert optional blobs don't cause non-functionality
Quoted 10 lines · Yannic Moog
When external blobs are marked optional, they should not cause a build to fail. Extend the test cases for FitTeeOsOptional and ExtblobOptional.
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/ftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
RFC PATCH 6/6 binman: doc: update Optional entries
In reply to Yannic MoogThe binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
tools/binman/binman.rst +8 -1
@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the ObtainContents() method. -The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the image is packed without it and it disappears from the list of entries.
Signature · 1 line
2.43.0
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the ObtainContents() method.
tools/binman/binman.rst called on all entries. · line 1156
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the image is packed without it and it disappears from the list of entries.
I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Quoted 20 lines · Simon Glass
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>---
tools/binman/binman.rst | 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries.It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the
ObtainContents()method.
Quoted 14 lines
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the imageis packed without it and it disappears from the list of entries.
I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
The heading is a subsection of "Optional entries". To my knowledge the "optional" property is not limited to blobs. But blobs get special treatment in regards to "optional" due to the --fake-ext- blobs option. Hence the subsection.
What would you like me to change to make this clearer?
Yannic
Quoted 3 lines
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Yannic,
Quoted 37 lines · Yannic Moog
Quoted 20 lines · Simon Glass
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the ObtainContents() method.Quoted 14 lines
tools/binman/binman.rst called on all entries. · line 1156
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the image is packed without it and it disappears from the list of entries.I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
Quoted 5 lines
The heading is a subsection of "Optional entries". To my knowledge the "optional" property is not limited to blobs. But blobs get special treatment in regards to "optional" due to the --fake-ext- blobs option. Hence the subsection.
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image when they are faked, external blobs? If so, that seems like a bug to me.
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Quoted 46 lines · Simon Glass
Hi Yannic,
Quoted 43 lines · Yannic Moog
Quoted 20 lines · Simon Glass
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>---
tools/binman/binman.rst | 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries.It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the
ObtainContents()method.Quoted 14 lines
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the imageis packed without it and it disappears from the list of entries.
I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
The heading is a subsection of "Optional entries". To my knowledge the "optional" property is not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --fake- ext-
blobs option. Hence the subsection.
Quoted 5 lines
Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image when they are faked, external blobs? If so, that seems like a bug to me.
To clarify, optional images are faked only when they are missing. So in case the image is missing, a faked image is indeed packaged into the image.
Here is the image map from an (phycore-)imx8mp build.
Missing tee-os (faked):
ImagePos Offset Size Name
00000000 00000000 00159e10 image
00000000 00000000 00159e10 section
[...]
00058000 00058000 00101e10 fit0005b000 00003000 000e4910 uboot0005b000 00000000 000e4910 blob-ext0013f910 000e7910 00008458 atf0013f910 00000000 00008458 atf-blob00147d68 000efd68 00000000 tee00147d68 00000000 00000000 tee-os
tee-os present:
ImagePos Offset Size Name
00000000 00000000 0022b5b0 image
00000000 00000000 0022b5b0 section
[...]
00058000 00058000 001d35b0 fit0005b000 00003000 000e4910 uboot0005b000 00000000 000e4910 blob-ext0013f910 000e7910 00008458 atf0013f910 00000000 00008458 atf-blob00147d68 000efd68 000d17a0 tee00147d68 00000000 000d17a0 tee-os
Yannic
Quoted 3 lines
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Yannic,
Quoted 48 lines · Yannic Moog
Quoted 46 lines · Simon Glass
Hi Yannic,
Quoted 43 lines · Yannic Moog
Quoted 20 lines · Simon Glass
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the ObtainContents() method.Quoted 14 lines
tools/binman/binman.rst called on all entries. · line 1156
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the image is packed without it and it disappears from the list of entries.I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
The heading is a subsection of "Optional entries". To my knowledge the "optional" property is not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --fake- ext-
blobs option. Hence the subsection.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image when they are faked, external blobs? If so, that seems like a bug to me.
To clarify, optional images are faked only when they are missing. So in case the image is missing, a faked image is indeed packaged into the image.
OK, but I still think it is a bug. Why add an optional thing in this way?
Quoted 30 lines
Here is the image map from an (phycore-)imx8mp build.
Missing tee-os (faked):
ImagePos Offset Size Name
00000000 0000000000159e10image
00000000 0000000000159e10section
[...]
00058000 0005800000101e10fit0005b00000003000000e4910uboot0005b00000000000000e4910blob-ext0013f910000e791000008458 atf0013f91000000000 00008458 atf-blob00147d68000efd6800000000 tee00147d6800000000 00000000 tee-ostee-os present:
ImagePos Offset Size Name
00000000 000000000022b5b0image
00000000 000000000022b5b0section
[...]
00058000 00058000001d35b0fit0005b00000003000000e4910uboot0005b00000000000000e4910blob-ext0013f910000e791000008458 atf0013f91000000000 00008458 atf-blob00147d68000efd68000d17a0tee00147d6800000000000d17a0tee-os
Quoted 3 lines
Yannic
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Simon,
Quoted 59 lines · Simon Glass
Hi Yannic,
Quoted 56 lines · Yannic Moog
Quoted 53 lines · Simon Glass
Hi Yannic,
Quoted 45 lines · Yannic Moog
Quoted 20 lines · Simon Glass
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>---
tools/binman/binman.rst | 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries.It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the
ObtainContents()method.Quoted 14 lines
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the imageis packed without it and it disappears from the list of entries.
I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
The heading is a subsection of "Optional entries". To my knowledge the "optional" property is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the -- fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image when they are faked, external blobs? If so, that seems like a bug to me.
Quoted 6 lines
Quoted 4 lines
To clarify, optional images are faked only when they are missing. So in case the image is missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?
Quoted 1 line
Why add an optional thing in this way?
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality . I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit. What do you have in mind to achieve this goal?
Yannic
Quoted 38 lines
Quoted 32 lines
Here is the image map from an (phycore-)imx8mp build.
Missing tee-os (faked):
ImagePos Offset Size Name 00000000 00000000 00159e10 image 00000000 00000000 00159e10 section [...]
00058000 00058000 00101e10 fit 0005b000 00003000 000e4910 uboot 0005b000 00000000 000e4910 blob-ext 0013f910 000e7910 00008458 atf 0013f910 00000000 00008458 atf-blob 00147d68 000efd68 00000000 tee 00147d68 00000000 00000000 tee-ostee-os present:
ImagePos Offset Size Name 00000000 00000000 0022b5b0 image 00000000 00000000 0022b5b0 section [...]
00058000 00058000 001d35b0 fit 0005b000 00003000 000e4910 uboot 0005b000 00000000 000e4910 blob-ext 0013f910 000e7910 00008458 atf 0013f910 00000000 00008458 atf-blob 00147d68 000efd68 000d17a0 tee 00147d68 00000000 000d17a0 tee-osQuoted 3 lines
Yannic
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Yannic,
Quoted 76 lines · Yannic Moog
Hi Simon,
Quoted 59 lines · Simon Glass
Hi Yannic,
Quoted 56 lines · Yannic Moog
Quoted 53 lines · Simon Glass
Hi Yannic,
Quoted 45 lines · Yannic Moog
Quoted 20 lines · Simon Glass
Quoted 19 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the sense that it does not cover blobs entry type. As this is also the most widely used type to have the optional entry, document the interaction with faking blobs.
Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absent at any other point in the processing. It must happen in the ObtainContents() method.Quoted 14 lines
tools/binman/binman.rst called on all entries. · line 1156
Quoted 10 lines
tools/binman/binman.rst +8
-1-The effect is as if the entry had never been present at all, since the image +The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed +to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entries will be faked. +If not set, it is as if the entry had never been present at all, since the image is packed without it and it disappears from the list of entries.I'm not quite following this. The text seems OK but your heading implies that things other than blobs can be faked. All of this functionality is only for blobs.
The heading is a subsection of "Optional entries". To my knowledge the "optional" property is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the -- fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image when they are faked, external blobs? If so, that seems like a bug to me.
Quoted 6 lines
Quoted 4 lines
To clarify, optional images are faked only when they are missing. So in case the image is missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?Quoted 1 line
Why add an optional thing in this way?
Quoted 8 lines
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality . I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit. What do you have in mind to achieve this goal?
I think we are talking about slightly different things.
If a binary is optional then I don't see much point in including an empty (or faked) binary. If it is the only thing missing, the image should still boot OK if it just doesn't appear in the image.
The idea with Binman is to produce a functional image, where possible. An image without an optional blob is functional, so we should not need to add it.
I'm not saying this is a big problem, just that it seems surprising and not what I intended.
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
Quoted 36 lines
Yannic
Quoted 33 lines
Quoted 33 lines
Here is the image map from an (phycore-)imx8mp build.
Missing tee-os (faked):
ImagePos Offset Size Name
00000000 0000000000159e10image
00000000 0000000000159e10section
[...]
00058000 0005800000101e10fit0005b00000003000000e4910uboot0005b00000000000000e4910blob-ext0013f910000e791000008458 atf0013f91000000000 00008458 atf-blob00147d68000efd6800000000 tee00147d6800000000 00000000 tee-ostee-os present:
ImagePos Offset Size Name
00000000 000000000022b5b0image
00000000 000000000022b5b0section
[...]
00058000 00058000001d35b0fit0005b00000003000000e4910uboot0005b00000000000000e4910blob-ext0013f910000e791000008458 atf0013f91000000000 00008458 atf-blob00147d68000efd68000d17a0tee00147d6800000000000d17a0tee-osYannic
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Quoted 120 lines · Simon Glass
Hi Yannic,
Quoted 99 lines · Yannic Moog
Hi Simon,
Quoted 79 lines · Simon Glass
Hi Yannic,
Quoted 75 lines · Yannic Moog
Quoted 72 lines · Simon Glass
Hi Yannic,
Quoted 61 lines · Yannic Moog
Quoted 40 lines · Simon Glass
Quoted 38 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the
sense that it does not cover blobs entry type. As this is also the most
widely used type to have the optional entry, document the interaction
with faking blobs.Signed-off-by Yannic Moog <[email protected]>---
tools/binman/binman.rst | 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries.It is not possible for an entry to mark itself absent at any other point in the
processing. It must happen in theObtainContents()method.-The effect is as if the entry had never been present at all, since the image
tools/binman/binman.rst +5
-0+The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed
tools/binman/binman.rst +2
-0+to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entrieswill be faked.
+If not set, it is as if the entry had never been
present at all, since the imageQuoted 8 lines
Quoted 2 lines
is packed without it and it disappears from the list of entries.
I'm not quite following this. The text seems OK but your heading
implies that things other than blobs can be faked. All of this
functionality is only for blobs.The heading is a subsection of "Optional entries". To my knowledge the "optional" property
is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --
fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image
when they are faked, external blobs? If so, that seems like a bug to
me.Quoted 7 lines
Quoted 5 lines
To clarify, optional images are faked only when they are missing. So in case the image is
missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able
to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?Quoted 1 line
Why add an optional thing in this way?
Quoted 11 lines
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it
is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality
. I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit.
What do you have in mind to achieve this goal?I think we are talking about slightly different things.
If a binary is optional then I don't see much point in including an empty (or faked) binary. If it is the only thing missing, the image should still boot OK if it just doesn't appear in the image.
Quoted 8 lines
The idea with Binman is to produce a functional image, where possible.
An image without an optional blob is functional, so we should not need
to add it.I'm not saying this is a big problem, just that it seems surprising and not what I intended.
I am with you on this. It was suprising to me, too. And I agree there is no point (at least to me) in including it in the final image. So we were talking about the same thing, I simply want to make sure we are on the same page.
Quoted 4 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
From my point of view, It would be better to stop binman from adding faked blobs than what I proposed in these RFC patches. I didn't know, however, if there was a use case for adding them to the images that I am not aware of.
Since you now confirm that it was never your intention to have them included in the first place I think we can go ahead in preventing binman from adding faked blobs to images.
I'll work on it for the next version.
Yannic
Quoted 41 lines
Quoted 38 lines
Yannic
Quoted 33 lines
Quoted 33 lines
Here is the image map from an (phycore-)imx8mp build.
Missing tee-os (faked):
ImagePos Offset Size Name 00000000 00000000 00159e10 image 00000000 00000000 00159e10 section [...]
00058000 00058000 00101e10 fit 0005b000 00003000 000e4910 uboot 0005b000 00000000 000e4910 blob-ext 0013f910 000e7910 00008458 atf 0013f910 00000000 00008458 atf-blob 00147d68 000efd68 00000000 tee 00147d68 00000000 00000000 tee-ostee-os present:
ImagePos Offset Size Name 00000000 00000000 0022b5b0 image 00000000 00000000 0022b5b0 section [...]
00058000 00058000 001d35b0 fit 0005b000 00003000 000e4910 uboot 0005b000 00000000 000e4910 blob-ext 0013f910 000e7910 00008458 atf 0013f910 00000000 00008458 atf-blob 00147d68 000efd68 000d17a0 tee 00147d68 00000000 000d17a0 tee-osYannic
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Yannic,
Quoted 141 lines · Yannic Moog
Quoted 120 lines · Simon Glass
Hi Yannic,
Quoted 99 lines · Yannic Moog
Hi Simon,
Quoted 79 lines · Simon Glass
Hi Yannic,
Quoted 75 lines · Yannic Moog
Quoted 72 lines · Simon Glass
Hi Yannic,
Quoted 61 lines · Yannic Moog
Quoted 40 lines · Simon Glass
Quoted 38 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the
sense that it does not cover blobs entry type. As this is also the most
widely used type to have the optional entry, document the interaction
with faking blobs.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absentat any other point in the
processing. It must happen in theObtainContents()
method.-The effect is as if the entry had never been present at all, since the image
tools/binman/binman.rst +5
-0+The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed
tools/binman/binman.rst +2
-0+to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entrieswill be faked.
+If not set, it is as if the entry had never been
present at all, since the imageQuoted 8 lines
Quoted 2 lines
is packed without it and it disappears from the list
of entries.I'm not quite following this. The text seems OK but your heading
implies that things other than blobs can be faked. All of this
functionality is only for blobs.The heading is a subsection of "Optional entries". To my knowledge the "optional" property
is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --
fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image
when they are faked, external blobs? If so, that seems like a bug to
me.Quoted 7 lines
Quoted 5 lines
To clarify, optional images are faked only when they are missing. So in case the image is
missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able
to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?Quoted 1 line
Why add an optional thing in this way?
Quoted 11 lines
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it
is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality
. I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit.
What do you have in mind to achieve this goal?I think we are talking about slightly different things.
If a binary is optional then I don't see much point in including an empty (or faked) binary. If it is the only thing missing, the image should still boot OK if it just doesn't appear in the image.
Quoted 8 lines
The idea with Binman is to produce a functional image, where possible.
An image without an optional blob is functional, so we should not need
to add it.I'm not saying this is a big problem, just that it seems surprising and not what I intended.
I am with you on this. It was suprising to me, too. And I agree there is no point (at least to me) in including it in the final image. So we were talking about the same thing, I simply want to make sure we are on the same page.
Quoted 4 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
Quoted 8 lines
From my point of view, It would be better to stop binman from adding faked blobs than what I proposed in these RFC patches. I didn't know, however, if there was a use case for adding them to the images that I am not aware of.
Since you now confirm that it was never your intention to have them included in the first place I think we can go ahead in preventing binman from adding faked blobs to images.
I'll work on it for the next version.
Thanks, and also for spotting this.
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Yannic,
Quoted 154 lines · Simon Glass
Hi Yannic,
Quoted 141 lines · Yannic Moog
Quoted 120 lines · Simon Glass
Hi Yannic,
Quoted 99 lines · Yannic Moog
Hi Simon,
Quoted 79 lines · Simon Glass
Hi Yannic,
Quoted 75 lines · Yannic Moog
Quoted 72 lines · Simon Glass
Hi Yannic,
Quoted 61 lines · Yannic Moog
Quoted 40 lines · Simon Glass
Quoted 38 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the
sense that it does not cover blobs entry type. As this is also the most
widely used type to have the optional entry, document the interaction
with faking blobs.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absentat any other point in the
processing. It must happen in theObtainContents()
method.-The effect is as if the entry had never been present at all, since the image
tools/binman/binman.rst +5
-0+The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed
tools/binman/binman.rst +2
-0+to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entrieswill be faked.
+If not set, it is as if the entry had never been
present at all, since the imageQuoted 8 lines
Quoted 2 lines
is packed without it and it disappears from the list
of entries.I'm not quite following this. The text seems OK but your heading
implies that things other than blobs can be faked. All of this
functionality is only for blobs.The heading is a subsection of "Optional entries". To my knowledge the "optional" property
is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --
fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image
when they are faked, external blobs? If so, that seems like a bug to
me.Quoted 7 lines
Quoted 5 lines
To clarify, optional images are faked only when they are missing. So in case the image is
missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able
to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?Quoted 1 line
Why add an optional thing in this way?
Quoted 11 lines
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it
is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality
. I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit.
What do you have in mind to achieve this goal?I think we are talking about slightly different things.
If a binary is optional then I don't see much point in including an empty (or faked) binary. If it is the only thing missing, the image should still boot OK if it just doesn't appear in the image.
Quoted 8 lines
The idea with Binman is to produce a functional image, where possible.
An image without an optional blob is functional, so we should not need
to add it.I'm not saying this is a big problem, just that it seems surprising and not what I intended.
I am with you on this. It was suprising to me, too. And I agree there is no point (at least to me) in including it in the final image. So we were talking about the same thing, I simply want to make sure we are on the same page.
Quoted 4 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
Quoted 8 lines
From my point of view, It would be better to stop binman from adding faked blobs than what I proposed in these RFC patches. I didn't know, however, if there was a use case for adding them to the images that I am not aware of.
Since you now confirm that it was never your intention to have them included in the first place I think we can go ahead in preventing binman from adding faked blobs to images.
I'll work on it for the next version.
Quoted 1 line
Thanks, and also for spotting this.
Did you ever get back to this series? I'd like to get it in if we can.
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Simon,
Am Dienstag, dem 27.05.2025 um 08:34 +0100 schrieb Simon Glass:
Quoted 157 lines
Hi Yannic,
Quoted 154 lines · Simon Glass
Hi Yannic,
Quoted 149 lines · Yannic Moog
Quoted 120 lines · Simon Glass
Hi Yannic,
Quoted 99 lines · Yannic Moog
Hi Simon,
Quoted 79 lines · Simon Glass
Hi Yannic,
Quoted 75 lines · Yannic Moog
Quoted 72 lines · Simon Glass
Hi Yannic,
Quoted 61 lines · Yannic Moog
Quoted 40 lines · Simon Glass
Quoted 38 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the
sense that it does not cover blobs entry type. As this is also the most
widely used type to have the optional entry, document the interaction
with faking blobs.Signed-off-by Yannic Moog <[email protected]>---
tools/binman/binman.rst | 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries.It is not possible for an entry to mark itself absent at any other point in the
processing. It must happen in theObtainContents()method.-The effect is as if the entry had never been present at all, since the image
tools/binman/binman.rst +5
-0+The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed
tools/binman/binman.rst +2
-0+to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entrieswill be faked.
+If not set, it is as if the entry had never been
present at all, since the imageQuoted 8 lines
Quoted 2 lines
is packed without it and it disappears from the list of entries.
I'm not quite following this. The text seems OK but your heading
implies that things other than blobs can be faked. All of this
functionality is only for blobs.The heading is a subsection of "Optional entries". To my knowledge the "optional" property
is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --
fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image
when they are faked, external blobs? If so, that seems like a bug to
me.Quoted 7 lines
Quoted 5 lines
To clarify, optional images are faked only when they are missing. So in case the image is
missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able
to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?Quoted 1 line
Why add an optional thing in this way?
Quoted 11 lines
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it
is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality
. I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit.
What do you have in mind to achieve this goal?I think we are talking about slightly different things.
If a binary is optional then I don't see much point in including an empty (or faked) binary. If it is the only thing missing, the image should still boot OK if it just doesn't appear in the image.
Quoted 8 lines
The idea with Binman is to produce a functional image, where possible.
An image without an optional blob is functional, so we should not need
to add it.I'm not saying this is a big problem, just that it seems surprising and not what I intended.
I am with you on this. It was suprising to me, too. And I agree there is no point (at least to me) in including it in the final image. So we were talking about the same thing, I simply want to make sure we are on the same page.
Quoted 4 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
From my point of view, It would be better to stop binman from adding faked blobs than what I proposed in these RFC patches. I didn't know, however, if there was a use case for adding them to the images that I am not aware of.
Since you now confirm that it was never your intention to have them included in the first place I think we can go ahead in preventing binman from adding faked blobs to images.
I'll work on it for the next version.
Quoted 3 lines
Quoted 1 line
Thanks, and also for spotting this.
Did you ever get back to this series? I'd like to get it in if we can.
Yes, however I took a break due to other work.
Anyway, I had taken a look at it the other day and found it very difficult to get the GetEntries(omit_optional=True) route working as it only goes 1 level deep in the "entries" tree and we pack and write the image in multiple steps. Essentially, we would have to make a copy of the whole tree as far as I understand (one copy including absent images and one excluding absent images).
Quoted 5 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
Imo keeping the drop_absent function and adjusting the tests is a more promising solution; less complex. We could only drop optional images but then still have faked blobs in the final binman image afaik; rename drop_absent to drop_optional_absent?
Yannic
Quoted 3 lines
Regards,
Simon
Re: [PATCH RFC 6/6] binman: doc: update Optional entries
Hi Yannic,
Quoted 178 lines · Yannic Moog
Hi Simon,
Am Dienstag, dem 27.05.2025 um 08:34 +0100 schrieb Simon Glass:
Quoted 157 lines
Hi Yannic,
Quoted 154 lines · Simon Glass
Hi Yannic,
Quoted 149 lines · Yannic Moog
Quoted 120 lines · Simon Glass
Hi Yannic,
Quoted 99 lines · Yannic Moog
Hi Simon,
Quoted 79 lines · Simon Glass
Hi Yannic,
Quoted 75 lines · Yannic Moog
Quoted 72 lines · Simon Glass
Hi Yannic,
Quoted 61 lines · Yannic Moog
Quoted 40 lines · Simon Glass
Quoted 38 lines · Yannic Moog
The binman documentation of Optional entries is not accurate in the
sense that it does not cover blobs entry type. As this is also the most
widely used type to have the optional entry, document the interaction
with faking blobs.Signed-off-by Yannic Moog <[email protected]>--- tools/binman/binman.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)tools/binman/binman.rst +0
-0@@ -1145,7 +1145,14 @@ called on all entries. It is not possible for an entry to mark itself absentat any other point in the
processing. It must happen in theObtainContents()
method.-The effect is as if the entry had never been present at all, since the image
tools/binman/binman.rst +5
-0+The effect depends on the type of entry. + +Blobs +~~~~~ +For blobs, the effect depends on whether --fake-ext-blobs is passed
tools/binman/binman.rst +2
-0+to binman. (This is the case by default) +In case --fake-ext-blobs is set, any missing entrieswill be faked.
+If not set, it is as if the entry had never been
present at all, since the imageQuoted 8 lines
Quoted 2 lines
is packed without it and it disappears from the list
of entries.I'm not quite following this. The text seems OK but your heading
implies that things other than blobs can be faked. All of this
functionality is only for blobs.The heading is a subsection of "Optional entries". To my knowledge the "optional" property
is
not
limited to blobs. But blobs get special treatment in regards to "optional" due to the --
fake-
ext-
blobs option. Hence the subsection.Quoted 1 line
What would you like me to change to make this clearer?
Oh I see. Are you saying that optional entries end up in the image
when they are faked, external blobs? If so, that seems like a bug to
me.Quoted 7 lines
Quoted 5 lines
To clarify, optional images are faked only when they are missing. So in case the image is
missing, a
faked image is indeed packaged into the image.OK, but I still think it is a bug.
I didn't question your judgement, I simply don't have the broader goal of binman in mind to be able
to judge if this behaviour is unintended.
What should happen instead? Should the image simply be absent in the final image?Quoted 1 line
Why add an optional thing in this way?
Quoted 11 lines
Because it seems like a simple, elegant solution.
To elaborate:
The goal (in case of OP-TEE) is to have the binary packaged when its there and not packaged when it
is not present.
Precisely because it is not required for a bootable image, but may be added to enhance functionality
. I.e. it is optional.
I found the U-Boot doc to explain optional entries and thought it to be a perfect fit.
What do you have in mind to achieve this goal?I think we are talking about slightly different things.
If a binary is optional then I don't see much point in including an empty (or faked) binary. If it is the only thing missing, the image should still boot OK if it just doesn't appear in the image.
Quoted 8 lines
The idea with Binman is to produce a functional image, where possible.
An image without an optional blob is functional, so we should not need
to add it.I'm not saying this is a big problem, just that it seems surprising and not what I intended.
I am with you on this. It was suprising to me, too. And I agree there is no point (at least to me) in including it in the final image. So we were talking about the same thing, I simply want to make sure we are on the same page.
Quoted 4 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
From my point of view, It would be better to stop binman from adding faked blobs than what I proposed in these RFC patches. I didn't know, however, if there was a use case for adding them to the images that I am not aware of.
Since you now confirm that it was never your intention to have them included in the first place I think we can go ahead in preventing binman from adding faked blobs to images.
I'll work on it for the next version.Quoted 3 lines
Quoted 1 line
Thanks, and also for spotting this.
Did you ever get back to this series? I'd like to get it in if we can.
Yes, however I took a break due to other work.
Anyway, I had taken a look at it the other day and found it very difficult to get theGetEntries(omit_optional=True)route working as it only goes 1 level deep in the "entries" tree and we pack and write the image in multiple steps. Essentially, we would have to make a copy of the whole tree as far as I understand (one copy including absent images and one excluding absent images).Quoted 5 lines
Perhaps we do need to fake the blob in case it is used by some other tool. But I wonder if we can stop Binman adding the faked blob into the image, if it is optional?
Quoted 4 lines
Imo keeping the
drop_absentfunction and adjusting the tests is a more promising solution; less complex. We could only drop optional images but then still have faked blobs in the final binman image afaik; renamedrop_absenttodrop_optional_absent?
OK, can you please send it again and I'll take a look?
Regards,
SImon
Hi Yannic,
Quoted 49 lines · Yannic Moog
This series solves a contradiction regarding ext blobs packaged in binman. When they are marked as optional, by default they are faked, two messages are emitted. One says the image is not functional the other says the image is still functional. Both concern the same binman entry/blob. To solve this, don't emit a warning when an image is faked AND optional.
Make binman tests consistent with this behaviour.
Add regex to test cases checking that the non-functional message is indeed not emitted. Update the documentation to inform users of this interaction.Binman is set up to have fake external blobs in case they are missing. This is regardless on whether they are optional or not.
The implementation does not allow different types of entries to override the faking decision; at least there wouldn't be much sense in doing so.Here is an example build output of a phycore-imx8mp:
BINMAN .binman_stamp
Image 'image' is missing optional external blobs but is still functional: tee-os/binman/section/fit/images/tee/tee-os (tee.bin):
See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.binImage 'image' has faked optional external blobs and is still functional: tee.bin
OFCHK .config
The first patch makes binman test with --fake_ext_blobs by default to be consistent with the default make target when building U-Boot. This exposes an error as one test is failing where it should not (loadables). Then, fix some tests that must not fake ext blobs and thus failed due to the change.
Further, fix the behaviour of binman itself as explained above. Fixing this bug also makes the loadables test pass again.
Finally, add test coverage for this new case and extend the documentation.---
Yannic Moog (6):
tools: binman:ftest.py: fake ext blobs per default
tools: binman: ftest: passallow_fake_blobto_DoReadFileDtb
tools: binman: ftest: fix tests that require non-faked ext blobs
binman: fix faked optional entry handling
binman: test: assert optional blobs don't cause non-functionality
binman: doc: update Optional entries
Quoted 7 lines
tools/binman/binman.rst | 9 ++++++++- tools/binman/control.py | 19 ++++++++++++++++--- tools/binman/ftest.py | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 15 deletions(-)---
base-commit:a2b489b170f8382f746202c36616eaf2bc38fe86
change-id: 20250122-binman_faked_optional-5025f7046e25
Thank you for looking at this.
Regards,
SImon