All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/4] Add dumpimage tool to extract files from U-Boot images
@ 2013-12-01 19:43 Simon Glass
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 1/4] mkimage: added 'static' specifier to match function's prototype Simon Glass
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Simon Glass @ 2013-12-01 19:43 UTC (permalink / raw)
  To: u-boot

This new dumpimage tool makes it easy to unpack images created by mkimage.

The tool was written by:

   Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>

I have tidied it up a little and resubmitted it, since no response was
received to my earlier email.

You can review this change here (complete with patman tags):

https://u-boot-review.googlesource.com/#/c/1538/

Changes in v2:
- Add additional -o option for when the file name is not valid
- Correct checkpatch problems
- Tidy up shell script style a little
- Updated test to include coverage for the new -o option

Guilherme Maciel Ferreira (4):
  mkimage: added 'static' specifier to match function's prototype.
  tools: moved code common to all image tools to a separated module.
  Add dumpimage, a tool to extract data from U-Boot images
  sandbox: dumpimage: Test dumpimage

 Makefile                      |   1 +
 README                        |   9 ++
 test/image/test-imagetools.sh | 141 +++++++++++++++++++
 tools/.gitignore              |   1 +
 tools/Makefile                |  28 ++++
 tools/aisimage.c              |  16 +--
 tools/default_image.c         |  67 +++++++++-
 tools/dumpimage.c             | 305 ++++++++++++++++++++++++++++++++++++++++++
 tools/dumpimage.h             |  33 +++++
 tools/fit_image.c             |  11 +-
 tools/imagetool.c             |  58 ++++++++
 tools/imagetool.h             | 173 ++++++++++++++++++++++++
 tools/imximage.c              |  12 +-
 tools/kwbimage.c              |  10 +-
 tools/mkimage.c               |  25 +---
 tools/mkimage.h               | 123 +----------------
 tools/mxsimage.c              |  12 +-
 tools/omapimage.c             |  10 +-
 tools/pblimage.c              |  10 +-
 tools/ublimage.c              |  10 +-
 20 files changed, 862 insertions(+), 193 deletions(-)
 create mode 100755 test/image/test-imagetools.sh
 create mode 100644 tools/dumpimage.c
 create mode 100644 tools/dumpimage.h
 create mode 100644 tools/imagetool.c
 create mode 100644 tools/imagetool.h

-- 
1.8.4.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 1/4] mkimage: added 'static' specifier to match function's prototype.
  2013-12-01 19:43 [U-Boot] [PATCH v2 0/4] Add dumpimage tool to extract files from U-Boot images Simon Glass
@ 2013-12-01 19:43 ` Simon Glass
  2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 2/4] tools: moved code common to all image tools to a separated module Simon Glass
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2013-12-01 19:43 UTC (permalink / raw)
  To: u-boot

From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>

This function should be declared static.

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Correct checkpatch problems

 tools/mkimage.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/mkimage.c b/tools/mkimage.c
index 7f22101..e12bc31 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -632,8 +632,7 @@ copy_file (int ifd, const char *datafile, int pad)
 	(void) close (dfd);
 }
 
-void
-usage ()
+static void usage(void)
 {
 	fprintf (stderr, "Usage: %s -l image\n"
 			 "          -l ==> list image header information\n",
-- 
1.8.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 2/4] tools: moved code common to all image tools to a separated module.
  2013-12-01 19:43 [U-Boot] [PATCH v2 0/4] Add dumpimage tool to extract files from U-Boot images Simon Glass
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 1/4] mkimage: added 'static' specifier to match function's prototype Simon Glass
@ 2013-12-01 19:43 ` Simon Glass
  2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images Simon Glass
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 4/4] sandbox: dumpimage: Test dumpimage Simon Glass
  3 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2013-12-01 19:43 UTC (permalink / raw)
  To: u-boot

From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>

In order to avoid duplicating code and keep only one point of modification,
the functions, structs and defines useful for "dumpimage" were moved from
"mkimage" to a common module called "imagetool".

This modification also weakens the coupling between image types (FIT, IMX, MXS,
and so on) and image tools (mkimage and dumpimage). Any tool may initialize the
"imagetool" through register_image_tool() function, while the image types
register themselves within an image tool using the register_image_type()
function:

                                                      +---------------+
                                               +------|   fit_image   |
 +--------------+          +-----------+       |      +---------------+
 |    mkimage   |--------> |           | <-----+
 +--------------+          |           |              +---------------+
                           | imagetool | <------------|    imximage   |
 +--------------+          |           |              +---------------+
 |  dumpimage   |--------> |           | <-----+
 +--------------+          +-----------+       |      +---------------+
                                               +------| default_image |
                                                      +---------------+

          register_image_tool()           register_image_type()

Also, the struct "mkimage_params" was renamed to "image_tool_params" to make
clear its general purpose.

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Correct checkpatch problems

 tools/Makefile        |   2 +
 tools/aisimage.c      |  16 ++---
 tools/default_image.c |  10 ++--
 tools/fit_image.c     |  11 ++--
 tools/imagetool.c     |  58 ++++++++++++++++++
 tools/imagetool.h     | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/imximage.c      |  12 ++--
 tools/kwbimage.c      |  10 ++--
 tools/mkimage.c       |  22 +------
 tools/mkimage.h       | 123 +-------------------------------------
 tools/mxsimage.c      |  12 ++--
 tools/omapimage.c     |  10 ++--
 tools/pblimage.c      |  10 ++--
 tools/ublimage.c      |  10 ++--
 14 files changed, 276 insertions(+), 191 deletions(-)
 create mode 100644 tools/imagetool.c
 create mode 100644 tools/imagetool.h

diff --git a/tools/Makefile b/tools/Makefile
index 14d94e3..154eae3 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -76,6 +76,7 @@ NOPED_OBJ_FILES-y += fit_image.o
 NOPED_OBJ_FILES-y += image-host.o
 NOPED_OBJ_FILES-y += imximage.o
 NOPED_OBJ_FILES-y += kwbimage.o
+NOPED_OBJ_FILES-y += imagetool.o
 NOPED_OBJ_FILES-y += mkenvimage.o
 NOPED_OBJ_FILES-y += mkimage.o
 NOPED_OBJ_FILES-y += mxsimage.o
@@ -212,6 +213,7 @@ $(obj)mkimage$(SFX):	$(obj)aisimage.o \
 			$(obj)image-fit.o \
 			$(obj)image-host.o \
 			$(obj)image.o \
+			$(obj)imagetool.o \
 			$(obj)imximage.o \
 			$(obj)kwbimage.o \
 			$(obj)md5.o \
diff --git a/tools/aisimage.c b/tools/aisimage.c
index 04fb649..8de370a 100644
--- a/tools/aisimage.c
+++ b/tools/aisimage.c
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include "aisimage.h"
 #include <image.h>
 
@@ -176,7 +176,7 @@ static uint32_t *ais_insert_cmd_header(uint32_t cmd, uint32_t nargs,
 
 }
 
-static uint32_t *ais_alloc_buffer(struct mkimage_params *params)
+static uint32_t *ais_alloc_buffer(struct image_tool_params *params)
 {
 	int dfd;
 	struct stat sbuf;
@@ -216,7 +216,7 @@ static uint32_t *ais_alloc_buffer(struct mkimage_params *params)
 	return ptr;
 }
 
