[U-Boot] [RFC PATCH] add ability to handle compressed images to imxtract

Wolfgang Denk wd at denx.de
Wed Dec 2 22:43:21 CET 2009


Dear Wolfgang Wegner,

In message <1256916625-30792-1-git-send-email-w.wegner at astro-kom.de> you wrote:
> imxtract currently can not handle compressed images. This patch adds
> handling for bzip2 and zip compression. In both cases, a destination
> address has to be specified for extraction.
> 
> Signed-off-by: Wolfgang Wegner <w.wegner at astro-kom.de>
...

> +/* there is no prototype in zlib.h */
> +int  gunzip (void *, int, unsigned char *, unsigned long *);

Then we should add it there, once.

> +#ifndef CFG_XIMG_LEN
> +#define CFG_XIMG_LEN	0x800000	/* use 8MByte as default max gunzip size */
> +#endif

CFG_ has been deprectaed a long, long time ago. Please use CONFIG_SYS_
instead.

> -			printf("Wrong Compression Type for %s command\n",
> +		comp = image_get_comp (hdr);
> +		if ((comp != IH_COMP_NONE) && (argc < 4)) {
> +			printf("Must specify load address for %s command with compressed image\n",

Line too long. (Check globally).

>  	if (argc > 3) {
> -		memcpy((char *) dest, (char *) data, len);
> +		switch (comp) {
> +		case IH_COMP_NONE:
> +#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
> +			{
> +				size_t l = len;
> +				void *to = (void *) dest;
> +				void *from = (void *)data;
> +
> +				printf ("   Loading part %d ... ", part);
> +
> +				while (l > 0) {
> +					size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
> +					WATCHDOG_RESET();
> +					memmove (to, from, tail);
> +					to += tail;
> +					from += tail;
> +					l -= tail;
> +				}
> +			}
> +#else	/* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
> +			memmove ((char *) dest, (char *)data, len);
> +#endif	/* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */

It seems wrong to me to have inconsistent behaviour (with printf() in
the "if", without in the "else" branch).

> +		case IH_COMP_GZIP:
> +			printf ("   Uncompressing part %d (len %d) ... ", part, len);
...
> +#if defined(CONFIG_BZIP2)
> +		case IH_COMP_BZIP2:
> +			printf ("   Uncompressing part %d ... ", part);

Inconsistent behaviour. Why do we print "len" for IH_COMP_GZIP, but
not for IH_COMP_BZIP2 ?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I've got to get something inside me. Some coffee  or  something.  And
then the world will somehow be better.
                                     - Terry Pratchett, _Men at Arms_


More information about the U-Boot mailing list