From 6a590c5f5fd12cdd27f3153522acfac3854590e7 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Wed, 28 Oct 2009 22:13:35 +0100 Subject: Building of FIT images does not work. The type is not set for generation of the FIT images, resulting in no images being created without printing or returning an error Signed-off-by: Remy Bohmer --- tools/mkimage.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/mkimage.c b/tools/mkimage.c index ab6ea32ad..8a20594f3 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -229,6 +229,7 @@ main (int argc, char **argv) case 'f': if (--argc <= 0) usage (); + params.type = IH_TYPE_FLATDT; params.datafile = *++argv; params.fflag = 1; goto NXTARG; -- cgit v1.2.3 From faf36c1437c95e4a86835633d9801c5f6396a3c7 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Wed, 28 Oct 2009 22:13:36 +0100 Subject: Fix mingw tools build mkimage does not build due to missing strtok_r() and getline() implementation Signed-off-by: Remy Bohmer --- tools/mingw_support.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/mingw_support.h | 2 + 2 files changed, 159 insertions(+) (limited to 'tools') diff --git a/tools/mingw_support.c b/tools/mingw_support.c index 67cd6e115..63797108b 100644 --- a/tools/mingw_support.c +++ b/tools/mingw_support.c @@ -24,7 +24,9 @@ #include "mingw_support.h" #include #include +#include #include +#include #include int fsync(int fd) @@ -77,3 +79,158 @@ int munmap(void *addr, size_t len) return 0; } + +/* Reentrant string tokenizer. Generic version. + Copyright (C) 1991,1996-1999,2001,2004,2007 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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, 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. */ + +/* Parse S into tokens separated by characters in DELIM. + If S is NULL, the saved pointer in SAVE_PTR is used as + the next starting point. For example: + char s[] = "-abc-=-def"; + char *sp; + x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" + x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL + x = strtok_r(NULL, "=", &sp); // x = NULL + // s = "abc\0-def\0" +*/ +char *strtok_r(char *s, const char *delim, char **save_ptr) +{ + char *token; + + if (s == NULL) + s = *save_ptr; + + /* Scan leading delimiters. */ + s += strspn(s, delim); + if (*s == '\0') { + *save_ptr = s; + return NULL; + } + + /* Find the end of the token. */ + token = s; + s = strpbrk (token, delim); + if (s == NULL) { + /* This token finishes the string. */ + *save_ptr = memchr(token, '\0', strlen(token)); + } else { + /* Terminate the token and make *SAVE_PTR point past it. */ + *s = '\0'; + *save_ptr = s + 1; + } + return token; +} + +/* getline.c -- Replacement for GNU C library function getline + +Copyright (C) 1993, 1996, 2001, 2002 Free Software Foundation, Inc. + +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */ + +/* Always add at least this many bytes when extending the buffer. */ +#define MIN_CHUNK 64 + +/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR + + OFFSET (and null-terminate it). *LINEPTR is a pointer returned from + malloc (or NULL), pointing to *N characters of space. It is realloc'd + as necessary. Return the number of characters read (not including the + null terminator), or -1 on error or EOF. + NOTE: There is another getstr() function declared in . */ +static int getstr(char **lineptr, size_t *n, FILE *stream, + char terminator, size_t offset) +{ + int nchars_avail; /* Allocated but unused chars in *LINEPTR. */ + char *read_pos; /* Where we're reading into *LINEPTR. */ + int ret; + + if (!lineptr || !n || !stream) + return -1; + + if (!*lineptr) { + *n = MIN_CHUNK; + *lineptr = malloc(*n); + if (!*lineptr) + return -1; + } + + nchars_avail = *n - offset; + read_pos = *lineptr + offset; + + for (;;) { + register int c = getc(stream); + + /* We always want at least one char left in the buffer, since we + always (unless we get an error while reading the first char) + NUL-terminate the line buffer. */ + + assert(*n - nchars_avail == read_pos - *lineptr); + if (nchars_avail < 2) { + if (*n > MIN_CHUNK) + *n *= 2; + else + *n += MIN_CHUNK; + + nchars_avail = *n + *lineptr - read_pos; + *lineptr = realloc(*lineptr, *n); + if (!*lineptr) + return -1; + read_pos = *n - nchars_avail + *lineptr; + assert(*n - nchars_avail == read_pos - *lineptr); + } + + if (c == EOF || ferror (stream)) { + /* Return partial line, if any. */ + if (read_pos == *lineptr) + return -1; + else + break; + } + + *read_pos++ = c; + nchars_avail--; + + if (c == terminator) + /* Return the line. */ + break; + } + + /* Done - NUL terminate and return the number of chars read. */ + *read_pos = '\0'; + + ret = read_pos - (*lineptr + offset); + return ret; +} + +int getline (char **lineptr, size_t *n, FILE *stream) +{ + return getstr(lineptr, n, stream, '\n', 0); +} diff --git a/tools/mingw_support.h b/tools/mingw_support.h index 9e45e6491..27936746b 100644 --- a/tools/mingw_support.h +++ b/tools/mingw_support.h @@ -44,5 +44,7 @@ typedef ULONG ulong; int fsync(int fd); void *mmap(void *, size_t, int, int, int, int); int munmap(void *, size_t); +char *strtok_r(char *s, const char *delim, char **save_ptr); +int getline(char **lineptr, size_t *n, FILE *stream); #endif /* __MINGW_SUPPORT_H_ */ -- cgit v1.2.3 From 8204e068110e8abe5db9c3b7df9971b58cda8f26 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 4 Nov 2009 16:03:25 -0500 Subject: tools: gitignore *.exe binaries Signed-off-by: Mike Frysinger --- tools/.gitignore | 1 + 1 file changed, 1 insertion(+) (limited to 'tools') diff --git a/tools/.gitignore b/tools/.gitignore index 03f54ef12..cb067a407 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -8,3 +8,4 @@ /ncp /ubsha1 /inca-swap-bytes +/*.exe -- cgit v1.2.3 From fd66066ee3ce15c2966feb9b2be0f0d51a95db48 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 4 Nov 2009 16:13:19 -0500 Subject: img2srec: use standard types The img2srec code creates a lot of typedefs with common names. These easily clash with system headers that include these typedefs (like mingw). Signed-off-by: Mike Frysinger --- tools/img2srec.c | 164 +++++++++++++++++++++---------------------------------- 1 file changed, 62 insertions(+), 102 deletions(-) (limited to 'tools') diff --git a/tools/img2srec.c b/tools/img2srec.c index f10379fe4..ec7696402 100644 --- a/tools/img2srec.c +++ b/tools/img2srec.c @@ -53,6 +53,7 @@ |*************************************************************************/ #include "os_support.h" +#include #include #include #include @@ -62,64 +63,23 @@ #include #include -/************************************************************************* -| DEFINES -|*************************************************************************/ - -#define FALSE 0 -#define TRUE 1 - -/************************************************************************* -| MACROS -|*************************************************************************/ - -/************************************************************************* -| TYPEDEFS -|*************************************************************************/ - -typedef uint8_t CHAR; -typedef uint8_t BYTE; -typedef uint16_t WORD; -typedef uint32_t DWORD; -typedef int BOOL; - -/************************************************************************* -| LOCALS -|*************************************************************************/ - -/************************************************************************* -| PROTOTYPES -|*************************************************************************/ - -static char *ExtractHex(DWORD *value, char *getPtr); -static char *ExtractDecimal(DWORD *value, char *getPtr); -static void ExtractNumber(DWORD *value, char *getPtr); -static BYTE *ExtractWord(WORD *value, BYTE *buffer); -static BYTE *ExtractLong(DWORD *value, BYTE *buffer); -static BYTE *ExtractBlock(WORD count, BYTE *data, BYTE *buffer); -static char *WriteHex(char *pa, BYTE value, WORD *pCheckSum); -static char *BuildSRecord(char *pa, WORD sType, DWORD addr, - const BYTE *data, int nCount); -static void ConvertELF(char *fileName, DWORD loadOffset); -int main(int argc, char *argv[]); - /************************************************************************* | FUNCTIONS |*************************************************************************/ -static char* ExtractHex (DWORD* value, char* getPtr) +static char* ExtractHex (uint32_t* value, char* getPtr) { - DWORD num; - DWORD digit; - BYTE c; + uint32_t num; + uint32_t digit; + uint8_t c; while (*getPtr == ' ') getPtr++; num = 0; for (;;) { c = *getPtr; - if ((c >= '0') && (c <= '9')) digit = (DWORD)(c - '0'); - else if ((c >= 'A') && (c <= 'F')) digit = (DWORD)(c - 'A' + 10); - else if ((c >= 'a') && (c <= 'f')) digit = (DWORD)(c - 'a' + 10); + if ((c >= '0') && (c <= '9')) digit = (uint32_t)(c - '0'); + else if ((c >= 'A') && (c <= 'F')) digit = (uint32_t)(c - 'A' + 10); + else if ((c >= 'a') && (c <= 'f')) digit = (uint32_t)(c - 'a' + 10); else break; num <<= 4; num += digit; @@ -129,17 +89,17 @@ static char* ExtractHex (DWORD* value, char* getPtr) return getPtr; } /* ExtractHex */ -static char* ExtractDecimal (DWORD* value, char* getPtr) +static char* ExtractDecimal (uint32_t* value, char* getPtr) { - DWORD num; - DWORD digit; - BYTE c; + uint32_t num; + uint32_t digit; + uint8_t c; while (*getPtr == ' ') getPtr++; num = 0; for (;;) { c = *getPtr; - if ((c >= '0') && (c <= '9')) digit = (DWORD)(c - '0'); + if ((c >= '0') && (c <= '9')) digit = (uint32_t)(c - '0'); else break; num *= 10; num += digit; @@ -150,13 +110,13 @@ static char* ExtractDecimal (DWORD* value, char* getPtr) } /* ExtractDecimal */ -static void ExtractNumber (DWORD* value, char* getPtr) +static void ExtractNumber (uint32_t* value, char* getPtr) { - BOOL neg = FALSE;; + bool neg = false;; while (*getPtr == ' ') getPtr++; if (*getPtr == '-') { - neg = TRUE; + neg = true; getPtr++; } /* if */ if ((*getPtr == '0') && ((*(getPtr+1) == 'x') || (*(getPtr+1) == 'X'))) { @@ -170,38 +130,38 @@ static void ExtractNumber (DWORD* value, char* getPtr) } /* ExtractNumber */ -static BYTE* ExtractWord(WORD* value, BYTE* buffer) +static uint8_t* ExtractWord(uint16_t* value, uint8_t* buffer) { - WORD x; - x = (WORD)*buffer++; - x = (x<<8) + (WORD)*buffer++; + uint16_t x; + x = (uint16_t)*buffer++; + x = (x<<8) + (uint16_t)*buffer++; *value = x; return buffer; } /* ExtractWord */ -static BYTE* ExtractLong(DWORD* value, BYTE* buffer) +static uint8_t* ExtractLong(uint32_t* value, uint8_t* buffer) { - DWORD x; - x = (DWORD)*buffer++; - x = (x<<8) + (DWORD)*buffer++; - x = (x<<8) + (DWORD)*buffer++; - x = (x<<8) + (DWORD)*buffer++; + uint32_t x; + x = (uint32_t)*buffer++; + x = (x<<8) + (uint32_t)*buffer++; + x = (x<<8) + (uint32_t)*buffer++; + x = (x<<8) + (uint32_t)*buffer++; *value = x; return buffer; } /* ExtractLong */ -static BYTE* ExtractBlock(WORD count, BYTE* data, BYTE* buffer) +static uint8_t* ExtractBlock(uint16_t count, uint8_t* data, uint8_t* buffer) { while (count--) *data++ = *buffer++; return buffer; } /* ExtractBlock */ -static char* WriteHex(char* pa, BYTE value, WORD* pCheckSum) +static char* WriteHex(char* pa, uint8_t value, uint16_t* pCheckSum) { - WORD temp; + uint16_t temp; static char ByteToHex[] = "0123456789ABCDEF"; @@ -214,13 +174,13 @@ static char* WriteHex(char* pa, BYTE value, WORD* pCheckSum) } -static char* BuildSRecord(char* pa, WORD sType, DWORD addr, - const BYTE* data, int nCount) +static char* BuildSRecord(char* pa, uint16_t sType, uint32_t addr, + const uint8_t* data, int nCount) { - WORD addrLen; - WORD sRLen; - WORD checkSum; - WORD i; + uint16_t addrLen; + uint16_t sRLen; + uint16_t checkSum; + uint16_t i; switch (sType) { case 0: @@ -244,11 +204,11 @@ static char* BuildSRecord(char* pa, WORD sType, DWORD addr, *pa++ = (char)(sType + '0'); sRLen = addrLen + nCount + 1; checkSum = 0; - pa = WriteHex(pa, (BYTE)sRLen, &checkSum); + pa = WriteHex(pa, (uint8_t)sRLen, &checkSum); /* Write address field */ for (i = 1; i <= addrLen; i++) { - pa = WriteHex(pa, (BYTE)(addr >> (8 * (addrLen - i))), &checkSum); + pa = WriteHex(pa, (uint8_t)(addr >> (8 * (addrLen - i))), &checkSum); } /* for */ /* Write code/data fields */ @@ -258,25 +218,25 @@ static char* BuildSRecord(char* pa, WORD sType, DWORD addr, /* Write checksum field */ checkSum = ~checkSum; - pa = WriteHex(pa, (BYTE)checkSum, &checkSum); + pa = WriteHex(pa, (uint8_t)checkSum, &checkSum); *pa++ = '\0'; return pa; } -static void ConvertELF(char* fileName, DWORD loadOffset) +static void ConvertELF(char* fileName, uint32_t loadOffset) { FILE* file; int i; int rxCount; - BYTE rxBlock[1024]; - DWORD loadSize; - DWORD firstAddr; - DWORD loadAddr; - DWORD loadDiff = 0; + uint8_t rxBlock[1024]; + uint32_t loadSize; + uint32_t firstAddr; + uint32_t loadAddr; + uint32_t loadDiff = 0; Elf32_Ehdr elfHeader; Elf32_Shdr sectHeader[32]; - BYTE* getPtr; + uint8_t* getPtr; char srecLine[128]; char *hdr_name; @@ -292,11 +252,11 @@ static void ConvertELF(char* fileName, DWORD loadOffset) getPtr = ExtractBlock(sizeof elfHeader.e_ident, elfHeader.e_ident, rxBlock); getPtr = ExtractWord(&elfHeader.e_type, getPtr); getPtr = ExtractWord(&elfHeader.e_machine, getPtr); - getPtr = ExtractLong((DWORD *)&elfHeader.e_version, getPtr); - getPtr = ExtractLong((DWORD *)&elfHeader.e_entry, getPtr); - getPtr = ExtractLong((DWORD *)&elfHeader.e_phoff, getPtr); - getPtr = ExtractLong((DWORD *)&elfHeader.e_shoff, getPtr); - getPtr = ExtractLong((DWORD *)&elfHeader.e_flags, getPtr); + getPtr = ExtractLong((uint32_t *)&elfHeader.e_version, getPtr); + getPtr = ExtractLong((uint32_t *)&elfHeader.e_entry, getPtr); + getPtr = ExtractLong((uint32_t *)&elfHeader.e_phoff, getPtr); + getPtr = ExtractLong((uint32_t *)&elfHeader.e_shoff, getPtr); + getPtr = ExtractLong((uint32_t *)&elfHeader.e_flags, getPtr); getPtr = ExtractWord(&elfHeader.e_ehsize, getPtr); getPtr = ExtractWord(&elfHeader.e_phentsize, getPtr); getPtr = ExtractWord(&elfHeader.e_phnum, getPtr); @@ -319,16 +279,16 @@ static void ConvertELF(char* fileName, DWORD loadOffset) fseek(file, elfHeader.e_shoff, SEEK_SET); for (i = 0; i < elfHeader.e_shnum; i++) { rxCount = fread(rxBlock, 1, sizeof sectHeader[0], file); - getPtr = ExtractLong((DWORD *)§Header[i].sh_name, rxBlock); - getPtr = ExtractLong((DWORD *)§Header[i].sh_type, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_flags, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_addr, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_offset, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_size, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_link, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_info, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_addralign, getPtr); - getPtr = ExtractLong((DWORD *)§Header[i].sh_entsize, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_name, rxBlock); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_type, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_flags, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_addr, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_offset, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_size, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_link, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_info, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_addralign, getPtr); + getPtr = ExtractLong((uint32_t *)§Header[i].sh_entsize, getPtr); if (rxCount != sizeof sectHeader[0]) { fclose(file); fprintf (stderr, "*** illegal file format\n"); @@ -342,7 +302,7 @@ static void ConvertELF(char* fileName, DWORD loadOffset) ++hdr_name; } /* write start record */ - (void)BuildSRecord(srecLine, 0, 0, (BYTE *)hdr_name, strlen(hdr_name)); + (void)BuildSRecord(srecLine, 0, 0, (uint8_t *)hdr_name, strlen(hdr_name)); printf("%s\r\n",srecLine); /* write data records */ @@ -395,7 +355,7 @@ static void ConvertELF(char* fileName, DWORD loadOffset) int main( int argc, char *argv[ ]) { - DWORD offset; + uint32_t offset; if (argc == 2) { ConvertELF(argv[1], 0); -- cgit v1.2.3 From 1a99de2cb4d08eb3bf9fb3f60a9d533150de8c0e Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 24 Nov 2009 16:42:08 -0600 Subject: tools/mkimage: Assume FDT image type for FIT images When building a Flattened Image Tree (FIT) the image type needs to be "flat_dt". Commit 89a4d6b12fd6394898b8a454cbabeaf1cd59bae5 introduced a regression which caused the user to need to specify the "-T flat_dt" parameter on the command line when building a FIT image. The "-T flat_dt" parameter should not be needed and is at odds with the current FIT image documentation. Signed-off-by: Peter Tyser --- tools/mkimage.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools') diff --git a/tools/mkimage.c b/tools/mkimage.c index 8a20594f3..2bf9a5b5e 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -232,6 +232,12 @@ main (int argc, char **argv) params.type = IH_TYPE_FLATDT; params.datafile = *++argv; params.fflag = 1; + + /* + * The flattened image tree (FIT) format + * requires a flattened device tree image type + */ + params.type = IH_TYPE_FLATDT; goto NXTARG; case 'n': if (--argc <= 0) -- cgit v1.2.3 From 8e1c89663cc8796b85588910046e03b388a7597c Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 24 Nov 2009 16:42:09 -0600 Subject: tools/fit_image.c: Remove unused fit_set_header() The FIT fit_set_header() function was copied from the standard uImage's image_set_header() function during mkimage reorganization. However, the fit_set_header() function is not used since FIT images use a standard device tree blob header. Signed-off-by: Peter Tyser --- tools/fit_image.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'tools') diff --git a/tools/fit_image.c b/tools/fit_image.c index d1e612fec..ef9ffeeec 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -155,38 +155,6 @@ static int fit_handle_file (struct mkimage_params *params) return (EXIT_SUCCESS); } -static void fit_set_header (void *ptr, struct stat *sbuf, int ifd, - struct mkimage_params *params) -{ - uint32_t checksum; - - image_header_t * hdr = (image_header_t *)ptr; - - checksum = crc32 (0, - (const unsigned char *)(ptr + - sizeof(image_header_t)), - sbuf->st_size - sizeof(image_header_t)); - - /* Build new header */ - image_set_magic (hdr, IH_MAGIC); - image_set_time (hdr, sbuf->st_mtime); - image_set_size (hdr, sbuf->st_size - sizeof(image_header_t)); - image_set_load (hdr, params->addr); - image_set_ep (hdr, params->ep); - image_set_dcrc (hdr, checksum); - image_set_os (hdr, params->os); - image_set_arch (hdr, params->arch); - image_set_type (hdr, params->type); - image_set_comp (hdr, params->comp); - - image_set_name (hdr, params->imagename); - - checksum = crc32 (0, (const unsigned char *)hdr, - sizeof(image_header_t)); - - image_set_hcrc (hdr, checksum); -} - static int fit_check_params (struct mkimage_params *params) { return ((params->dflag && (params->fflag || params->lflag)) || @@ -202,7 +170,7 @@ static struct image_type_params fitimage_params = { .print_header = fit_print_contents, .check_image_type = fit_check_image_types, .fflag_handle = fit_handle_file, - .set_header = fit_set_header, + .set_header = NULL, /* FIT images use DTB header */ .check_params = fit_check_params, }; -- cgit v1.2.3 From c81296c16fd9d12422c9968cc0f1d9bf440a7d88 Mon Sep 17 00:00:00 2001 From: Peter Tyser Date: Tue, 24 Nov 2009 16:42:10 -0600 Subject: tools/mkimage: Print FIT image contents after creation Previously, there was no indication to the user that a FIT image was successfully created after executing mkimage. For example: $ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its" Adding some additional output after creating a FIT image lets the user know exactly what is contained in their image, eg: $ mkimage -f uImage.its uImage.itb DTC: dts->dtb on file "uImage.its" FIT description: Linux kernel 2.6.32-rc7-00201-g7550d6f-dirty Created: Tue Nov 24 15:43:01 2009 Image 0 (kernel@1) Description: Linux Kernel 2.6.32-rc7-00201-g7550d6f-dirty Type: Kernel Image Compression: gzip compressed Data Size: 2707311 Bytes = 2643.86 kB = 2.58 MB Architecture: PowerPC OS: Linux Load Address: 0x00000000 Entry Point: 0x00000000 Hash algo: crc32 Hash value: efe0798b Hash algo: sha1 Hash value: ecafba8c95684f2c8fec67e33c41ec88df1534d7 Image 1 (fdt@1) Description: Flattened Device Tree blob Type: Flat Device Tree Compression: uncompressed Data Size: 12288 Bytes = 12.00 kB = 0.01 MB Architecture: PowerPC Hash algo: crc32 Hash value: a5cab676 Hash algo: sha1 Hash value: 168722b13e305283cfd6603dfe8248cc329adea6 Default Configuration: 'config@1' Configuration 0 (config@1) Description: Default Linux kernel Kernel: kernel@1 FDT: fdt@1 This brings the behavior of creating a FIT image in line with creating a standard uImage, which also prints out the uImage contents after creation. Signed-off-by: Peter Tyser --- tools/mkimage.c | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'tools') diff --git a/tools/mkimage.c b/tools/mkimage.c index 2bf9a5b5e..6826eae77 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -299,23 +299,35 @@ NXTARG: ; params.imagefile = *argv; - if (!params.fflag){ - if (params.lflag) { - ifd = open (params.imagefile, O_RDONLY|O_BINARY); - } else { - ifd = open (params.imagefile, - O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); - } + if (params.fflag){ + if (tparams->fflag_handle) + /* + * in some cases, some additional processing needs + * to be done if fflag is defined + * + * For ex. fit_handle_file for Fit file support + */ + retval = tparams->fflag_handle(¶ms); - if (ifd < 0) { - fprintf (stderr, "%s: Can't open %s: %s\n", - params.cmdname, params.imagefile, - strerror(errno)); - exit (EXIT_FAILURE); - } + if (retval != EXIT_SUCCESS) + exit (retval); + } + + if (params.lflag || params.fflag) { + ifd = open (params.imagefile, O_RDONLY|O_BINARY); + } else { + ifd = open (params.imagefile, + O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); + } + + if (ifd < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + params.cmdname, params.imagefile, + strerror(errno)); + exit (EXIT_FAILURE); } - if (params.lflag) { + if (params.lflag || params.fflag) { /* * list header information of existing image */ @@ -352,17 +364,6 @@ NXTARG: ; (void) munmap((void *)ptr, sbuf.st_size); (void) close (ifd); - exit (retval); - } else if (params.fflag) { - if (tparams->fflag_handle) - /* - * in some cases, some additional processing needs - * to be done if fflag is defined - * - * For ex. fit_handle_file for Fit file support - */ - retval = tparams->fflag_handle(¶ms); - exit (retval); } -- cgit v1.2.3