[U-Boot,2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
diff mbox series

Message ID 20190917210935.3666-2-afd@ti.com
State New
Delegated to: Tom Rini
Headers show
Series
  • [U-Boot,1/3] tools: dumpimage: Provide more feedback on internal errors
Related show

Commit Message

Andrew F. Davis Sept. 17, 2019, 9:09 p.m. UTC
This is very similar to fit_image_get_data but has the benefit of working
on FIT images with external data unlike fit_image_get_data. This is
useful for extracting sub-images from type of FIT image as this would
previously just silently fail. Add an error message also so if this
still fails it is easier to find out why.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 tools/fit_image.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Lokesh Vutla Nov. 14, 2019, 11:46 a.m. UTC | #1
On 18/09/19 2:39 AM, Andrew F. Davis wrote:
> This is very similar to fit_image_get_data but has the benefit of working
> on FIT images with external data unlike fit_image_get_data. This is
> useful for extracting sub-images from type of FIT image as this would
> previously just silently fail. Add an error message also so if this
> still fails it is easier to find out why.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

Patch
diff mbox series

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 5aca634b5e..0e4c2271ce 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -738,9 +738,14 @@  static int fit_image_extract(
 {
 	const void *file_data;
 	size_t file_size = 0;
+	int ret;
 
-	/* get the "data" property of component at offset "image_noffset" */
-	fit_image_get_data(fit, image_noffset, &file_data, &file_size);
+	/* get the data address and size of component at offset "image_noffset" */
+	ret = fit_image_get_data_and_size(fit, image_noffset, &file_data, &file_size);
+	if (ret) {
+		fprintf(stderr, "Could not get component information\n");
+		return ret;
+	}
 
 	/* save the "file_data" into the file specified by "file_name" */
 	return imagetool_save_subimage(file_name, (ulong) file_data, file_size);