tools: mkimage: Fixed build warnings
PATCH v2 1/2 tools: mkimage: Fixed build warnings
uninitialized retval variable warning fixed
crc32 APIs moved to crc.h (newly added) and build warnings fixed some indentation tabs fixed
---
Change log:
v2: updated as per review feedback for v1
include/common.h | 4 +--- include/u-boot/crc.h | 33 +++++++++++++++++++++++++++++++++ tools/mkimage.c | 20 +++++++++++--------- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 include/u-boot/crc.h
include/common.h +1 -3
@@ -622,9 +622,7 @@ int vsprintf(char *buf, const char *fmt, va_list args);char *strmhz (char *buf,long hz);/* lib_generic/crc32.c */ -uint32_t crc32 (uint32_t ,const unsigned char *,uint ); -uint32_t crc32_wd (uint32_t ,const unsigned char *,uint ,uint ); -uint32_t crc32_no_comp (uint32_t ,const unsigned char *,uint ); +#include <u-boot/crc.h> /* common/console.c */ int console_init_f (void );/* Before relocation; uses the serial stuff */
include/u-boot/crc.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* (C) Copyright 2009 +* Marvell Semiconductor <www.marvell.com> +* Written-by: Prafulla Wadaskar <[email protected]> +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +* MA 02110-1301 USA +*/ + +#ifndef _UBOOT_CRC_H +#define _UBOOT_CRC_H + +/* lib_generic/crc32.c */ +uint32_t crc32 (uint32_t ,const unsigned char *,uint ); +uint32_t crc32_wd (uint32_t ,const unsigned char *,uint ,uint ); +uint32_t crc32_no_comp (uint32_t ,const unsigned char *,uint ); + +#endif /* _UBOOT_CRC_H */
tools/mkimage.c +11 -9
@@ -24,8 +24,8 @@#include "mkimage.h" #include <image.h> +#include <u-boot/crc.h> -extern unsigned long crc32 (unsigned long crc,const char *buf,unsigned int len);static void copy_file (int ,const char *,int );static void usage (void );static int image_verify_header (char *,int );
@@ -60,7 +60,7 @@ main (int argc, char **argv)struct stat sbuf;unsigned char *ptr;char *name ="" ; -int retval; +int retval =0 ; cmdname = *argv;
@@ -334,9 +334,10 @@ NXTARG: ; hdr = (image_header_t *)ptr; checksum =crc32 (0 , - (const char *)(ptr +image_get_header_size ()), - sbuf.st_size -image_get_header_size () - ); + (const unsigned char *)(ptr + +image_get_header_size ()), + sbuf.st_size -image_get_header_size () + );/* Build new header */ image_set_magic (hdr,IH_MAGIC );
@@ -352,7 +353,8 @@ NXTARG: ;image_set_name (hdr, name); - checksum =crc32 (0 , (const char *)hdr,image_get_header_size ()); + checksum =crc32 (0 , (const unsigned char *)hdr, +image_get_header_size ());image_set_hcrc (hdr, checksum);
@@ -485,7 +487,7 @@ static int image_verify_header (char *ptr, int image_size) {int len; -char *data; +const unsigned char *data;uint32_t checksum;image_header_t header;image_header_t *hdr = &header;
@@ -504,7 +506,7 @@ image_verify_header (char *ptr, int image_size)return -FDT_ERR_BADMAGIC ; } - data = (char *)hdr; + data = (const unsigned char *)hdr; len =sizeof (image_header_t); checksum =be32_to_cpu (hdr->ih_hcrc);
@@ -517,7 +519,7 @@ image_verify_header (char *ptr, int image_size)return -FDT_ERR_BADSTATE ; } - data = ptr +sizeof (image_header_t); + data = (const unsigned char *)ptr +sizeof (image_header_t); len = image_size -sizeof (image_header_t) ;if (crc32 (0 , data, len) !=be32_to_cpu (hdr->ih_dcrc)) {
Signature · 1 line
1.5.3.4
PATCH 2/2 tools: mkimage: split code into core, default and FIT image specific
This is first step towards cleaning mkimage code for kwbimage support in clean way. Current mkimage code is very specific to uimg generation whereas the same framework can be used to generate other image types like Kirkwood boot image (kwbimage-TBD). For this, the architecture of mkimage code need to modified.
Here is the brief plan for the same:-
a) Split mkimage code into core and image specific support
b) Implement callback function for image specific functions
c) Move image type specific code to respective c files Currently there are two types of file generation/list supported (i.e uimg, FIT), the code is abstracted from mkimage.c/h and put in default_image.c and fit_image.c all code in these file is static except init function call
d) mkimage_register API is added to add new image type support All above is addressed in this patch
e) Add kwbimage type support to this new framework (TBD)
--- tools/Makefile | 9 +- tools/default_image.c | 149 ++++++++++++++ tools/fit_image.c | 212 +++++++++++++++++++ tools/mkimage.c | 539 +++++++++++++++++++++++-------------------------- tools/mkimage.h | 101 +++++++++- 5 files changed, 720 insertions(+), 290 deletions(-) create mode 100644 tools/default_image.c create mode 100644 tools/fit_image.c
tools/Makefile +8 -1
@@ -177,7 +177,8 @@ $(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ $(STRIP) $@ -$(obj)mkimage$(SFX): $(obj)crc32.o $(obj)mkimage.o $(obj)image.o $(obj)md5.o $(obj)mkimage.o \ +$(obj)mkimage$(SFX): $(obj)crc32.o $(obj)default_image.o $(obj)fit_image.o $(obj)image.o \ + $(obj)md5.o $(obj)mkimage.o \ $(obj)os_support.o $(obj)sha1.o $(LIBFDT_OBJS) $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^ $(STRIP) $@
@@ -190,6 +191,12 @@ $(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o $(CC) $(CFLAGS) -o $@ $^ # Some files complain if compiled with -pedantic, use FIT_CFLAGS +$(obj)default_image.o: $(SRCTREE)/tools/default_image.c + $(CC) -g $(FIT_CFLAGS) -c -o $@ $< + +$(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c + $(CC) -g $(FIT_CFLAGS) -c -o $@ $< + $(obj)image.o: $(SRCTREE)/common/image.c $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
tools/default_image.c new file +149 -0
149 lines not on this page · raw message
tools/fit_image.c new file +212 -0
212 lines not on this page · raw message
tools/mkimage.c +251 -288
795 lines not on this page · raw message
tools/mkimage.h +100 -1
116 lines not on this page · raw message
Signature · 1 line
1.5.3.4
PATCH 2/2 tools: mkimage: split code into core, default and FIT image specific
Dear Prafulla Wadaskar,
Quoted 19 lines · In message <[email protected]> you wrote:
This is first step towards cleaning mkimage code for kwbimage support in clean way. Current mkimage code is very specific to uimg generation whereas the same framework can be used to generate other image types like Kirkwood boot image (kwbimage-TBD). For this, the architecture of mkimage code need to modified.
Here is the brief plan for the same:-
a) Split mkimage code into core and image specific support
b) Implement callback function for image specific functions
c) Move image type specific code to respective c files Currently there are two types of file generation/list supported (i.e uimg, FIT), the code is abstracted from mkimage.c/h and put indefault_image.candfit_image.call code in these file is static except init function call
d)mkimage_registerAPI is added to add new image type support All above is addressed in this patch
e) Add kwbimage type support to this new framework (TBD)Signed-off-by Prafulla Wadaskar <[email protected]>
Quoted 9 lines
--- tools/Makefile | 9 +- tools/default_image.c | 149 ++++++++++++++ tools/fit_image.c | 212 +++++++++++++++++++ tools/mkimage.c | 539 +++++++++++++++++++++++-------------------------- tools/mkimage.h | 101 +++++++++- 5 files changed, 720 insertions(+), 290 deletions(-) create mode 100644 tools/default_image.c create mode 100644 tools/fit_image.c
I have only but a few minor comments (which I probably would clean up myself), but the problem is: the patch doesn't apply to the current "mkimage" branch:
Applying: tools: mkimage: split code into core, default and FIT image specific
error: patch failed: tools/mkimage.c:152
error: tools/mkimage.c: patch does not apply
fatal: sha1 information is lacking or useless (tools/Makefile). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0002.
Could you please reebase and resubmit? Thanks in advance (I like how you implemented this now!)
Best regards,
Wolfgang Denk
Signature · 5 lines
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 Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das nennen sie ihren Standpunkt.
PATCH 2/2 tools: mkimage: split code into core, default and FIT image specific
Quoted 39 lines
-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Tuesday, August 18, 2009 8:16 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik
Subject: Re: [U-Boot] [PATCH 2/2] tools: mkimage: split code into core, default and FIT image specificDear Prafulla Wadaskar,
In message
Quoted 18 lines · <[email protected]> you wrote:
This is first step towards cleaning mkimage code for kwbimage support in clean way. Current mkimage code is very specific to uimg generation whereas the same framework can be used to generate other image types like Kirkwood boot image (kwbimage-TBD). For this, the architecture of mkimage code need to modified.
Here is the brief plan for the same:-
a) Split mkimage code into core and image specific support
b) Implement callback function for image specific functions
c) Move image type specific code to respective c files Currently there are two types of file generation/list supported (i.e uimg, FIT), the code is abstracted from mkimage.c/h and put indefault_image.candfit_image.call code in these file is static except init function call
d)mkimage_registerAPI is added to add new image type support All above is addressed in this patch
e) Add kwbimage type support to this new framework (TBD)Quoted 6 lines
Signed-off-by Prafulla Wadaskar <[email protected]>--- tools/Makefile | 9 +- tools/default_image.c | 149 ++++++++++++++ tools/fit_image.c | 212 +++++++++++++++++++ tools/mkimage.c | 539+++++++++++++++++++++++--------------------------
Quoted 8 lines
Quoted 4 lines
tools/mkimage.h | 101 +++++++++- 5 files changed, 720 insertions(+), 290 deletions(-) create mode 100644 tools/default_image.c create mode 100644 tools/fit_image.cI have only but a few minor comments (which I probably would clean up myself), but the problem is: the patch doesn't apply to the current "mkimage" branch:
Oh... I will repost it for mkimage branch
Thanks....
Regards..
Prafulla . .
Wolfgang Denk
AppliedPATCH v2 1/2 tools: mkimage: Fixed build warnings
In reply to Prafulla WadaskarDear Prafulla Wadaskar,
Quoted 9 lines · In message <[email protected]> you wrote:
uninitialized retval variable warning fixed
crc32 APIs moved tocrc.h(newly added) and build warnings fixed some indentation tabs fixedSigned-off-by Prafulla Wadaskar <[email protected]>---
Change log:
v2: updated as per review feedback for v1
Quoted 5 lines
include/common.h | 4 +--- include/u-boot/crc.h | 33 +++++++++++++++++++++++++++++++++ tools/mkimage.c | 20 +++++++++++--------- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 include/u-boot/crc.h
Applied to "mkimage" branch.
I decided to omit the tab cleanup, and used "uchar" instead of "unsigned char" so no reformatting due to growing line length was needed. This way the changes are (IMHO) better visible.
Hope this is OK with you.
Best regards,
Wolfgang Denk
Signature · 5 lines
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 Build a system that even a fool can use and only a fool will want to use it.
PATCH v2 1/2 tools: mkimage: Fixed build warnings
Dear Prafulla,
Quoted 17 lines · In message <[email protected]> I wrote:
Quoted 9 lines · In message <[email protected]> you wrote:
uninitialized retval variable warning fixed
crc32 APIs moved tocrc.h(newly added) and build warnings fixed some indentation tabs fixedSigned-off-by Prafulla Wadaskar <[email protected]>---
Change log:
v2: updated as per review feedback for v1Quoted 5 lines
include/common.h | 4 +--- include/u-boot/crc.h | 33 +++++++++++++++++++++++++++++++++ tools/mkimage.c | 20 +++++++++++--------- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 include/u-boot/crc.h
Quoted 5 lines
Applied to "mkimage" branch.
I decided to omit the tab cleanup, and used "uchar" instead of "unsigned char" so no reformatting due to growing line length was needed. This way the changes are (IMHO) better visible.
...what a stupid idea. I didn't consider that "uchar" might not be defined in standard compile environments. Undone.
I applied your original patch now, just with minimal indentation changes.
Sorry for the confusion.
Best regards,
Wolfgang Denk
Signature · 7 lines
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 usually tell my classes "if you are using @ and [] together in this
class, you will almost certainly NOT get what you want. That's going
down the wrong tunnel. There's no cheese at the end of that tunnel."
-- Randal L. Schwartz in <[email protected]>PATCH v2 1/2 tools: mkimage: Fixed build warnings
Quoted 37 lines
-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Tuesday, August 18, 2009 6:23 PM
To: Prafulla Wadaskar
Cc: u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik
Subject: Re: [U-Boot] [PATCH v2 1/2] tools: mkimage: Fixed build warningsDear Prafulla,
Quoted 2 lines · In message <[email protected]> I wrote:
In message
Quoted 15 lines · <[email protected]> you wrote:
Quoted 9 lines
uninitialized retval variable warning fixed
crc32 APIs moved tocrc.h(newly added) and build warnings fixed some indentation tabs fixedSigned-off-by Prafulla Wadaskar <[email protected]>---
Change log:
v2: updated as per review feedback for v1Quoted 5 lines
include/common.h | 4 +--- include/u-boot/crc.h | 33 +++++++++++++++++++++++++++++++++ tools/mkimage.c | 20 +++++++++++--------- 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 include/u-boot/crc.hQuoted 5 lines
Applied to "mkimage" branch.
I decided to omit the tab cleanup, and used "uchar" instead of "unsigned char" so no reformatting due to growing line length was needed. This way the changes are (IMHO) better visible.
Quoted 5 lines
...what a stupid idea. I didn't consider that "uchar" might not be defined in standard compile environments. Undone.
I applied your original patch now, just with minimal indentation changes.
:-D Thanks....
Regards..
Prafulla . .
Quoted 16 lines
Sorry for the confusion.
Best regards,
Wolfgang Denk
Signature · 7 lines
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 usually tell my classes "if you are using @ and [] together in this class, you will almost certainly NOT get what you want. That's going down the wrong tunnel. There's no cheese at the end of that tunnel." -- Randal L. Schwartz in <[email protected]>