[U-Boot-Users] [PATCH 0/5 RESEND] [new uImage] patchset4 - assorted patches

Addressed comments posted to the first version, dropped patch fixing fdt_support.c compilation with DEBUG enabled.
Patches apply on top of new-image branch of the u-boot-testing, with recent master pulled. Original description:
This patchset encompasses some clean-ups and fixes, and adds the new uImage #define knob (CONFIG_FIT), which is enabled by default. The patchset also adds some new uImage-specific functionality: (1) a routine to parse new-style arguments to bootm (and other commands), (2) a generic function for retrieving images. It lays foundation for the soon-to-follow: - low-level new uImage handling functions - mkimage extensions to allow generation of new format images - U-Boot support for booting new format images
Code from this patchset will be soon available from the new-image branch of the u-boot-testing repository.
Please review, test and provide comments.
Marian Balakowicz (5): [new uImage] Fix erroneous use of image_get_magic() in fdc/usb cmds [new uImage] Rename and move print_image_hdr() routine [new uImage] Add fit_parse_conf() and fit_parse_subimage() routines [new uImage] Add gen_get_image() routine [new uImage] Pull in libfdt if CONFIG_FIT is enabled
Regards, Bartlomiej

From: Marian Balakowicz m8@semihalf.com
New uImage format (Flattened Image Tree) requires libfdt functionality, print out error message if CONFIG_OF_LIBFDT is not defined.
New uImage support is enabled by defining CONFIG_FIT (and CONFIG_OF_LIBFDT). This commit turns it on by default.
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
cpu/mpc5xxx/cpu.c | 2 +- cpu/mpc8260/cpu.c | 2 +- cpu/mpc8xx/cpu.c | 2 +- include/image.h | 9 +++++++++ 4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/cpu/mpc5xxx/cpu.c b/cpu/mpc5xxx/cpu.c index e4d6168..7522afe 100644 --- a/cpu/mpc5xxx/cpu.c +++ b/cpu/mpc5xxx/cpu.c @@ -114,7 +114,7 @@ unsigned long get_tbclk (void)
/* ------------------------------------------------------------------------- */
-#ifdef CONFIG_OF_LIBFDT +#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP) void ft_cpu_setup(void *blob, bd_t *bd) { int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4; diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c index 55e61a1..414759e 100644 --- a/cpu/mpc8260/cpu.c +++ b/cpu/mpc8260/cpu.c @@ -300,7 +300,7 @@ void watchdog_reset (void) #endif /* CONFIG_WATCHDOG */
/* ------------------------------------------------------------------------- */ -#if defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP) void ft_cpu_setup (void *blob, bd_t *bd) { char * cpu_path = "/cpus/" OF_CPU; diff --git a/cpu/mpc8xx/cpu.c b/cpu/mpc8xx/cpu.c index c878352..5d4ab82 100644 --- a/cpu/mpc8xx/cpu.c +++ b/cpu/mpc8xx/cpu.c @@ -638,7 +638,7 @@ void reset_8xx_watchdog (volatile immap_t * immr) #endif /* CONFIG_WATCHDOG */
/* ------------------------------------------------------------------------- */ -#if defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP) void ft_cpu_setup (void *blob, bd_t *bd) { char * cpu_path = "/cpus/" OF_CPU; diff --git a/include/image.h b/include/image.h index dbbbee9..ecfce72 100644 --- a/include/image.h +++ b/include/image.h @@ -35,10 +35,19 @@
#include <asm/byteorder.h> #include <command.h> + #ifndef USE_HOSTCC #include <linux/string.h> #include <asm/u-boot.h> + +/* new uImage format support enabled by default */ +#define CONFIG_FIT 1 +#define CONFIG_OF_LIBFDT 1 + +#if defined(CONFIG_FIT) && !defined(CONFIG_OF_LIBFDT) +#error "CONFIG_OF_LIBFDT not enabled, required by CONFIG_FIT!" #endif +#endif /* USE_HOSTCC */
/* * Operating System Codes

From: Marian Balakowicz m8@semihalf.com
This routine assures that image (whether legacy or FIT) is not in a special dataflash storage.
If image address is a dataflash address image is moved to system RAM.
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
common/cmd_bootm.c | 22 +-------- common/image.c | 126 +++++++++++++++++++++++++++++++++++++++++++--------- include/image.h | 6 ++ lib_ppc/bootm.c | 5 ++ 4 files changed, 119 insertions(+), 40 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 2ddb191..ebb6b69 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -44,10 +44,6 @@ #include <hush.h> #endif
-#ifdef CONFIG_HAS_DATAFLASH -#include <dataflash.h> -#endif - DECLARE_GLOBAL_DATA_PTR;
extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp); @@ -304,12 +300,8 @@ static image_header_t *get_kernel (cmd_tbl_t *cmdtp, int flag, show_boot_progress (1); printf ("## Booting image at %08lx ...\n", img_addr);
-#ifdef CONFIG_HAS_DATAFLASH - if (addr_dataflash (img_addr)){ - hdr = (image_header_t *)CFG_LOAD_ADDR; - read_dataflash (img_addr, image_get_header_size (), (char *)hdr); - } else -#endif + /* copy from dataflash if needed */ + img_addr = gen_get_image (img_addr); hdr = (image_header_t *)img_addr;
if (!image_check_magic(hdr)) { @@ -324,16 +316,8 @@ static image_header_t *get_kernel (cmd_tbl_t *cmdtp, int flag, show_boot_progress (-2); return NULL; } - show_boot_progress (3);
-#ifdef CONFIG_HAS_DATAFLASH - if (addr_dataflash (img_addr)) - read_dataflash (img_addr + image_get_header_size (), - image_get_data_size (hdr), - (char *)image_get_data (hdr)); -#endif - - /* uImage is in a system RAM, pointed to by hdr */ + show_boot_progress (3); print_image_hdr (hdr);
if (verify) { diff --git a/common/image.c b/common/image.c index 39e5f23..ab6b8e6 100644 --- a/common/image.c +++ b/common/image.c @@ -41,6 +41,12 @@ #include <logbuff.h> #endif
+#if defined(CONFIG_FIT) +#include <fdt.h> +#include <libfdt.h> +#include <fdt_support.h> +#endif + extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
#ifdef CONFIG_CMD_BDI @@ -305,6 +311,103 @@ const char* image_get_comp_name (uint8_t comp) }
/** + * gen_image_get_format - get image format type + * @img_addr: image start address + * + * gen_image_get_format() checks whether provided address points to a valid + * legacy or FIT image. + * + * returns: + * image format type or IMAGE_FORMAT_INVALID if no image is present + */ +int gen_image_get_format (void *img_addr) +{ + ulong format = IMAGE_FORMAT_INVALID; + image_header_t *hdr; +#if defined(CONFIG_FIT) + char *fit_hdr; +#endif + + hdr = (image_header_t *)img_addr; + if (image_check_magic(hdr)) + format = IMAGE_FORMAT_LEGACY; +#if defined(CONFIG_FIT) + else { + fit_hdr = (char *)img_addr; + if (fdt_check_header (fit_hdr) == 0) + format = IMAGE_FORMAT_FIT; + } +#endif + + return format; +} + +/** + * gen_get_image - get image from special storage (if necessary) + * @img_addr: image start address + * + * gen_get_image() checks if provided image start adddress is located + * in a dataflash storage. If so, image is moved to a system RAM memory. + * + * returns: + * image start address after possible relocation from special storage + */ +ulong gen_get_image (ulong img_addr) +{ + ulong ram_addr, h_size, d_size; + + h_size = image_get_header_size (); +#if defined(CONFIG_FIT) + if (sizeof(struct fdt_header) > h_size) + h_size = sizeof(struct fdt_header); +#endif + +#ifdef CONFIG_HAS_DATAFLASH + if (addr_dataflash (img_addr)){ + ram_addr = CFG_LOAD_ADDR; + debug (" Reading image header from dataflash address " + "%08lx to RAM address %08lx\n", img_addr, ram_addr); + read_dataflash (img_addr, h_size, (char *)ram_addr); + } else +#endif + return img_addr; + + ram_addr = img_addr; + + switch (gen_image_get_format ((void *)ram_addr)) { + case IMAGE_FORMAT_LEGACY: + d_size = image_get_data_size ((image_header_t *)ram_addr); + debug (" Legacy format image found at 0x%08lx, size 0x%08lx\n", + ram_addr, d_size); + break; +#if defined(CONFIG_FIT) + case IMAGE_FORMAT_FIT: + d_size = fdt_totalsize((void *)ram_addr) - h_size; + debug (" FIT/FDT format image found at 0x%08lx, size 0x%08lx\n", + ram_addr, d_size); + + break; +#endif + default: + printf (" No valid image found at 0x%08lx\n", img_addr); + return ram_addr; + } + +#ifdef CONFIG_HAS_DATAFLASH + if (addr_dataflash (img_addr)) { + debug (" Reading image remaining data from dataflash address " + "%08lx to RAM address %08lx\n", img_addr + h_size, + ram_addr + h_size); + + read_dataflash (img_addr + h_size, d_size, + (char *)(ram_addr + h_size)); + } +#endif + + return ram_addr; +} + +/** * image_get_ramdisk - get and verify ramdisk image * @cmdtp: command table pointer * @flag: command flag @@ -334,15 +437,8 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
show_boot_progress (9);
-#ifdef CONFIG_HAS_DATAFLASH - if (addr_dataflash (rd_addr)) { - rd_hdr = (image_header_t *)CFG_LOAD_ADDR; - debug (" Reading Ramdisk image header from dataflash address " - "%08lx to %08lx\n", rd_addr, (ulong)rd_hdr); - read_dataflash (rd_addr, image_get_header_size (), - (char *)rd_hdr); - } else -#endif + /* copy from dataflash if needed */ + rd_addr = gen_get_image (rd_addr); rd_hdr = (image_header_t *)rd_addr;
if (!image_check_magic (rd_hdr)) { @@ -360,18 +456,6 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, show_boot_progress (10); print_image_hdr (rd_hdr);
-#ifdef CONFIG_HAS_DATAFLASH - if (addr_dataflash (rd_addr)) { - debug (" Reading Ramdisk image data from dataflash address " - "%08lx to %08lx\n", rd_addr + image_get_header_size, - (ulong)image_get_data (rd_hdr)); - - read_dataflash (rd_addr + image_get_header_size (), - image_get_data_size (rd_hdr), - (char *)image_get_data (rd_hdr)); - } -#endif - if (verify) { puts(" Verifying Checksum ... "); if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) { diff --git a/include/image.h b/include/image.h index ecfce72..b4de49d 100644 --- a/include/image.h +++ b/include/image.h @@ -343,6 +343,12 @@ const char* image_get_arch_name (uint8_t arch); const char* image_get_type_name (uint8_t type); const char* image_get_comp_name (uint8_t comp);
+#define IMAGE_FORMAT_INVALID 0x00 +#define IMAGE_FORMAT_LEGACY 0x01 +#define IMAGE_FORMAT_FIT 0x02 +int gen_image_get_format (void *img_addr); +ulong gen_get_image (ulong img_addr); + image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], ulong rd_addr, uint8_t arch, int verify); diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 69ec459..04a9665 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -234,6 +234,11 @@ static ulong get_fdt (ulong alloc_current,
if(argc > 3) { fdt = (char *)simple_strtoul (argv[3], NULL, 16); + + debug ("## Checking for 'FDT'/'FDT image' at %08lx\n", fdt); + + /* copy from dataflash if needed */ + fdt = (char *)gen_get_image ((ulong)fdt); fdt_hdr = (image_header_t *)fdt;
if (fdt_check_header (fdt) == 0) {

From: Marian Balakowicz m8@semihalf.com
Introducing routines for parsing new uImage format bootm arguments: [<addr>]#<conf> - configuration specification [<addr>]:<subimg> - subimage specification
New format images can contain multiple subimages of the same type. For example a single new format image file can contain three kernels, two ramdisks and a couple of FDT blobs. Subimage and configuration specifications are extensions to bootm (and other image-related commands) arguments' syntax that allow to specify which particular subimage should be operated on.
Subimage specification is used to denote a particular subimage. Configurations are a bit more complex -- they are used to define a particualr booting setup, for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple, etc.
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
common/image.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/image.h | 10 +++++++ 2 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/common/image.c b/common/image.c index ab6b8e6..7362328 100644 --- a/common/image.c +++ b/common/image.c @@ -774,4 +774,82 @@ ulong get_boot_kbd (ulong alloc_current, bd_t **kbd) } #endif /* CONFIG_PPC || CONFIG_M68K */
+#if defined(CONFIG_FIT) +/*****************************************************************************/ +/* New uImage format routines */ +/*****************************************************************************/ +static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr, + ulong *addr, const char **name) +{ + const char *sep; + + *addr = addr_curr; + *name = NULL; + + sep = strchr (spec, sepc); + if (sep) { + if (sep - spec > 0) + *addr = simple_strtoul (spec, NULL, 16); + + *name = sep + 1; + return 1; + } + + return 0; +} + +/** + * fit_parse_conf - parse FIT configuration spec + * @spec: input string, containing configuration spec + * @add_curr: current image address (to be used as a possible default) + * @addr: pointer to a ulong variable, will hold FIT image address of a given + * configuration + * @conf_name double pointer to a char, will hold pointer to a configuration + * unit name + * + * fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>, + * where <addr> is a FIT image address that contains configuration + * with a <conf> unit name. + * + * Address part is optional, and if omitted default add_curr will + * be used instead. + * + * returns: + * 1 if spec is a valid configuration string, + * addr and conf_name are set accordingly + * 0 otherwise + */ +inline int fit_parse_conf (const char *spec, ulong addr_curr, + ulong *addr, const char **conf_name) +{ + return fit_parse_spec (spec, '#', addr_curr, addr, conf_name); +} + +/** + * fit_parse_subimage - parse FIT subimage spec + * @spec: input string, containing subimage spec + * @add_curr: current image address (to be used as a possible default) + * @addr: pointer to a ulong variable, will hold FIT image address of a given + * subimage + * @image_name: double pointer to a char, will hold pointer to a subimage name + * + * fit_parse_subimage() expects subimage spec in the for of + * [<addr>]:<subimage>, where <addr> is a FIT image address that contains + * subimage with a <subimg> unit name. + * + * Address part is optional, and if omitted default add_curr will + * be used instead. + * + * returns: + * 1 if spec is a valid subimage string, + * addr and image_name are set accordingly + * 0 otherwise + */ +inline int fit_parse_subimage (const char *spec, ulong addr_curr, + ulong *addr, const char **image_name) +{ + return fit_parse_spec (spec, ':', addr_curr, addr, image_name); +} +#endif /* CONFIG_FIT */ + #endif /* USE_HOSTCC */ diff --git a/include/image.h b/include/image.h index b4de49d..4923612 100644 --- a/include/image.h +++ b/include/image.h @@ -367,6 +367,16 @@ ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end); ulong get_boot_kbd (ulong alloc_current, bd_t **kbd); #endif /* CONFIG_PPC || CONFIG_M68K */
+#if defined(CONFIG_FIT) +/* + * New uImage format + */ +inline int fit_parse_conf (const char *spec, ulong addr_curr, + ulong *addr, const char **conf_name); +inline int fit_parse_subimage (const char *spec, ulong addr_curr, + ulong *addr, const char **image_name); +#endif /* CONFIG_FIT */ + #endif /* USE_HOSTCC */
#endif /* __IMAGE_H__ */

On Feb 21, 2008, at 11:55 AM, Bartlomiej Sieka wrote:
From: Marian Balakowicz m8@semihalf.com
Introducing routines for parsing new uImage format bootm arguments: [<addr>]#<conf> - configuration specification [<addr>]:<subimg> - subimage specification
New format images can contain multiple subimages of the same type. For example a single new format image file can contain three kernels, two ramdisks and a couple of FDT blobs. Subimage and configuration specifications are extensions to bootm (and other image-related commands) arguments' syntax that allow to specify which particular subimage should be operated on.
Subimage specification is used to denote a particular subimage. Configurations are a bit more complex -- they are used to define a particualr booting setup, for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple, etc.
Signed-off-by: Marian Balakowicz m8@semihalf.com
Mind adding a example of what <conf> and <subimg> would/could be set to. (Its not clear to me if these are indexes [0..n] or labels)
- k

Kumar Gala wrote: [...]
Introducing routines for parsing new uImage format bootm arguments: [<addr>]#<conf> - configuration specification [<addr>]:<subimg> - subimage specification
New format images can contain multiple subimages of the same type. For example a single new format image file can contain three kernels, two ramdisks and a couple of FDT blobs. Subimage and configuration specifications are extensions to bootm (and other image-related commands) arguments' syntax that allow to specify which particular subimage should be operated on.
Subimage specification is used to denote a particular subimage. Configurations are a bit more complex -- they are used to define a particualr booting setup, for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple, etc.
Signed-off-by: Marian Balakowicz m8@semihalf.com
Mind adding a example of what <conf> and <subimg> would/could be set to. (Its not clear to me if these are indexes [0..n] or labels)
Both <conf> and <subimg> are unit names from the image source file (dts format) used to generate the image. For example, having an image generated using the source file with the following structure:
/{ images { kernel@1 { ... kernel@2 { ... ramdisk@1 { ... fdt@1 { ... fdt@2 { ... fdt@3 { ... };
configurations { conf@1 { ... }; };
one could in U-Boot do:
bootm 300000:kernel@1 bootm 300000:kernel@2 :ramdisk@1 :fdt@3 bootm 300000:kernel@2 - 300000:fdt@1 bootm 300000:config@1
This will be documented better in the form of a doc/README.<something> file that we plan to post. And I'd rather not add too much documentation to the commit log, especially now that Wolfgang has merged the patches to the new-image branch of u-boot-testing.
Regards, Bartlomiej

From: Marian Balakowicz m8@semihalf.com
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
board/mpl/common/common_util.c | 2 + common/cmd_bootm.c | 61 ++-------------------------------------- common/cmd_doc.c | 2 + common/cmd_fdc.c | 2 + common/cmd_ide.c | 2 + common/cmd_nand.c | 4 +-- common/cmd_scsi.c | 2 + common/cmd_usb.c | 2 + common/cmd_ximg.c | 2 + common/image.c | 56 ++++++++++++++++++++++++++++++++++++- include/common.h | 3 -- include/image.h | 1 + lib_ppc/bootm.c | 2 + 13 files changed, 69 insertions(+), 72 deletions(-)
diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c index 30c6ca9..b171ca5 100644 --- a/board/mpl/common/common_util.c +++ b/board/mpl/common/common_util.c @@ -185,7 +185,7 @@ mpl_prg_image(uchar *ld_addr) puts("Bad Magic Number\n"); return 1; } - print_image_hdr(hdr); + image_print_contents (hdr); if (!image_check_os (hdr, IH_OS_U_BOOT)) { puts("No U-Boot Image\n"); return 1; diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index ebb6b69..bb60a84 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -36,10 +36,6 @@ #include <environment.h> #include <asm/byteorder.h>
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) -#include <rtc.h> -#endif - #ifdef CFG_HUSH_PARSER #include <hush.h> #endif @@ -69,7 +65,6 @@ static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); static void fixup_silent_linux (void); #endif
-static void print_type (image_header_t *hdr); static image_header_t *get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], int verify, ulong *os_data, ulong *os_len); @@ -318,7 +313,7 @@ static image_header_t *get_kernel (cmd_tbl_t *cmdtp, int flag, }
show_boot_progress (3); - print_image_hdr (hdr); + image_print_contents (hdr);
if (verify) { puts (" Verifying Checksum ... "); @@ -445,7 +440,7 @@ static int image_info (ulong addr) return 1; }
- print_image_hdr (hdr); + image_print_contents (hdr);
puts (" Verifying Checksum ... "); if (!image_check_dcrc (hdr)) { @@ -493,7 +488,7 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) goto next_sector;
printf ("Image at %08lX:\n", (ulong)hdr); - print_image_hdr (hdr); + image_print_contents (hdr);
puts (" Verifying Checksum ... "); if (!image_check_dcrc (hdr)) { @@ -521,56 +516,6 @@ U_BOOT_CMD( /*******************************************************************/ /* helper routines */ /*******************************************************************/ -void print_image_hdr (image_header_t *hdr) -{ -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) - time_t timestamp = (time_t)image_get_time (hdr); - struct rtc_time tm; -#endif - - printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr)); - -#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) - to_tm (timestamp, &tm); - printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n", - tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); -#endif - puts (" Image Type: "); - print_type (hdr); - - printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr)); - print_size (image_get_data_size (hdr), "\n"); - printf (" Load Address: %08x\n" - " Entry Point: %08x\n", - image_get_load (hdr), image_get_ep (hdr)); - - if (image_check_type (hdr, IH_TYPE_MULTI)) { - int i; - ulong data, len; - ulong count = image_multi_count (hdr); - - puts (" Contents:\n"); - for (i = 0; i < count; i++) { - image_multi_getimg (hdr, i, &data, &len); - printf (" Image %d: %8ld Bytes = ", i, len); - print_size (len, "\n"); - } - } -} - -static void print_type (image_header_t *hdr) -{ - const char *os, *arch, *type, *comp; - - os = image_get_os_name (image_get_os (hdr)); - arch = image_get_arch_name (image_get_arch (hdr)); - type = image_get_type_name (image_get_type (hdr)); - comp = image_get_comp_name (image_get_comp (hdr)); - - printf ("%s %s %s (%s)", arch, os, type, comp); -} - #ifdef CONFIG_SILENT_CONSOLE static void fixup_silent_linux () { diff --git a/common/cmd_doc.c b/common/cmd_doc.c index b20a2e1..70bbd31 100644 --- a/common/cmd_doc.c +++ b/common/cmd_doc.c @@ -265,7 +265,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (image_check_magic (hdr)) {
- print_image_hdr (hdr); + image_print_contents (hdr);
cnt = image_get_image_size (hdr); cnt -= SECTORSIZE; diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c index 3b8f80b..c97abfb 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -840,7 +840,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) printf ("Bad Magic Number\n"); return 1; } - print_image_hdr (hdr); + image_print_contents (hdr);
imsize= image_get_image_size (hdr); nrofblk=imsize/512; diff --git a/common/cmd_ide.c b/common/cmd_ide.c index bcd1325..a396643 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -462,7 +462,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } show_boot_progress (50);
- print_image_hdr (hdr); + image_print_contents (hdr);
cnt = image_get_image_size (hdr); cnt += info.blksz - 1; diff --git a/common/cmd_nand.c b/common/cmd_nand.c index bfa39d7..7fd6667 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -521,7 +521,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand, } show_boot_progress (57);
- print_image_hdr (hdr); + image_print_contents (hdr);
cnt = image_get_image_size (hdr); if (jffs2) { @@ -984,7 +984,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (image_check_magic (hdr)) {
- print_image_hdr (hdr); + image_print_contents (hdr);
cnt = image_get_image_size (hdr); cnt -= SECTORSIZE; diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index c2b27a5..5aae7ec 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -285,7 +285,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; }
- print_image_hdr (hdr); + image_print_contents (hdr); cnt = image_get_image_size (hdr); cnt += info.blksz - 1; cnt /= info.blksz; diff --git a/common/cmd_usb.c b/common/cmd_usb.c index db2e754..2d7a85a 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -398,7 +398,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; }
- print_image_hdr (hdr); + image_print_contents (hdr);
cnt = image_get_image_size (hdr); cnt += info.blksz - 1; diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c index ab579cd..7d83dc3 100644 --- a/common/cmd_ximg.c +++ b/common/cmd_ximg.c @@ -70,7 +70,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) return 1; } #ifdef DEBUG - print_image_hdr (hdr); + image_print_contents (hdr); #endif
if (!image_check_type (hdr, IH_TYPE_MULTI)) { diff --git a/common/image.c b/common/image.c index 7362328..690e0af 100644 --- a/common/image.c +++ b/common/image.c @@ -41,6 +41,10 @@ #include <logbuff.h> #endif
+#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) +#include <rtc.h> +#endif + #if defined(CONFIG_FIT) #include <fdt.h> #include <libfdt.h> @@ -310,6 +314,56 @@ const char* image_get_comp_name (uint8_t comp) return name; }
+static void image_print_type (image_header_t *hdr) +{ + const char *os, *arch, *type, *comp; + + os = image_get_os_name (image_get_os (hdr)); + arch = image_get_arch_name (image_get_arch (hdr)); + type = image_get_type_name (image_get_type (hdr)); + comp = image_get_comp_name (image_get_comp (hdr)); + + printf ("%s %s %s (%s)", arch, os, type, comp); +} + +void image_print_contents (image_header_t *hdr) +{ +#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) + time_t timestamp = (time_t)image_get_time (hdr); + struct rtc_time tm; +#endif + + printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr)); + +#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) + to_tm (timestamp, &tm); + printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n", + tm.tm_year, tm.tm_mon, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); +#endif + puts (" Image Type: "); + image_print_type (hdr); + + printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr)); + print_size (image_get_data_size (hdr), "\n"); + printf (" Load Address: %08x\n" + " Entry Point: %08x\n", + image_get_load (hdr), image_get_ep (hdr)); + + if (image_check_type (hdr, IH_TYPE_MULTI)) { + int i; + ulong data, len; + ulong count = image_multi_count (hdr); + + puts (" Contents:\n"); + for (i = 0; i < count; i++) { + image_multi_getimg (hdr, i, &data, &len); + printf (" Image %d: %8ld Bytes = ", i, len); + print_size (len, "\n"); + } + } +} + /** * gen_image_get_format - get image format type * @img_addr: image start address @@ -454,7 +508,7 @@ image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag, }
show_boot_progress (10); - print_image_hdr (rd_hdr); + image_print_contents (rd_hdr);
if (verify) { puts(" Verifying Checksum ... "); diff --git a/include/common.h b/include/common.h index cd8aad0..3f05b5e 100644 --- a/include/common.h +++ b/include/common.h @@ -224,9 +224,6 @@ void flash_perror (int); /* common/cmd_autoscript.c */ int autoscript (ulong addr);
-/* common/cmd_bootm.c */ -void print_image_hdr (image_header_t *hdr); - extern ulong load_addr; /* Default Load Address */
/* common/cmd_nvedit.c */ diff --git a/include/image.h b/include/image.h index 4923612..502d35a 100644 --- a/include/image.h +++ b/include/image.h @@ -342,6 +342,7 @@ const char* image_get_os_name (uint8_t os); const char* image_get_arch_name (uint8_t arch); const char* image_get_type_name (uint8_t type); const char* image_get_comp_name (uint8_t comp); +void image_print_contents (image_header_t *hdr);
#define IMAGE_FORMAT_INVALID 0x00 #define IMAGE_FORMAT_LEGACY 0x01 diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c index 04a9665..d2ee3dc 100644 --- a/lib_ppc/bootm.c +++ b/lib_ppc/bootm.c @@ -254,7 +254,7 @@ static ulong get_fdt (ulong alloc_current, printf ("## Flattened Device Tree Image at %08lx\n", fdt_hdr);
- print_image_hdr (fdt_hdr); + image_print_contents (fdt_hdr);
image_start = (ulong)fdt_hdr; image_end = image_get_image_end (fdt_hdr);

From: Marian Balakowicz m8@semihalf.com
Signed-off-by: Marian Balakowicz m8@semihalf.com ---
common/cmd_fdc.c | 2 +- common/cmd_usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/cmd_fdc.c b/common/cmd_fdc.c index c97abfb..9ddc59b 100644 --- a/common/cmd_fdc.c +++ b/common/cmd_fdc.c @@ -836,7 +836,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) return 1; } hdr = (image_header_t *)addr; - if (!image_get_magic (hdr)) { + if (!image_check_magic (hdr)) { printf ("Bad Magic Number\n"); return 1; } diff --git a/common/cmd_usb.c b/common/cmd_usb.c index 2d7a85a..3f1aa7d 100644 --- a/common/cmd_usb.c +++ b/common/cmd_usb.c @@ -388,7 +388,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
hdr = (image_header_t *)addr;
- if (!image_get_magic (hdr)) { + if (!image_check_magic (hdr)) { printf("\n** Bad Magic Number **\n"); return 1; }
participants (2)
-
Bartlomiej Sieka
-
Kumar Gala