-static uint32_t *ais_copy_image(struct mkimage_params *params,
+static uint32_t *ais_copy_image(struct image_tool_params *params,
 	uint32_t *aisptr)
 
 {
@@ -252,7 +252,7 @@ static uint32_t *ais_copy_image(struct mkimage_params *params,
 
 }
 
-static int aisimage_generate(struct mkimage_params *params,
+static int aisimage_generate(struct image_tool_params *params,
 	struct image_type_params *tparams)
 {
 	FILE *fd = NULL;
@@ -370,7 +370,7 @@ static int aisimage_check_image_types(uint8_t type)
 }
 
 static int aisimage_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct ais_header *ais_hdr = (struct ais_header *)ptr;
 
@@ -384,11 +384,11 @@ static int aisimage_verify_header(unsigned char *ptr, int image_size,
 }
 
 static void aisimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 }
 
-int aisimage_check_params(struct mkimage_params *params)
+int aisimage_check_params(struct image_tool_params *params)
 {
 	if (!params)
 		return CFG_INVALID;
@@ -427,5 +427,5 @@ static struct image_type_params aisimage_params = {
 
 void init_ais_image_type(void)
 {
-	mkimage_register(&aisimage_params);
+	register_image_type(&aisimage_params);
 }
diff --git a/tools/default_image.c b/tools/default_image.c
index fd8b9f5..cc790b2 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -14,7 +14,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include <u-boot/crc.h>
 
@@ -29,7 +29,7 @@ static int image_check_image_types(uint8_t type)
 		return EXIT_FAILURE;
 }
 
-static int image_check_params(struct mkimage_params *params)
+static int image_check_params(struct image_tool_params *params)
 {
 	return	((params->dflag && (params->fflag || params->lflag)) ||
 		(params->fflag && (params->dflag || params->lflag)) ||
@@ -37,7 +37,7 @@ static int image_check_params(struct mkimage_params *params)
 }
 
 static int image_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	uint32_t len;
 	const unsigned char *data;
@@ -86,7 +86,7 @@ static int image_verify_header(unsigned char *ptr, int image_size,
 }
 
 static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 	uint32_t checksum;
 
@@ -133,5 +133,5 @@ static struct image_type_params defimage_params = {
 
 void init_default_image_type(void)
 {
-	mkimage_register(&defimage_params);
+	register_image_type(&defimage_params);
 }
diff --git a/tools/fit_image.c b/tools/fit_image.c
index 0400a60..1466164 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -14,6 +14,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include "imagetool.h"
 #include "mkimage.h"
 #include <image.h>
 #include <u-boot/crc.h>
@@ -21,7 +22,7 @@
 static image_header_t header;
 
 static int fit_verify_header (unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	return fdt_check_header(ptr);
 }
@@ -34,7 +35,7 @@ static int fit_check_image_types (uint8_t type)
 		return EXIT_FAILURE;
 }
 
-int mmap_fdt(struct mkimage_params *params, const char *fname, void **blobp,
+int mmap_fdt(struct image_tool_params *params, const char *fname, void **blobp,
 		struct stat *sbuf)
 {
 	void *ptr;
@@ -88,7 +89,7 @@ int mmap_fdt(struct mkimage_params *params, const char *fname, void **blobp,
  * returns:
  *     only on success, otherwise calls exit (EXIT_FAILURE);
  */
-static int fit_handle_file (struct mkimage_params *params)
+static int fit_handle_file(struct image_tool_params *params)
 {
 	char tmpfile[MKIMAGE_MAX_TMPFILE_LEN];
 	char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN];
@@ -184,7 +185,7 @@ err_system:
 	return -1;
 }
 
-static int fit_check_params (struct mkimage_params *params)
+static int fit_check_params(struct image_tool_params *params)
 {
 	return	((params->dflag && (params->fflag || params->lflag)) ||
 		(params->fflag && (params->dflag || params->lflag)) ||
@@ -205,5 +206,5 @@ static struct image_type_params fitimage_params = {
 
 void init_fit_image_type (void)
 {
-	mkimage_register (&fitimage_params);
+	register_image_type(&fitimage_params);
 }
diff --git a/tools/imagetool.c b/tools/imagetool.c
new file mode 100644
index 0000000..29d2189
--- /dev/null
+++ b/tools/imagetool.c
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2013
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include "imagetool.h"
+
+/*
+ * Callback function to register a image type within a tool
+ */
+static imagetool_register_t register_func;
+
+/*
+ * register_image_tool -
+ *
+ * The tool provides its own registration function in order to all image
+ * types initialize themselves.
+ */
+void register_image_tool(imagetool_register_t image_register)
+{
+	/*
+	 * Save the image tool callback function. It will be used to register
+	 * image types within that tool
+	 */
+	register_func = image_register;
+
+	/* Init Freescale PBL Boot image generation/list support */
+	init_pbl_image_type();
+	/* Init Kirkwood Boot image generation/list support */
+	init_kwb_image_type();
+	/* Init Freescale imx Boot image generation/list support */
+	init_imx_image_type();
+	/* Init Freescale mxs Boot image generation/list support */
+	init_mxs_image_type();
+	/* Init FIT image generation/list support */
+	init_fit_image_type();
+	/* Init TI OMAP Boot image generation/list support */
+	init_omap_image_type();
+	/* Init Default image generation/list support */
+	init_default_image_type();
+	/* Init Davinci UBL support */
+	init_ubl_image_type();
+	/* Init Davinci AIS support */
+	init_ais_image_type();
+}
+
+/*
+ * register_image_type -
+ *
+ * Register a image type within a tool
+ */
+void register_image_type(struct image_type_params *tparams)
+{
+	register_func(tparams);
+}
diff --git a/tools/imagetool.h b/tools/imagetool.h
new file mode 100644
index 0000000..b8adb61
--- /dev/null
+++ b/tools/imagetool.h
@@ -0,0 +1,161 @@
+/*
+ * (C) Copyright 2013
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _IMAGETOOL_H_
+#define _IMAGETOOL_H_
+
+#include "os_support.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+#include <sha1.h>
+#include "fdt_host.h"
+
+#define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
+
+#define IH_ARCH_DEFAULT		IH_ARCH_INVALID
+
+/*
+ * This structure defines all such variables those are initialized by
+ * mkimage and dumpimage main core and need to be referred by image
+ * type specific functions
+ */
+struct image_tool_params {
+	int dflag;
+	int eflag;
+	int fflag;
+	int lflag;
+	int vflag;
+	int xflag;
+	int skipcpy;
+	int os;
+	int arch;
+	int type;
+	int comp;
+	char *dtc;
+	unsigned int addr;
+	unsigned int ep;
+	char *imagename;
+	char *imagename2;
+	char *datafile;
+	char *imagefile;
+	char *cmdname;
+	const char *keydir;	/* Directory holding private keys */
+	const char *keydest;	/* Destination .dtb for public key */
+	const char *comment;	/* Comment to add to signature node */
+	int require_keys;	/* 1 to mark signing keys as 'required' */
+};
+
+/*
+ * image type specific variables and callback functions
+ */
+struct image_type_params {
+	/* name is an identification tag string for added support */
+	char *name;
+	/*
+	 * header size is local to the specific image type to be supported,
+	 * mkimage core treats this as number of bytes
+	 */
+	uint32_t header_size;
+	/* Image type header pointer */
+	void *hdr;
+	/*
+	 * There are several arguments that are passed on the command line
+	 * and are registered as flags in image_tool_params structure.
+	 * This callback function can be used to check the passed arguments
+	 * are in-lined with the image type to be supported
+	 *
+	 * Returns 1 if parameter check is successful
+	 */
+	int (*check_params) (struct image_tool_params *);
+	/*
+	 * This function is used by list command (i.e. mkimage -l <filename>)
+	 * image type verification code must be put here
+	 *
+	 * Returns 0 if image header verification is successful
+	 * otherwise, returns respective negative error codes
+	 */
+	int (*verify_header) (unsigned char *, int, struct image_tool_params *);
+	/* Prints image information abstracting from image header */
+	void (*print_header) (const void *);
+	/*
+	 * The header or image contents need to be set as per image type to
+	 * be generated using this callback function.
+	 * further output file post processing (for ex. checksum calculation,
+	 * padding bytes etc..) can also be done in this callback function.
+	 */
+	void (*set_header) (void *, struct stat *, int,
+					struct image_tool_params *);
+	/*
+	 * Some image generation support for ex (default image type) supports
+	 * more than one type_ids, this callback function is used to check
+	 * whether input (-T <image_type>) is supported by registered image
+	 * generation/list low level code
+	 */
+	int (*check_image_type) (uint8_t);
+	/* This callback function will be executed if fflag is defined */
+	int (*fflag_handle) (struct image_tool_params *);
+	/*
+	 * This callback function will be executed for variable size record
+	 * It is expected to build this header in memory and return its length
+	 * and a pointer to it by using image_type_params.header_size and
+	 * image_type_params.hdr. The return value shall indicate if an
+	 * additional padding should be used when copying the data image
+	 * by returning the padding length.
+	 */
+	int (*vrec_header) (struct image_tool_params *,
+		struct image_type_params *);
+	/* pointer to the next registered entry in linked list */
+	struct image_type_params *next;
+};
+
+/*
+ * Tool registration function.
+ */
+typedef void (*imagetool_register_t)(struct image_type_params *);
+
+/*
+ * Initializes all image types with the given registration callback
+ * function.
+ * An image tool uses this function to initialize all image types.
+ */
+void register_image_tool(imagetool_register_t image_register);
+
+/*
+ * Register a image type within a tool.
+ * An image type uses this function to register itself within
+ * all tools.
+ */
+void register_image_type(struct image_type_params *tparams);
+
+/*
+ * There is a c file associated with supported image type low level code
+ * for ex. default_image.c, fit_image.c
+ * init_xxx_type() is the only function referred by image tool core to avoid
+ * a single lined header file, you can define them here
+ *
+ * Supported image types init functions
+ */
+void init_default_image_type(void);
+void init_pbl_image_type(void);
+void init_ais_image_type(void);
+void init_kwb_image_type(void);
+void init_imx_image_type(void);
+void init_mxs_image_type(void);
+void init_fit_image_type(void);
+void init_ubl_image_type(void);
+void init_omap_image_type(void);
+
+void pbl_load_uboot(int fd, struct image_tool_params *mparams);
+
+#endif /* _IMAGETOOL_H_ */
diff --git a/tools/imximage.c b/tools/imximage.c
index 511e3f2..18dc051 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -9,7 +9,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "imximage.h"
 
@@ -520,7 +520,7 @@ static int imximage_check_image_types(uint8_t type)
 }
 
 static int imximage_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct imx_header *imx_hdr = (struct imx_header *) ptr;
 
@@ -549,7 +549,7 @@ static void imximage_print_header(const void *ptr)
 }
 
 static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 	struct imx_header *imxhdr = (struct imx_header *)ptr;
 	uint32_t dcd_len;
@@ -589,7 +589,7 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
 	}
 }
 
-int imximage_check_params(struct mkimage_params *params)
+int imximage_check_params(struct image_tool_params *params)
 {
 	if (!params)
 		return CFG_INVALID;
@@ -611,7 +611,7 @@ int imximage_check_params(struct mkimage_params *params)
 		(params->xflag) || !(strlen(params->imagename));
 }
 
-static int imximage_generate(struct mkimage_params *params,
+static int imximage_generate(struct image_tool_params *params,
 	struct image_type_params *tparams)
 {
 	struct imx_header *imxhdr;
@@ -701,5 +701,5 @@ static struct image_type_params imximage_params = {
 
 void init_imx_image_type(void)
 {
-	mkimage_register(&imximage_params);
+	register_image_type(&imximage_params);
 }
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index 1df6b20..109d616 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "kwbimage.h"
 
@@ -54,7 +54,7 @@ static int lineno = -1;
 /*
  * Report Error if xflag is set in addition to default
  */
-static int kwbimage_check_params (struct mkimage_params *params)
+static int kwbimage_check_params(struct image_tool_params *params)
 {
 	if (!strlen (params->imagename)) {
 		printf ("Error:%s - Configuration file not specified, "
@@ -288,7 +288,7 @@ INVL_CMD:
 }
 
 static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 	struct kwb_header *hdr = (struct kwb_header *)ptr;
 	bhr_t *mhdr = &hdr->kwb_hdr;
@@ -322,7 +322,7 @@ static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
 }
 
 static int kwbimage_verify_header (unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct kwb_header *hdr = (struct kwb_header *)ptr;
 	bhr_t *mhdr = &hdr->kwb_hdr;
@@ -382,5 +382,5 @@ static struct image_type_params kwbimage_params = {
 
 void init_kwb_image_type (void)
 {
-	mkimage_register (&kwbimage_params);
+	register_image_type(&kwbimage_params);
 }
diff --git a/tools/mkimage.c b/tools/mkimage.c
index e12bc31..123d0c7 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -19,7 +19,7 @@ static void usage(void);
 struct image_type_params *mkimage_tparams = NULL;
 
 /* parameters initialized by core will be used by the image type code */
-struct mkimage_params params = {
+struct image_tool_params params = {
 	.os = IH_OS_LINUX,
 	.arch = IH_ARCH_PPC,
 	.type = IH_TYPE_KERNEL,
@@ -139,24 +139,8 @@ main (int argc, char **argv)
 	struct image_type_params *tparams = NULL;
 	int pad_len = 0;
 
-	/* Init Freescale PBL Boot image generation/list support */
-	init_pbl_image_type();
-	/* Init Kirkwood Boot image generation/list support */
-	init_kwb_image_type ();
-	/* Init Freescale imx Boot image generation/list support */
-	init_imx_image_type ();
-	/* Init Freescale mxs Boot image generation/list support */
-	init_mxs_image_type();
-	/* Init FIT image generation/list support */
-	init_fit_image_type ();
-	/* Init TI OMAP Boot image generation/list support */
-	init_omap_image_type();
-	/* Init Default image generation/list support */
-	init_default_image_type ();
-	/* Init Davinci UBL support */
-	init_ubl_image_type();
-	/* Init Davinci AIS support */
-	init_ais_image_type();
+	/* Init all image generation/list support */
+	register_image_tool(mkimage_register);
 
 	params.cmdname = *argv;
 	params.addr = params.ep = 0;
diff --git a/tools/mkimage.h b/tools/mkimage.h
index af49154..d5491b6 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <sha1.h>
 #include "fdt_host.h"
+#include "imagetool.h"
 
 #undef MKIMAGE_DEBUG
 
@@ -29,8 +30,6 @@
 #define debug(fmt,args...)
 #endif /* MKIMAGE_DEBUG */
 
-#define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
-
 static inline void *map_sysmem(ulong paddr, unsigned long len)
 {
 	return (void *)(uintptr_t)paddr;
@@ -47,124 +46,4 @@ static inline ulong map_to_sysmem(void *ptr)
 #define MKIMAGE_MAX_DTC_CMDLINE_LEN	512
 #define MKIMAGE_DTC			"dtc"   /* assume dtc is in $PATH */
 
-#define IH_ARCH_DEFAULT		IH_ARCH_INVALID
-
-/*
- * This structure defines all such variables those are initialized by
- * mkimage main core and need to be referred by image type specific
- * functions
- */
-struct mkimage_params {
-	int dflag;
-	int eflag;
-	int fflag;
-	int lflag;
-	int vflag;
-	int xflag;
-	int skipcpy;
-	int os;
-	int arch;
-	int type;
-	int comp;
-	char *dtc;
-	unsigned int addr;
-	unsigned int ep;
-	char *imagename;
-	char *imagename2;
-	char *datafile;
-	char *imagefile;
-	char *cmdname;
-	const char *keydir;	/* Directory holding private keys */
-	const char *keydest;	/* Destination .dtb for public key */
-	const char *comment;	/* Comment to add to signature node */
-	int require_keys;	/* 1 to mark signing keys as 'required' */
-};
-
-/*
- * image type specific variables and callback functions
- */
-struct image_type_params {
-	/* name is an identification tag string for added support */
-	char *name;
-	/*
-	 * header size is local to the specific image type to be supported,
-	 * mkimage core treats this as number of bytes
-	 */
-	uint32_t header_size;
-	/* Image type header pointer */
-	void *hdr;
-	/*
-	 * There are several arguments that are passed on the command line
-	 * and are registered as flags in mkimage_params structure.
-	 * This callback function can be used to check the passed arguments
-	 * are in-lined with the image type to be supported
-	 *
-	 * Returns 1 if parameter check is successful
-	 */
-	int (*check_params) (struct mkimage_params *);
-	/*
-	 * This function is used by list command (i.e. mkimage -l <filename>)
-	 * image type verification code must be put here
-	 *
-	 * Returns 0 if image header verification is successful
-	 * otherwise, returns respective negative error codes
-	 */
-	int (*verify_header) (unsigned char *, int, struct mkimage_params *);
-	/* Prints image information abstracting from image header */
-	void (*print_header) (const void *);
-	/*
-	 * The header or image contents need to be set as per image type to
-	 * be generated using this callback function.
-	 * further output file post processing (for ex. checksum calculation,
-	 * padding bytes etc..) can also be done in this callback function.
-	 */
-	void (*set_header) (void *, struct stat *, int,
-					struct mkimage_params *);
-	/*
-	 * Some image generation support for ex (default image type) supports
-	 * more than one type_ids, this callback function is used to check
-	 * whether input (-T <image_type>) is supported by registered image
-	 * generation/list low level code
-	 */
-	int (*check_image_type) (uint8_t);
-	/* This callback function will be executed if fflag is defined */
-	int (*fflag_handle) (struct mkimage_params *);
-	/*
-	 * This callback function will be executed for variable size record
-	 * It is expected to build this header in memory and return its length
-	 * and a pointer to it by using image_type_params.header_size and
-	 * image_type_params.hdr. The return value shall indicate if an
-	 * additional padding should be used when copying the data image
-	 * by returning the padding length.
-	 */
-	int (*vrec_header) (struct mkimage_params *,
-		struct image_type_params *);
-	/* pointer to the next registered entry in linked list */
-	struct image_type_params *next;
-};
-
-/*
- * Exported functions
- */
-void mkimage_register (struct image_type_params *tparams);
-
-/*
- * There is a c file associated with supported image type low level code
- * for ex. default_image.c, fit_image.c
- * init is the only function referred by mkimage core.
- * to avoid a single lined header file, you can define them here
- *
- * Supported image types init functions
- */
-void pbl_load_uboot(int fd, struct mkimage_params *mparams);
-void init_pbl_image_type(void);
-void init_ais_image_type(void);
-void init_kwb_image_type (void);
-void init_imx_image_type (void);
-void init_mxs_image_type(void);
-void init_default_image_type (void);
-void init_fit_image_type (void);
-void init_ubl_image_type(void);
-void init_omap_image_type(void);
-
 #endif /* _MKIIMAGE_H_ */
diff --git a/tools/mxsimage.c b/tools/mxsimage.c
index 5db19b2..b214050 100644
--- a/tools/mxsimage.c
+++ b/tools/mxsimage.c
@@ -17,7 +17,7 @@
 
 #include <openssl/evp.h>
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include "mxsimage.h"
 #include <image.h>
 
@@ -2148,11 +2148,11 @@ static int mxsimage_check_image_types(uint8_t type)
 }
 
 static void mxsimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 }
 
-int mxsimage_check_params(struct mkimage_params *params)
+int mxsimage_check_params(struct image_tool_params *params)
 {
 	if (!params)
 		return -1;
@@ -2193,7 +2193,7 @@ static int mxsimage_verify_print_header(char *file, int silent)
 
 char *imagefile;
 static int mxsimage_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct sb_boot_image_header *hdr;
 
@@ -2291,7 +2291,7 @@ static int sb_build_image(struct sb_image_ctx *ictx,
 	return 0;
 }
 
-static int mxsimage_generate(struct mkimage_params *params,
+static int mxsimage_generate(struct image_tool_params *params,
 	struct image_type_params *tparams)
 {
 	int ret;
@@ -2337,7 +2337,7 @@ static struct image_type_params mxsimage_params = {
 
 void init_mxs_image_type(void)
 {
-	mkimage_register(&mxsimage_params);
+	register_image_type(&mxsimage_params);
 }
 
 #else
diff --git a/tools/omapimage.c b/tools/omapimage.c
index 8774a7e..d59bc4d 100644
--- a/tools/omapimage.c
+++ b/tools/omapimage.c
@@ -14,7 +14,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "omapimage.h"
 
@@ -69,7 +69,7 @@ static int valid_gph_load_addr(uint32_t load_addr)
 }
 
 static int omapimage_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct ch_toc *toc = (struct ch_toc *)ptr;
 	struct gp_header *gph = (struct gp_header *)(ptr+OMAP_CH_HDR_SIZE);
@@ -188,7 +188,7 @@ static int toc_offset(void *hdr, void *member)
 }
 
 static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 	struct ch_toc *toc = (struct ch_toc *)ptr;
 	struct ch_settings *chs = (struct ch_settings *)
@@ -224,7 +224,7 @@ static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd,
 	}
 }
 
-int omapimage_check_params(struct mkimage_params *params)
+int omapimage_check_params(struct image_tool_params *params)
 {
 	return	(params->dflag && (params->fflag || params->lflag)) ||
 		(params->fflag && (params->dflag || params->lflag)) ||
@@ -247,5 +247,5 @@ static struct image_type_params omapimage_params = {
 
 void init_omap_image_type(void)
 {
-	mkimage_register(&omapimage_params);
+	register_image_type(&omapimage_params);
 }
diff --git a/tools/pblimage.c b/tools/pblimage.c
index bac5faf..ef3d7f6 100644
--- a/tools/pblimage.c
+++ b/tools/pblimage.c
@@ -3,7 +3,7 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "pblimage.h"
 
@@ -242,7 +242,7 @@ static void add_end_cmd(void)
 	}
 }
 
-void pbl_load_uboot(int ifd, struct mkimage_params *params)
+void pbl_load_uboot(int ifd, struct image_tool_params *params)
 {
 	FILE *fp_uboot;
 	int size;
@@ -281,7 +281,7 @@ static int pblimage_check_image_types(uint8_t type)
 }
 
 static int pblimage_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct pbl_header *pbl_hdr = (struct pbl_header *) ptr;
 
@@ -308,7 +308,7 @@ static void pblimage_print_header(const void *ptr)
 }
 
 static void pblimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 	/*nothing need to do, pbl_load_uboot takes care of whole file. */
 }
@@ -327,5 +327,5 @@ static struct image_type_params pblimage_params = {
 void init_pbl_image_type(void)
 {
 	pbl_size = 0;
-	mkimage_register(&pblimage_params);
+	register_image_type(&pblimage_params);
 }
diff --git a/tools/ublimage.c b/tools/ublimage.c
index aafe248..cbbbe20 100644
--- a/tools/ublimage.c
+++ b/tools/ublimage.c
@@ -13,7 +13,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "ublimage.h"
 
@@ -193,7 +193,7 @@ static int ublimage_check_image_types(uint8_t type)
 }
 
 static int ublimage_verify_header(unsigned char *ptr, int image_size,
-			struct mkimage_params *params)
+			struct image_tool_params *params)
 {
 	struct ubl_header *ubl_hdr = (struct ubl_header *)ptr;
 
@@ -211,7 +211,7 @@ static void ublimage_print_header(const void *ptr)
 }
 
 static void ublimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-				struct mkimage_params *params)
+				struct image_tool_params *params)
 {
 	struct ubl_header *ublhdr = (struct ubl_header *)ptr;
 
@@ -219,7 +219,7 @@ static void ublimage_set_header(void *ptr, struct stat *sbuf, int ifd,
 	parse_cfg_file(ublhdr, params->imagename);
 }
 
-int ublimage_check_params(struct mkimage_params *params)
+int ublimage_check_params(struct image_tool_params *params)
 {
 	if (!params)
 		return CFG_INVALID;
@@ -257,5 +257,5 @@ static struct image_type_params ublimage_params = {
 
 void init_ubl_image_type(void)
 {
-	mkimage_register(&ublimage_params);
+	register_image_type(&ublimage_params);
 }
-- 
1.8.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images
  2013-12-01 19:43 [U-Boot] [PATCH v2 0/4] Add dumpimage tool to extract files from U-Boot images Simon Glass
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 1/4] mkimage: added 'static' specifier to match function's prototype Simon Glass
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 2/4] tools: moved code common to all image tools to a separated module Simon Glass
@ 2013-12-01 19:43 ` Simon Glass
  2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2013-12-17  2:25   ` [U-Boot] [PATCH v2 " Masahiro Yamada
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 4/4] sandbox: dumpimage: Test dumpimage Simon Glass
  3 siblings, 2 replies; 12+ messages in thread
From: Simon Glass @ 2013-12-01 19:43 UTC (permalink / raw)
  To: u-boot

From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>

Given a multi-file image created through the mkimage's -d option:

  $ mkimage -A x86 -O linux -T multi -n x86 -d vmlinuz:initrd.img:System.map \
  multi.img

  Image Name:   x86
  Created:      Thu Jul 25 10:29:13 2013
  Image Type:   Intel x86 Linux Multi-File Image (gzip compressed)
  Data Size:    13722956 Bytes = 13401.32 kB = 13.09 MB
  Load Address: 00000000
  Entry Point:  00000000
  Contents:
     Image 0: 4040128 Bytes = 3945.44 kB = 3.85 MB
     Image 1: 7991719 Bytes = 7804.41 kB = 7.62 MB
     Image 2: 1691092 Bytes = 1651.46 kB = 1.61 MB

It is possible to perform the innverse operation -- extracting any file from
the image -- by using the dumpimage's -i option:

  $ dumpimage -i multi.img -p 2 System.map

Although it's feasible to retrieve "data files" from image through scripting,
the requirement to embed tools such 'dd', 'awk' and 'sed' for this sole purpose
is cumbersome and unreliable -- once you must keep track of file sizes inside
the image. Furthermore, extracting data files using "dumpimage" tool is faster
than through scripting.

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add additional -o option for when the file name is not valid
- Correct checkpatch problems

 Makefile              |   1 +
 README                |   9 ++
 tools/.gitignore      |   1 +
 tools/Makefile        |  26 +++++
 tools/default_image.c |  57 ++++++++++
 tools/dumpimage.c     | 305 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/dumpimage.h     |  33 ++++++
 tools/imagetool.h     |  12 ++
 8 files changed, 444 insertions(+)
 create mode 100644 tools/dumpimage.c
 create mode 100644 tools/dumpimage.h

diff --git a/Makefile b/Makefile
index a2fb037..653d3b3 100644
--- a/Makefile
+++ b/Makefile
@@ -796,6 +796,7 @@ clean:
 	       $(obj)tools/envcrc					  \
 	       $(obj)tools/gdb/{astest,gdbcont,gdbsend}			  \
 	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
+	       $(obj)tools/dump{env,}image		  \
 	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
 	       $(obj)tools/mk{$(BOARD),}spl				  \
 	       $(obj)tools/mxsboot					  \
diff --git a/README b/README
index 5def773..5072f08 100644
--- a/README
+++ b/README
@@ -5193,6 +5193,15 @@ when your kernel is intended to use an initial ramdisk:
 	Load Address: 0x00000000
 	Entry Point:  0x00000000
 
+The "dumpimage" is a tool to disassemble images built by mkimage. Its "-i"
+option performs the converse operation of the mkimage's second form (the "-d"
+option). Given an image built by mkimage, the dumpimage extracts a "data file"
+from the image:
+
+	tools/dumpimage -i image -p position data_file
+	  -i ==> extract from the 'image' a specific 'data_file', \
+	   indexed by 'position'
+
 
 Installing a Linux Image:
 -------------------------
diff --git a/tools/.gitignore b/tools/.gitignore
index a7fee26..2320fd8 100644
--- a/tools/.gitignore
+++ b/tools/.gitignore
@@ -3,6 +3,7 @@
 /gen_eth_addr
 /img2srec
 /kwboot
+/dumpimage
 /mkenvimage
 /mkimage
 /mpc86x_clk
diff --git a/tools/Makefile b/tools/Makefile
index 154eae3..e1264fd 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -50,6 +50,7 @@ BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
 BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
+BIN_FILES-y += dumpimage$(SFX)
 BIN_FILES-y += mkenvimage$(SFX)
 BIN_FILES-y += mkimage$(SFX)
 BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
@@ -72,6 +73,7 @@ EXT_OBJ_FILES-y += lib/sha1.o
 # Source files located in the tools directory
 NOPED_OBJ_FILES-y += aisimage.o
 NOPED_OBJ_FILES-y += default_image.o
+NOPED_OBJ_FILES-y += dumpimage.o
 NOPED_OBJ_FILES-y += fit_image.o
 NOPED_OBJ_FILES-y += image-host.o
 NOPED_OBJ_FILES-y += imximage.o
@@ -200,6 +202,30 @@ $(obj)xway-swap-bytes$(SFX):	$(obj)xway-swap-bytes.o
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
 	$(HOSTSTRIP) $@
 
+$(obj)dumpimage$(SFX):	$(obj)aisimage.o \
+			$(FIT_SIG_OBJS) \
+			$(obj)crc32.o \
+			$(obj)default_image.o \
+			$(obj)fit_image.o \
+			$(obj)image-fit.o \
+			$(obj)image.o \
+			$(obj)image-host.o \
+			$(obj)imagetool.o \
+			$(obj)imximage.o \
+			$(obj)kwbimage.o \
+			$(obj)dumpimage.o \
+			$(obj)md5.o \
+			$(obj)mxsimage.o \
+			$(obj)omapimage.o \
+			$(obj)os_support.o \
+			$(obj)pblimage.o \
+			$(obj)sha1.o \
+			$(obj)ublimage.o \
+			$(LIBFDT_OBJS) \
+			$(RSA_OBJS)
+	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
+	$(HOSTSTRIP) $@
+
 $(obj)mkenvimage$(SFX):	$(obj)crc32.o $(obj)mkenvimage.o \
 	$(obj)os_support.o
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
diff --git a/tools/default_image.c b/tools/default_image.c
index cc790b2..0a0792e 100644
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -117,6 +117,62 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
 	image_set_hcrc(hdr, checksum);
 }
 
+static int image_save_datafile(struct image_tool_params *params,
+			       ulong file_data, ulong file_len)
+{
+	int dfd;
+	const char *datafile = params->outfile;
+
+	dfd = open(datafile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
+		   S_IRUSR | S_IWUSR);
+	if (dfd < 0) {
+		fprintf(stderr, "%s: Can't open \"%s\": %s\n",
+			params->cmdname, datafile, strerror(errno));
+		return -1;
+	}
+
+	if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) {
+		fprintf(stderr, "%s: Write error on \"%s\": %s\n",
+			params->cmdname, datafile, strerror(errno));
+		close(dfd);
+		return -1;
+	}
+
+	close(dfd);
+
+	return 0;
+}
+
+static int image_extract_datafile(void *ptr, struct image_tool_params *params)
+{
+	const image_header_t *hdr = (const image_header_t *)ptr;
+	ulong file_data;
+	ulong file_len;
+
+	if (image_check_type(hdr, IH_TYPE_MULTI)) {
+		ulong idx = params->pflag;
+		ulong count;
+
+		/* get the number of data files present in the image */
+		count = image_multi_count(hdr);
+
+		/* retrieve the "data file" at the idx position */
+		image_multi_getimg(hdr, idx, &file_data, &file_len);
+
+		if ((file_len == 0) || (idx >= count)) {
+			fprintf(stderr, "%s: No such data file %ld in \"%s\"\n",
+				params->cmdname, idx, params->imagefile);
+			return -1;
+		}
+	} else {
+		file_data = image_get_data(hdr);
+		file_len = image_get_size(hdr);
+	}
+
+	/* save the "data file" into the file system */
+	return image_save_datafile(params, file_data, file_len);
+}
+
 /*
  * Default image type parameters definition
  */
@@ -128,6 +184,7 @@ static struct image_type_params defimage_params = {
 	.verify_header = image_verify_header,
 	.print_header = image_print_contents,
 	.set_header = image_set_header,
+	.extract_datafile = image_extract_datafile,
 	.check_params = image_check_params,
 };
 
diff --git a/tools/dumpimage.c b/tools/dumpimage.c
new file mode 100644
index 0000000..542ee28
--- /dev/null
+++ b/tools/dumpimage.c
@@ -0,0 +1,305 @@
+/*
+ * Based on mkimage.c.
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include "dumpimage.h"
+#include <image.h>
+#include <version.h>
+
+static void usage(void);
+
+/* image_type_params linked list to maintain registered image types supports */
+static struct image_type_params *dumpimage_tparams;
+
+/* parameters initialized by core will be used by the image type code */
+static struct image_tool_params params = {
+	.type = IH_TYPE_KERNEL,
+};
+
+/**
+ * dumpimage_register() - register respective image generation/list support
+ *
+ * the input struct image_type_params is checked and appended to the link
+ * list, if the input structure is already registered, issue an error
+ *
+ * @tparams: Image type parameters
+ */
+static void dumpimage_register(struct image_type_params *tparams)
+{
+	struct image_type_params **tp;
+
+	if (!tparams) {
+		fprintf(stderr, "%s: %s: Null input\n", params.cmdname,
+			__func__);
+		exit(EXIT_FAILURE);
+	}
+
+	/* scan the linked list, check for registry and point the last one */
+	for (tp = &dumpimage_tparams; *tp != NULL; tp = &(*tp)->next) {
+		if (!strcmp((*tp)->name, tparams->name)) {
+			fprintf(stderr, "%s: %s already registered\n",
+				params.cmdname, tparams->name);
+			return;
+		}
+	}
+
+	/* add input struct entry at the end of link list */
+	*tp = tparams;
+	/* mark input entry as last entry in the link list */
+	tparams->next = NULL;
+
+	debug("Registered %s\n", tparams->name);
+}
+
+/**
+ * dumpimage_get_type() - find the image type params for a given image type
+ *
+ * Scan all registered image types and check the input type_id for each
+ * supported image type
+ *
+ * @return respective image_type_params pointer. If the input type is not
+ * supported by any of registered image types, returns NULL
+ */
+static struct image_type_params *dumpimage_get_type(int type)
+{
+	struct image_type_params *curr;
+
+	for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
+		if (curr->check_image_type) {
+			if (!curr->check_image_type(type))
+				return curr;
+		}
+	}
+	return NULL;
+}
+
+/*
+ * dumpimage_verify_print_header() - verifies the image header
+ *
+ * Scan registered image types and verify the image_header for each
+ * supported image type. If verification is successful, this prints
+ * the respective header.
+ *
+ * @return 0 on success, negative if input image format does not match with
+ * any of supported image types
+ */
+static int dumpimage_verify_print_header(void *ptr, struct stat *sbuf)
+{
+	int retval = -1;
+	struct image_type_params *curr;
+
+	for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
+		if (curr->verify_header) {
+			retval = curr->verify_header((unsigned char *)ptr,
+						     sbuf->st_size, &params);
+			if (retval != 0)
+				continue;
+			/*
+			 * Print the image information  if verify is
+			 * successful
+			 */
+			if (curr->print_header) {
+				curr->print_header(ptr);
+			} else {
+				fprintf(stderr,
+					"%s: print_header undefined for %s\n",
+					params.cmdname, curr->name);
+			}
+			break;
+		}
+	}
+
+	return retval;
+}
+
+/*
+ * dumpimage_extract_datafile -
+ *
+ * It scans all registered image types,
+ * verifies image_header for each supported image type
+ * if verification is successful, it extracts the desired file,
+ * indexed by pflag, from the image
+ *
+ * returns negative if input image format does not match with any of
+ * supported image types
+ */
+static int dumpimage_extract_datafile(void *ptr, struct stat *sbuf)
+{
+	int retval = -1;
+	struct image_type_params *curr;
+
+	for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
+		if (curr->verify_header) {
+			retval = curr->verify_header((unsigned char *)ptr,
+						     sbuf->st_size, &params);
+			if (retval != 0)
+				continue;
+			/*
+			 * Extract the file from the image
+			 * if verify is successful
+			 */
+			if (curr->extract_datafile) {
+				curr->extract_datafile(ptr, &params);
+			} else {
+				fprintf(stderr,
+					"%s: extract_datafile undefined for %s\n",
+					params.cmdname, curr->name);
+			break;
+			}
+		}
+	}
+
+	return retval;
+}
+
+int main(int argc, char **argv)
+{
+	int opt;
+	int ifd = -1;
+	struct stat sbuf;
+	char *ptr;
+	int retval = 0;
+	struct image_type_params *tparams = NULL;
+
+	/* Init all image generation/list support */
+	register_image_tool(dumpimage_register);
+
+	params.cmdname = *argv;
+
+	while ((opt = getopt(argc, argv, "li:o:p:V")) != -1) {
+		switch (opt) {
+		case 'l':
+			params.lflag = 1;
+			break;
+		case 'i':
+			params.imagefile = optarg;
+			params.iflag = 1;
+			break;
+		case 'o':
+			params.outfile = optarg;
+			break;
+		case 'p':
+			params.pflag = strtoul(optarg, &ptr, 10);
+			if (*ptr) {
+				fprintf(stderr,
+					"%s: invalid file position %s\n",
+					params.cmdname, *argv);
+				exit(EXIT_FAILURE);
+			}
+			break;
+		case 'V':
+			printf("dumpimage version %s\n", PLAIN_VERSION);
+			exit(EXIT_SUCCESS);
+		default:
+			usage();
+		}
+	}
+
+	if (optind >= argc)
+		usage();
+
+	/* set tparams as per input type_id */
+	tparams = dumpimage_get_type(params.type);
+	if (tparams == NULL) {
+		fprintf(stderr, "%s: unsupported type %s\n",
+			params.cmdname, genimg_get_type_name(params.type));
+		exit(EXIT_FAILURE);
+	}
+
+	/*
+	 * check the passed arguments parameters meets the requirements
+	 * as per image type to be generated/listed
+	 */
+	if (tparams->check_params) {
+		if (tparams->check_params(&params))
+			usage();
+	}
+
+	if (params.iflag)
+		params.datafile = argv[optind];
+	else
+		params.imagefile = argv[optind];
+	if (!params.outfile)
+		params.outfile = params.datafile;
+
+	ifd = open(params.imagefile, O_RDONLY|O_BINARY);
+	if (ifd < 0) {
+		fprintf(stderr, "%s: Can't open \"%s\": %s\n",
+			params.cmdname, params.imagefile,
+			strerror(errno));
+		exit(EXIT_FAILURE);
+	}
+
+	if (params.lflag || params.iflag) {
+		if (fstat(ifd, &sbuf) < 0) {
+			fprintf(stderr, "%s: Can't stat \"%s\": %s\n",
+				params.cmdname, params.imagefile,
+				strerror(errno));
+			exit(EXIT_FAILURE);
+		}
+
+		if ((unsigned)sbuf.st_size < tparams->header_size) {
+			fprintf(stderr,
+				"%s: Bad size: \"%s\" is not valid image\n",
+				params.cmdname, params.imagefile);
+			exit(EXIT_FAILURE);
+		}
+
+		ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, ifd, 0);
+		if (ptr == MAP_FAILED) {
+			fprintf(stderr, "%s: Can't read \"%s\": %s\n",
+				params.cmdname, params.imagefile,
+				strerror(errno));
+			exit(EXIT_FAILURE);
+		}
+
+		/*
+		 * Both calls bellow scan through dumpimage registry for all
+		 * supported image types and verify the input image file
+		 * header for match
+		 */
+		if (params.iflag) {
+			/*
+			 * Extract the data files from within the matched
+			 * image type. Returns the error code if not matched
+			 */
+			retval = dumpimage_extract_datafile(ptr, &sbuf);
+		} else {
+			/*
+			 * Print the image information for matched image type
+			 * Returns the error code if not matched
+			 */
+			retval = dumpimage_verify_print_header(ptr, &sbuf);
+		}
+
+		(void)munmap((void *)ptr, sbuf.st_size);
+		(void)close(ifd);
+
+		return retval;
+	}
+
+	(void)close(ifd);
+
+	return EXIT_SUCCESS;
+}
+
+static void usage(void)
+{
+	fprintf(stderr, "Usage: %s -l image\n"
+		"          -l ==> list image header information\n",
+		params.cmdname);
+	fprintf(stderr,
+		"       %s -i image [-p position] [-o outfile] data_file\n"
+		"          -i ==> extract from the 'image' a specific 'data_file'"
+		", indexed by 'position' (starting at 0)\n",
+		params.cmdname);
+	fprintf(stderr,
+		"       %s -V ==> print version information and exit\n",
+		params.cmdname);
+
+	exit(EXIT_FAILURE);
+}
diff --git a/tools/dumpimage.h b/tools/dumpimage.h
new file mode 100644
index 0000000..d78523d
--- /dev/null
+++ b/tools/dumpimage.h
@@ -0,0 +1,33 @@
+/*
+ * Based on mkimage.c.
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _DUMPIMAGE_H_
+#define _DUMPIMAGE_H_
+
+#include "os_support.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+#include <sha1.h>
+#include "fdt_host.h"
+#include "imagetool.h"
+
+#undef DUMPIMAGE_DEBUG
+
+#ifdef DUMPIMAGE_DEBUG
+#define debug(fmt, args...)	printf(fmt, ##args)
+#else
+#define debug(fmt, args...)
+#endif /* DUMPIMAGE_DEBUG */
+
+#endif /* _DUMPIMAGE_H_ */
diff --git a/tools/imagetool.h b/tools/imagetool.h
index b8adb61..c2c9aea 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -34,7 +34,9 @@ struct image_tool_params {
 	int dflag;
 	int eflag;
 	int fflag;
+	int iflag;
 	int lflag;
+	int pflag;
 	int vflag;
 	int xflag;
 	int skipcpy;
@@ -50,6 +52,7 @@ struct image_tool_params {
 	char *datafile;
 	char *imagefile;
 	char *cmdname;
+	const char *outfile;	/* Output filename */
 	const char *keydir;	/* Directory holding private keys */
 	const char *keydest;	/* Destination .dtb for public key */
 	const char *comment;	/* Comment to add to signature node */
@@ -97,6 +100,15 @@ struct image_type_params {
 	void (*set_header) (void *, struct stat *, int,
 					struct image_tool_params *);
 	/*
+	 * This function is used by the command to retrieve a data file from
+	 * the image (i.e. dumpimage -i <image> -p <position> <data_file>).
+	 * Thus the code to extract a file from an image must be put here.
+	 *
+	 * Returns 0 if the file was successfully retrieved from the image,
+	 * or a negative value on error.
+	 */
+	int (*extract_datafile) (void *, struct image_tool_params *);
+	/*
 	 * Some image generation support for ex (default image type) supports
 	 * more than one type_ids, this callback function is used to check
 	 * whether input (-T <image_type>) is supported by registered image
-- 
1.8.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 4/4] sandbox: dumpimage: Test dumpimage
  2013-12-01 19:43 [U-Boot] [PATCH v2 0/4] Add dumpimage tool to extract files from U-Boot images Simon Glass
                   ` (2 preceding siblings ...)
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images Simon Glass
@ 2013-12-01 19:43 ` Simon Glass
  2013-12-16 14:15   ` [U-Boot] [U-Boot,v2,4/4] " Tom Rini
  3 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2013-12-01 19:43 UTC (permalink / raw)
  To: u-boot

From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>

Add a test for dumpimage.

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Tidy up shell script style a little
- Updated test to include coverage for the new -o option

 test/image/test-imagetools.sh | 141 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 141 insertions(+)
 create mode 100755 test/image/test-imagetools.sh

diff --git a/test/image/test-imagetools.sh b/test/image/test-imagetools.sh
new file mode 100755
index 0000000..9e299e1
--- /dev/null
+++ b/test/image/test-imagetools.sh
@@ -0,0 +1,141 @@
+#!/bin/bash
+#
+# Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+#
+# Sanity check for mkimage and dumpimage tools
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+# To run this:
+#
+# make O=sandbox sandbox_config
+# make O=sandbox
+# ./test/image/test-imagetools.sh
+
+BASEDIR=sandbox
+SRCDIR=sandbox/boot
+IMAGE_NAME="v1.0-test"
+IMAGE=linux.img
+DATAFILE0=vmlinuz
+DATAFILE1=initrd.img
+DATAFILE2=System.map
+DATAFILES="${DATAFILE0} ${DATAFILE1} ${DATAFILE2}"
+TEST_OUT=test_output
+MKIMAGE=${BASEDIR}/tools/mkimage
+DUMPIMAGE=${BASEDIR}/tools/dumpimage
+MKIMAGE_LIST=mkimage.list
+DUMPIMAGE_LIST=dumpimage.list
+
+# Remove all the files we created
+cleanup()
+{
+	local file
+
+	for file in ${DATAFILES}; do
+		rm -f ${file} ${SRCDIR}/${file}
+	done
+	rm -f ${IMAGE} ${DUMPIMAGE_LIST} ${MKIMAGE_LIST} ${TEST_OUT}
+	rmdir ${SRCDIR}
+}
+
+# Check that two files are the same
+assert_equal()
+{
+	if ! diff $1 $2; then
+		echo "Failed."
+		cleanup
+		exit 1
+	fi
+}
+
+# Create some test files
+create_files()
+{
+	local file
+
+	mkdir -p ${SRCDIR}
+	for file in ${DATAFILES}; do
+		head -c $RANDOM /dev/urandom >${SRCDIR}/${file}
+	done
+}
+
+# Run a command, echoing it first
+do_cmd()
+{
+	local cmd="$@"
+
+	echo "# ${cmd}"
+	${cmd} 2>&1
+}
+
+# Run a command, redirecting output
+# Args:
+#    redirect_file
+#    command...
+do_cmd_redir()
+{
+	local redir="$1"
+	shift
+	local cmd="$@"
+
+	echo "# ${cmd}"
+	${cmd} >${redir}
+}
+
+# Write files into an image
+create_image()
+{
+	local files="${SRCDIR}/${DATAFILE0}:${SRCDIR}/${DATAFILE1}"
+	files+=":${SRCDIR}/${DATAFILE2}"
+
+	echo -e "\nBuilding image..."
+	do_cmd ${MKIMAGE} -A x86 -O linux -T multi -n \"${IMAGE_NAME}\" \
+		-d ${files} ${IMAGE}
+	echo "done."
+}
+
+# Extract files from an image
+extract_image()
+{
+	echo -e "\nExtracting image contents..."
+	do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 0 ${DATAFILE0}
+	do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 1 ${DATAFILE1}
+	do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 2 ${DATAFILE2}
+	do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 2 ${DATAFILE2} -o ${TEST_OUT}
+	echo "done."
+}
+
+# List the contents of a file
+list_image()
+{
+	echo -e "\nListing image contents..."
+	do_cmd_redir ${MKIMAGE_LIST} ${MKIMAGE} -l ${IMAGE}
+	do_cmd_redir ${DUMPIMAGE_LIST} ${DUMPIMAGE} -l ${IMAGE}
+	echo "done."
+}
+
+main()
+{
+	local file
+
+	create_files
+
+	# Compress and extract multifile images, compare the result
+	create_image
+	extract_image
+	for file in ${DATAFILES}; do
+		assert_equal ${file} ${SRCDIR}/${file}
+	done
+	assert_equal ${TEST_OUT} ${DATAFILE2}
+
+	# List contents and compares output fro tools
+	list_image
+	assert_equal ${DUMPIMAGE_LIST} ${MKIMAGE_LIST}
+
+	# Remove files created
+	cleanup
+
+	echo "Tests passed."
+}
+
+main
-- 
1.8.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [U-Boot, v2, 1/4] mkimage: added 'static' specifier to match function's prototype.
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 1/4] mkimage: added 'static' specifier to match function's prototype Simon Glass
@ 2013-12-16 14:15   ` Tom Rini
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Rini @ 2013-12-16 14:15 UTC (permalink / raw)
  To: u-boot

On Sun, Dec 01, 2013 at 12:43:09PM -0700, Simon Glass wrote:

> From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> 
> This function should be declared static.
> 
> Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/458816f6/attachment.pgp>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [U-Boot, v2, 2/4] tools: moved code common to all image tools to a separated module.
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 2/4] tools: moved code common to all image tools to a separated module Simon Glass
@ 2013-12-16 14:15   ` Tom Rini
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Rini @ 2013-12-16 14:15 UTC (permalink / raw)
  To: u-boot

On Sun, Dec 01, 2013 at 12:43:10PM -0700, Simon Glass wrote:

> From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> 
> In order to avoid duplicating code and keep only one point of modification,
> the functions, structs and defines useful for "dumpimage" were moved from
> "mkimage" to a common module called "imagetool".
> 
> This modification also weakens the coupling between image types (FIT, IMX, MXS,
> and so on) and image tools (mkimage and dumpimage). Any tool may initialize the
> "imagetool" through register_image_tool() function, while the image types
> register themselves within an image tool using the register_image_type()
> function:
> 
>                                                       +---------------+
>                                                +------|   fit_image   |
>  +--------------+          +-----------+       |      +---------------+
>  |    mkimage   |--------> |           | <-----+
>  +--------------+          |           |              +---------------+
>                            | imagetool | <------------|    imximage   |
>  +--------------+          |           |              +---------------+
>  |  dumpimage   |--------> |           | <-----+
>  +--------------+          +-----------+       |      +---------------+
>                                                +------| default_image |
>                                                       +---------------+
> 
>           register_image_tool()           register_image_type()
> 
> Also, the struct "mkimage_params" was renamed to "image_tool_params" to make
> clear its general purpose.
> 
> Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/f66a8548/attachment.pgp>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [U-Boot, v2, 3/4] Add dumpimage, a tool to extract data from U-Boot images
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images Simon Glass
@ 2013-12-16 14:15   ` Tom Rini
  2013-12-17  2:25   ` [U-Boot] [PATCH v2 " Masahiro Yamada
  1 sibling, 0 replies; 12+ messages in thread
From: Tom Rini @ 2013-12-16 14:15 UTC (permalink / raw)
  To: u-boot

On Sun, Dec 01, 2013 at 12:43:11PM -0700, Simon Glass wrote:

> From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> 
> Given a multi-file image created through the mkimage's -d option:
> 
>   $ mkimage -A x86 -O linux -T multi -n x86 -d vmlinuz:initrd.img:System.map \
>   multi.img
> 
>   Image Name:   x86
>   Created:      Thu Jul 25 10:29:13 2013
>   Image Type:   Intel x86 Linux Multi-File Image (gzip compressed)
>   Data Size:    13722956 Bytes = 13401.32 kB = 13.09 MB
>   Load Address: 00000000
>   Entry Point:  00000000
>   Contents:
>      Image 0: 4040128 Bytes = 3945.44 kB = 3.85 MB
>      Image 1: 7991719 Bytes = 7804.41 kB = 7.62 MB
>      Image 2: 1691092 Bytes = 1651.46 kB = 1.61 MB
> 
> It is possible to perform the innverse operation -- extracting any file from
> the image -- by using the dumpimage's -i option:
> 
>   $ dumpimage -i multi.img -p 2 System.map
> 
> Although it's feasible to retrieve "data files" from image through scripting,
> the requirement to embed tools such 'dd', 'awk' and 'sed' for this sole purpose
> is cumbersome and unreliable -- once you must keep track of file sizes inside
> the image. Furthermore, extracting data files using "dumpimage" tool is faster
> than through scripting.
> 
> Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/751575e6/attachment.pgp>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [U-Boot,v2,4/4] sandbox: dumpimage: Test dumpimage
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 4/4] sandbox: dumpimage: Test dumpimage Simon Glass
@ 2013-12-16 14:15   ` Tom Rini
  0 siblings, 0 replies; 12+ messages in thread
From: Tom Rini @ 2013-12-16 14:15 UTC (permalink / raw)
  To: u-boot

On Sun, Dec 01, 2013 at 12:43:12PM -0700, Simon Glass wrote:

> From: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> 
> Add a test for dumpimage.
> 
> Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/36872e84/attachment.pgp>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images
  2013-12-01 19:43 ` [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images Simon Glass
  2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
@ 2013-12-17  2:25   ` Masahiro Yamada
  2013-12-17 23:07     ` Simon Glass
  1 sibling, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2013-12-17  2:25 UTC (permalink / raw)
  To: u-boot

Hello Guilherme, Simon


> diff --git a/Makefile b/Makefile
> index a2fb037..653d3b3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -796,6 +796,7 @@ clean:
>  	       $(obj)tools/envcrc					  \
>  	       $(obj)tools/gdb/{astest,gdbcont,gdbsend}			  \
>  	       $(obj)tools/gen_eth_addr    $(obj)tools/img2srec		  \
> +	       $(obj)tools/dump{env,}image		  \
>  	       $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk	  \
>  	       $(obj)tools/mk{$(BOARD),}spl				  \
>  	       $(obj)tools/mxsboot					  \

Where is tools/dumpenvimage created?


Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images
  2013-12-17  2:25   ` [U-Boot] [PATCH v2 " Masahiro Yamada
@ 2013-12-17 23:07     ` Simon Glass
  2013-12-18  3:07       ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2013-12-17 23:07 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 16 December 2013 19:25, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> Hello Guilherme, Simon
>
>
>> diff --git a/Makefile b/Makefile
>> index a2fb037..653d3b3 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -796,6 +796,7 @@ clean:
>>              $(obj)tools/envcrc                                         \
>>              $(obj)tools/gdb/{astest,gdbcont,gdbsend}                   \
>>              $(obj)tools/gen_eth_addr    $(obj)tools/img2srec           \
>> +            $(obj)tools/dump{env,}image                \
>>              $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk         \
>>              $(obj)tools/mk{$(BOARD),}spl                               \
>>              $(obj)tools/mxsboot                                        \
>
> Where is tools/dumpenvimage created?

I don't see it.

Regards,
Simon

>
>
> Best Regards
> Masahiro Yamada
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images
  2013-12-17 23:07     ` Simon Glass
@ 2013-12-18  3:07       ` Masahiro Yamada
  0 siblings, 0 replies; 12+ messages in thread
From: Masahiro Yamada @ 2013-12-18  3:07 UTC (permalink / raw)
  To: u-boot

Hello Simon.

> >> diff --git a/Makefile b/Makefile
> >> index a2fb037..653d3b3 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -796,6 +796,7 @@ clean:
> >>              $(obj)tools/envcrc                                         \
> >>              $(obj)tools/gdb/{astest,gdbcont,gdbsend}                   \
> >>              $(obj)tools/gen_eth_addr    $(obj)tools/img2srec           \
> >> +            $(obj)tools/dump{env,}image                \
> >>              $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk         \
> >>              $(obj)tools/mk{$(BOARD),}spl                               \
> >>              $(obj)tools/mxsboot                                        \
> >
> > Where is tools/dumpenvimage created?
> 
> I don't see it.

OK.
Anyway, I will fix it in my Kbuild series.

Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-12-18  3:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-01 19:43 [U-Boot] [PATCH v2 0/4] Add dumpimage tool to extract files from U-Boot images Simon Glass
2013-12-01 19:43 ` [U-Boot] [PATCH v2 1/4] mkimage: added 'static' specifier to match function's prototype Simon Glass
2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
2013-12-01 19:43 ` [U-Boot] [PATCH v2 2/4] tools: moved code common to all image tools to a separated module Simon Glass
2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
2013-12-01 19:43 ` [U-Boot] [PATCH v2 3/4] Add dumpimage, a tool to extract data from U-Boot images Simon Glass
2013-12-16 14:15   ` [U-Boot] [U-Boot, v2, " Tom Rini
2013-12-17  2:25   ` [U-Boot] [PATCH v2 " Masahiro Yamada
2013-12-17 23:07     ` Simon Glass
2013-12-18  3:07       ` Masahiro Yamada
2013-12-01 19:43 ` [U-Boot] [PATCH v2 4/4] sandbox: dumpimage: Test dumpimage Simon Glass
2013-12-16 14:15   ` [U-Boot] [U-Boot,v2,4/4] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.