binman: Support reading an image with entry args

Normally when an entry is created, any entry arguments it has are required
to be provided, so it can actually generate its contents correctly.

However when an existing image is read, Entry objects are created for each
of the entries in the image. This happens as part of the process of
reading the image into binman.

In this case we don't need the entry arguments, since we do not intend to
regenerate the entries, or at least not unless requested. So there is no
sense in reporting an error for missing entry arguments.

Add a new property for the Image to handle this case. Update the error
reporting to be conditional on this property.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 5016060..8b928eb 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -4154,6 +4154,25 @@
                     U_BOOT_SPL_DATA[20:])
         self.assertEqual(expected, data)
 
+    def testReadImageEntryArg(self):
+        """Test reading an image that would need an entry arg to generate"""
+        entry_args = {
+            'cros-ec-rw-path': 'ecrw.bin',
+        }
+        data = self.data = self._DoReadFileDtb(
+            '188_image_entryarg.dts',use_real_dtb=True, update_dtb=True,
+            entry_args=entry_args)
+
+        image_fname = tools.GetOutputFilename('image.bin')
+        orig_image = control.images['image']
+
+        # This should not generate an error about the missing 'cros-ec-rw-path'
+        # since we are reading the image from a file. Compare with
+        # testEntryArgsRequired()
+        image = Image.FromFile(image_fname)
+        self.assertEqual(orig_image.GetEntries().keys(),
+                         image.GetEntries().keys())
+
 
 if __name__ == "__main__":
     unittest.main()