Skip to contentSkip to conversation

patchset 7 - core functionality

PATCH New Bartlomiej Sieka 3 participants 25 messages Mar 12, 2008 – Mar 19, 2008

lore
Share & tools
lore
#0 lore raw

cover patchset 7 - core functionality

Hello,

This patch series implements the core of the new uImage support functionality, i.e., the actual booting of images in new format, as well as support in auxiliary commands that operate on images. There are also few fixing patches in the series.

The patchset concludes major development work on the new uImage format, with one missing piece (MD5 support) to be posted in a day or two. Generally, the new format supports everything that the old format does, with the exception of XIP and standalone applications. Also, only booting of the Linux kernel is supported. If there are people interested in contributing to these areas, please step forward.

It's a good moment to thank everybody who helped with this effort by commenting on requirements, etc., and those who helped by reviewing patches. At the same time it's important that people help with testing. The patchset 7 code is already available in the new-image branch of the u-boot-testing repository -- please pull the code and try it out on the boards that you care about. Reading doc/uImage.FIT/howto.txt should be sufficient to get you started. Note that adding support for the new image format increases the size of U-Boot, so depending on your Flash sector layout, adjustments to CFG_MONITOR_LEN might be necessary.

The code builds on all architectures, and has been tested on ppc, but more thorough testing is needed. In particular, reports on test results of the following areas not tested due to hardware unavailability will be greatly appreciated:
- boards other that ppc
- booting from dataflash
- U-Boot commands:
- diskboot
- docboot
- fdcboot
- fpga
- nboot
- scsiboot
- usbboot

Regards,
Bartlomiej

Bartlomiej Sieka (1):
[new uImage] Add support for new uImage format to mkimage tool

Marian Balakowicz (19):
[new uImage] Add new uImage format documentation and examples
[new uImage] Fix definition of common bootm_headers_t fields
[new uImage] Fix build problems on trab board
[new uImage] Add proper ramdisk/FDT handling when FIT configuration is used [new uImage] More verbose kernel image uncompress error message
[new uImage] Use show_boot_progress() for new uImage format
[new uImage] Add new uImage fromat support to fpga command
[new uImage] Add new uImage format handling to other bootm related commands [new uImage] Add new uImage format support to imgextract command
[new uImage] Add new uImage format support to autoscript routine
[new uImage] Add new uImage format support to arch specific do_bootm_linux() routines [new uImage] Add node offsets for FIT images listed in struct bootm_headers [new uImage] ppc: Add new uImage format support to FDT handling routines [new uImage] Re-enable interrupts for non automatic booting
[new uImage] Remove unnecessary arguments passed to ramdisk routines [new uImage] Add new uImage format support for ramdisk handling
[new uImage] Add new uImage format support for kernel booting
[new uImage] Add new uImage format support for imls and iminfo commands [new uImage] Make node unit names const in struct bootm_headers

#1 lore raw

PATCH 1/20 Make node unit names const in struct bootm_headers

From: Marian Balakowicz <[email protected]>

---

 include/image.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
include/image.h +3 -3
index 704a3b4..bbd481d 100644
@@ -200,14 +200,14 @@ typedef struct bootm_headers {
 
 #if defined(CONFIG_FIT)
 	void		*fit_hdr_os;	/* os FIT image header */
-	char		*fit_uname_os;	/* os subimage node unit name */
+	const char	*fit_uname_os;	/* os subimage node unit name */
 
 	void		*fit_hdr_rd;	/* init ramdisk FIT image header */
-	char		*fit_uname_rd;	/* init ramdisk node unit name */
+	const char	*fit_uname_rd;	/* init ramdisk node unit name */
 
 #if defined(CONFIG_PPC)
 	void		*fit_hdr_fdt;	/* FDT blob FIT image header */
-	char		*fit_uname_fdt;	/* FDT blob node unit name */
+	const char	*fit_uname_fdt;	/* FDT blob node unit name */
 #endif
 	int		verify;		/* getenv("verify")[0] != 'n' */
 	int		autostart;	/* getenv("autostart")[0] != 'n' */
#2 lore raw

PATCH 2/20 Add support for new uImage format to mkimage tool

In reply to Bartlomiej Sieka

Support for the new uImage format (FIT) is added to mkimage tool. Commandline syntax is appropriately extended:

mkimage [-D dtc_options] -f fit-image.its fit-image

mkimage (together with dtc) takes fit-image.its and referenced therein binaries (like vmlinux.bin.gz) as inputs, and produces fit-image file -- the final image that can be transferred to the target (e.g., via tftp) and then booted using the bootm command in U-Boot.

---

 include/image.h |   15 ++-
 tools/mkimage.c |  257 ++++++++++++++++++++++++++++++++++++++++++++-----------
 tools/mkimage.h |    6 +
 3 files changed, 222 insertions(+), 56 deletions(-)
include/image.h +11 -4
index bbd481d..681c753 100644
@@ -40,14 +40,21 @@
 #include <lmb.h>
 #include <linux/string.h>
 #include <asm/u-boot.h>
-#endif /* USE_HOSTCC */
 
-/* new uImage format support enabled by default */
+/* new uImage format support enabled on target
+ * To be moved to board configuration file */
 #define CONFIG_FIT		1
 #define CONFIG_OF_LIBFDT	1
+#define CONFIG_FIT_VERBOSE	1 /* enable fit_format_{error,warning}() */
+
+#else
 
-/* enable fit_format_error(), fit_format_warning() */
-#define CONFIG_FIT_VERBOSE	1
+/* new uImage format support enabled on host */
+#define CONFIG_FIT		1
+#define CONFIG_OF_LIBFDT	1
+#define CONFIG_FIT_VERBOSE	1 /* enable fit_format_{error,warning}() */
+
+#endif /* USE_HOSTCC */
 
 #if defined(CONFIG_FIT) && !defined(CONFIG_OF_LIBFDT)
 #error "CONFIG_OF_LIBFDT not enabled, required by CONFIG_FIT!"
tools/mkimage.c +205 -52

336 lines not on this page · raw message

tools/mkimage.h +6 -0
index 41cd156..a2d5248 100644
@@ -43,6 +43,12 @@
 #define debug(fmt,args...)
 #endif /* MKIMAGE_DEBUG */
 
+#define MKIMAGE_TMPFILE_SUFFIX		".tmp"
+#define MKIMAGE_MAX_TMPFILE_LEN		256
+#define MKIMAGE_DEFAULT_DTC_OPTIONS	"-I dts -O dtb -p 500"
+#define MKIMAGE_MAX_DTC_CMDLINE_LEN	512
+#define MKIMAGE_DTC			"dtc"   /* assume dtc is in $PATH */
+
 #if defined(__BEOS__) || defined(__NetBSD__) || defined(__APPLE__)
 #include <inttypes.h>
 #endif
#3 lore raw

PATCH 2/20 Add support for new uImage format to mkimage tool

Hi A,

I'm trying to use the newimage patches but I cannot compile the mkimage tool because the uint8_t uint16_t, ... types are not defined into the fdt.h include file (that uses them).
I just patched the fdt.h source adding the following code in the head:

#ifndef __KERNEL__

typedef          unsigned char   uint8_t;
typedef          unsigned short  uint16_t;
typedef          unsigned int    uint32_t;
typedef          unsigned long long int  uint64_t;

#else
#include <linux/types.h>
#endif

This is just a dirty approach... but it can be useful for who have the same problem. Anyway, can you correct the include/fdt.h source (or the tool/mkimage.c) to avoid this issue?

Thanks a lot,

luigi

Quoted 10 lines · Bartlomiej Sieka

Support for the new uImage format (FIT) is added to mkimage tool. Commandline syntax is appropriately extended:

mkimage [-D dtc_options] -f fit-image.its fit-image

mkimage (together with dtc) takes fit-image.its and referenced therein binaries (like vmlinux.bin.gz) as inputs, and produces fit-image file -- the final image that can be transferred to the target (e.g., via tftp) and then booted using the bootm command in U-Boot.

Signature · 10 lines
     ______       Luigi Mantellini
   .'______'.     R&D - Software
  (.'      '.)    Industrie Dial Face S.p.A.
  ( :=----=: )    Via Canzo, 4
  ('.______.')    20068 Peschiera Borromeo (MI), Italy
   '.______.'     Tel.: +39 02 5167 2813
                  Fax:  +39 02 5167 2459
Ind.  Dial Face   Email: luigi.mantellini at idf-hit.com
www.idf-hit.com   GPG fingerprint: 3DD1 7B71 FBDF 6376 1B4A
                                   B003 175F E979 907E 1650
#4 lore raw

PATCH 2/20 Add support for new uImage format to mkimage tool

Quoted 1 line · Luigi 'Comio' Mantellini

Hi A,

Hi Luigi,

Quoted 4 lines

I'm trying to use the newimage patches but I cannot compile the mkimage tool because the uint8_t uint16_t, ... types are not defined into the fdt.h include file (that uses them).

Hmm, I've not seen this. How are you trying to compile mkimage? What system are you on?

I usually compile mkimage by configuring the build for any board, and then compiling just the tools directory. Could you try this:
make TQM5200_config
make tools

BTW: "make tools" without prior make *_config says "make: Nothing to be done for `tools'." -- can somebody offer a suggestions on how to fix this?

Regards,
Bartlomiej

#5 lore raw

PATCH 3/20 Add new uImage format support for imls and iminfo commands

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

imls and iminfo can now recognize nad print out contents of the new (FIT) format uImages.

---

 common/cmd_bootm.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
common/cmd_bootm.c +11 -5
index 10403aa..daee7bf 100644
@@ -556,7 +556,13 @@ static int image_info (ulong addr)
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		puts ("   FIT image found\n");
-		fit_unsupported ("iminfo");
+
+		if (!fit_check_format (hdr)) {
+			puts ("Bad FIT image format!\n");
+			return 1;
+		}
+
+		fit_print_contents (hdr);
 		return 0;
 #endif
 	default:
@@ -601,9 +607,6 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 			switch (genimg_get_format (hdr)) {
 			case IMAGE_FORMAT_LEGACY:
-				if (!image_check_magic (hdr))
-					goto next_sector;
-
 				if (!image_check_hcrc (hdr))
 					goto next_sector;
 
@@ -619,8 +622,11 @@ int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 				break;
 #if defined(CONFIG_FIT)
 			case IMAGE_FORMAT_FIT:
+				if (!fit_check_format (hdr))
+					goto next_sector;
+
 				printf ("FIT Image at %08lX:\n", (ulong)hdr);
-				fit_unsupported ("imls");
+				fit_print_contents (hdr);
 				break;
 #endif
 			default:
#6 lore raw

PATCH 4/20 Add new uImage format support for kernel booting

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

New format uImages are recognized by the bootm command, validity of specified kernel component image is checked and its data section located and used for further processing (uncompress, load, etc.)

---

 common/cmd_bootm.c |  155 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 144 insertions(+), 11 deletions(-)
common/cmd_bootm.c +144 -11
index daee7bf..96d09e6 100644
@@ -66,6 +66,11 @@ static int do_imls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 static void fixup_silent_linux (void);
 #endif
 
+static image_header_t *image_get_kernel (ulong img_addr, int verify);
+#if defined(CONFIG_FIT)
+static int fit_check_kernel (const void *fit, int os_noffset, int verify);
+#endif
+
 static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[],
 		bootm_headers_t *images, ulong *os_data, ulong *os_len);
 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
@@ -125,6 +130,9 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
 	ulong		mem_start, mem_size;
+#if defined(CONFIG_FIT)
+	int		os_noffset;
+#endif
 
 	struct lmb lmb;
 
@@ -145,8 +153,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	/* get kernel image header, start address and length */
 	os_hdr = boot_get_kernel (cmdtp, flag, argc, argv,
 			&images, &os_data, &os_len);
-	if (os_len == 0)
+	if (os_len == 0) {
+		puts ("ERROR: can't get kernel image!\n");
 		return 1;
+	}
 
 	show_boot_progress (6);
 
@@ -162,8 +172,37 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("bootm");
-		return 1;
+		os_noffset = fit_image_get_node (images.fit_hdr_os,
+				images.fit_uname_os);
+		if (os_noffset < 0) {
+			printf ("Can't get image node for '%s'!\n",
+					images.fit_uname_os);
+			return 1;
+		}
+
+		if (fit_image_get_type (images.fit_hdr_os, os_noffset, &type)) {
+			puts ("Can't get image type!\n");
+			return 1;
+		}
+
+		if (fit_image_get_comp (images.fit_hdr_os, os_noffset, &comp)) {
+			puts ("Can't get image compression!\n");
+			return 1;
+		}
+
+		if (fit_image_get_os (images.fit_hdr_os, os_noffset, &os)) {
+			puts ("Can't get image OS!\n");
+			return 1;
+		}
+
+		image_end = fit_get_end (images.fit_hdr_os);
+
+		if (fit_image_get_load (images.fit_hdr_os, os_noffset,
+					&load_start)) {
+			puts ("Can't get image load address!\n");
+			return 1;
+		}
+		break;
 #endif
 	default:
 		puts ("ERROR: unknown image format type!\n");
@@ -360,6 +399,47 @@ static image_header_t *image_get_kernel (ulong img_addr, int verify)
 }
 
 /**
+ * fit_check_kernel - verify FIT format kernel subimage
+ * @fit_hdr: pointer to the FIT image header
+ * os_noffset: kernel subimage node offset within FIT image
+ * @verify: data CRC verification flag
+ *
+ * fit_check_kernel() verifies integrity of the kernel subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ *     1, on success
+ *     0, on failure
+ */
+#if defined (CONFIG_FIT)
+static int fit_check_kernel (const void *fit, int os_noffset, int verify)
+{
+	fit_image_print (fit, os_noffset, "   ");
+
+	if (verify) {
+		puts ("   Verifying Hash Integrity ... ");
+		if (!fit_image_check_hashes (fit, os_noffset)) {
+			puts ("Bad Data Hash\n");
+			return 0;
+		}
+		puts ("OK\n");
+	}
+
+	if (!fit_image_check_target_arch (fit, os_noffset)) {
+		puts ("Unsupported Architecture\n");
+		return 0;
+	}
+
+	if (!fit_image_check_type (fit, os_noffset, IH_TYPE_KERNEL)) {
+		puts ("Not a kernel image\n");
+		return 0;
+	}
+
+	return 1;
+}
+#endif /* CONFIG_FIT */
+
+/**
  * boot_get_kernel - find kernel image
  * @os_data: pointer to a ulong variable, will hold os data start address
  * @os_len: pointer to a ulong variable, will hold os data length
@@ -380,6 +460,10 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 	void		*fit_hdr;
 	const char	*fit_uname_config = NULL;
 	const char	*fit_uname_kernel = NULL;
+	const void	*data;
+	size_t		len;
+	int		conf_noffset;
+	int		os_noffset;
 #endif
 
 	/* find out kernel image address */
@@ -403,21 +487,22 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 	}
 
 	show_boot_progress (1);
-	printf ("## Booting kernel image at %08lx ...\n", img_addr);
 
 	/* copy from dataflash if needed */
 	img_addr = genimg_get_image (img_addr);
 
 	/* check image type, for FIT images get FIT kernel node */
+	*os_data = *os_len = 0;
 	switch (genimg_get_format ((void *)img_addr)) {
 	case IMAGE_FORMAT_LEGACY:
-
-		debug ("*  kernel: legacy format image\n");
+		printf ("## Booting kernel from Legacy Image@%08lx ...\n",
+				img_addr);
 		hdr = image_get_kernel (img_addr, images->verify);
 		if (!hdr)
 			return NULL;
 		show_boot_progress (5);
 
+		/* get os_data and os_len */
 		switch (image_get_type (hdr)) {
 		case IH_TYPE_KERNEL:
 			*os_data = image_get_data (hdr);
@@ -438,17 +523,57 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (void *)img_addr;
-		debug ("*  kernel: FIT format image\n");
-		fit_unsupported ("kernel");
-		return NULL;
+		printf ("## Booting kernel from FIT Image at %08lx ...\n",
+				img_addr);
+
+		if (!fit_check_format (fit_hdr)) {
+			puts ("Bad FIT kernel image format!\n");
+			return NULL;
+		}
+
+		if (!fit_uname_kernel) {
+			/*
+			 * no kernel image node unit name, try to get config
+			 * node first. If config unit node name is NULL
+			 * fit_conf_get_node() will try to find default config node
+			 */
+			conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+			if (conf_noffset < 0)
+				return NULL;
+
+			os_noffset = fit_conf_get_kernel_node (fit_hdr, conf_noffset);
+			fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL);
+		} else {
+			/* get kernel component image node offset */
+			os_noffset = fit_image_get_node (fit_hdr, fit_uname_kernel);
+		}
+		if (os_noffset < 0)
+			return NULL;
+
+		printf ("   Trying '%s' kernel subimage\n", fit_uname_kernel);
+
+		if (!fit_check_kernel (fit_hdr, os_noffset, images->verify))
+			return NULL;
+
+		/* get kernel image data address and length */
+		if (fit_image_get_data (fit_hdr, os_noffset, &data, &len)) {
+			puts ("Could not find kernel subimage data!\n");
+			return NULL;
+		}
+
+		*os_len = len;
+		*os_data = (ulong)data;
+		images->fit_hdr_os = fit_hdr;
+		images->fit_uname_os = fit_uname_kernel;
+		break;
 #endif
 	default:
 		printf ("Wrong Image Format for %s command\n", cmdtp->name);
 		return NULL;
 	}
 
-	debug ("   kernel data at 0x%08lx, end = 0x%08lx\n",
-			*os_data, *os_data + *os_len);
+	debug ("   kernel data at 0x%08lx, len = 0x%08lx (%d)\n",
+			*os_data, *os_len, *os_len);
 
 	return (void *)img_addr;
 }
@@ -466,6 +591,14 @@ U_BOOT_CMD(
 	"\tuse a '-' for the second argument. If you do not pass a third\n"
 	"\ta bd_info struct will be passed instead\n"
 #endif
+#if defined(CONFIG_FIT)
+	"\t\nFor the new multi component uImage format (FIT) addresses\n"
+	"\tmust be extened to include component or configuration unit name:\n"
+	"\taddr:<subimg_uname> - direct component image specification\n"
+	"\taddr#<conf_uname>   - configuration specification\n"
+	"\tUse iminfo command to get the list of existing component\n"
+	"\timages and configurations.\n"
+#endif
 );
 
 /*******************************************************************/
#7 lore raw

PATCH 5/20 Add new uImage format support for ramdisk handling

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

This patch updates boot_get_ramdisk() routine adding format verification and handling for new (FIT) uImages.

---

 common/image.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 108 insertions(+), 16 deletions(-)
common/image.c +108 -16
index 9278ea9..3b15853 100644
@@ -47,11 +47,17 @@
 
 #include <image.h>
 
-#if defined(CONFIG_FIT)
+#if defined(CONFIG_FIT) || defined (CONFIG_OF_LIBFDT)
 #include <fdt.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+#endif
+
+#if defined(CONFIG_FIT)
 #include <sha1.h>
+
+static int fit_check_ramdisk (const void *fit, int os_noffset,
+		uint8_t arch, int verify);
 #endif
 
 #ifdef CONFIG_CMD_BDI
@@ -774,8 +780,15 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	const char	*fit_uname_config = NULL;
 	const char	*fit_uname_ramdisk = NULL;
 	ulong		default_addr;
+	int		rd_noffset;
+	int		conf_noffset;
+	const void	*data;
+	size_t		size;
 #endif
 
+	*rd_start = 0;
+	*rd_end = 0;
+
 	/*
 	 * Look for a '-' which indicates to ignore the
 	 * ramdisk argument
@@ -812,8 +825,6 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		}
 
 		/* copy from dataflash if needed */
-		printf ("## Loading init Ramdisk Image at %08lx ...\n",
-				rd_addr);
 		rd_addr = genimg_get_image (rd_addr);
 
 		/*
@@ -823,17 +834,14 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		 */
 		switch (genimg_get_format ((void *)rd_addr)) {
 		case IMAGE_FORMAT_LEGACY:
-
-			debug ("*  ramdisk: legacy format image\n");
+			printf ("## Loading init Ramdisk from Legacy "
+					"Image at %08lx ...\n", rd_addr);
 
 			rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
 						rd_addr, arch, images->verify);
 
-			if (rd_hdr == NULL) {
-				*rd_start = 0;
-				*rd_end = 0;
+			if (rd_hdr == NULL)
 				return 1;
-			}
 
 			rd_data = image_get_data (rd_hdr);
 			rd_len = image_get_data_size (rd_hdr);
@@ -842,14 +850,60 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 #if defined(CONFIG_FIT)
 		case IMAGE_FORMAT_FIT:
 			fit_hdr = (void *)rd_addr;
-			debug ("*  ramdisk: FIT format image\n");
-			fit_unsupported_reset ("ramdisk");
-			return 1;
+			printf ("## Loading init Ramdisk from FIT "
+					"Image at %08lx ...\n", rd_addr);
+
+			if (!fit_check_format (fit_hdr)) {
+				puts ("Bad FIT ramdisk image format!\n");
+				return 0;
+			}
+
+			if (!fit_uname_ramdisk) {
+				/*
+				 * no ramdisk image node unit name, try to get config
+				 * node first. If config unit node name is NULL
+				 * fit_conf_get_node() will try to find default config node
+				 */
+				conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+				if (conf_noffset < 0)
+					return 0;
+
+				rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, conf_noffset);
+				fit_uname_ramdisk = fit_get_name (fit_hdr, rd_noffset, NULL);
+			} else {
+				/* get ramdisk component image node offset */
+				rd_noffset = fit_image_get_node (fit_hdr, fit_uname_ramdisk);
+			}
+			if (rd_noffset < 0)
+				return 0;
+
+			printf ("   Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
+
+			if (!fit_check_ramdisk (fit_hdr, rd_noffset, arch, images->verify))
+				return 0;
+
+			/* get ramdisk image data address and length */
+			if (fit_image_get_data (fit_hdr, rd_noffset, &data, &size)) {
+				puts ("Could not find ramdisk subimage data!\n");
+				return 0;
+			}
+
+			rd_data = (ulong)data;
+			rd_len = size;
+
+			if (fit_image_get_load (fit_hdr, rd_noffset, &rd_load)) {
+				puts ("Can't get ramdisk subimage load address!\n");
+				return 0;
+			}
+
+			images->fit_hdr_rd = fit_hdr;
+			images->fit_uname_rd = fit_uname_ramdisk;
+			break;
 #endif
 		default:
 			printf ("Wrong Image Format for %s command\n",
 					cmdtp->name);
-			rd_data = rd_len = 0;
+			rd_data = rd_len = rd_load = 0;
 		}
 
 #if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
@@ -870,7 +924,7 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		 */
 		show_boot_progress (13);
 		printf ("## Loading init Ramdisk from multi component "
-				"Image at %08lx ...\n",
+				"Legacy Image at %08lx ...\n",
 				(ulong)images->legacy_hdr_os);
 
 		image_multi_getimg (images->legacy_hdr_os, 1, &rd_data, &rd_len);
@@ -884,8 +938,6 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 	if (!rd_data) {
 		debug ("## No init Ramdisk\n");
-		*rd_start = 0;
-		*rd_end = 0;
 	} else {
 		*rd_start = rd_data;
 		*rd_end = rd_data + rd_len;
@@ -2376,4 +2428,44 @@ void fit_conf_print (const void *fit, int noffset, const char *p)
 	if (uname)
 		printf ("%s  FDT:          %s\n", p, uname);
 }
+
+/**
+ * fit_check_ramdisk - verify FIT format ramdisk subimage
+ * @fit_hdr: pointer to the FIT ramdisk header
+ * @rd_noffset: ramdisk subimage node offset within FIT image
+ * @arch: requested ramdisk image architecture type
+ * @verify: data CRC verification flag
+ *
+ * fit_check_ramdisk() verifies integrity of the ramdisk subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ *     1, on success
+ *     0, on failure
+ */
+#ifndef USE_HOSTCC
+static int fit_check_ramdisk (const void *fit, int rd_noffset, uint8_t arch, int verify)
+{
+	fit_image_print (fit, rd_noffset, "   ");
+
+	if (verify) {
+		puts ("   Verifying Hash Integrity ... ");
+		if (!fit_image_check_hashes (fit, rd_noffset)) {
+			puts ("Bad Data Hash\n");
+			return 0;
+		}
+		puts ("OK\n");
+	}
+
+	if (!fit_image_check_os (fit, rd_noffset, IH_OS_LINUX) ||
+	    !fit_image_check_arch (fit, rd_noffset, arch) ||
+	    !fit_image_check_type (fit, rd_noffset, IH_TYPE_RAMDISK)) {
+		printf ("No Linux %s Ramdisk Image\n",
+				genimg_get_arch_name(arch));
+		return 0;
+	}
+
+	return 1;
+}
+#endif /* USE_HOSTCC */
 #endif /* CONFIG_FIT */
#8 lore raw

PATCH 6/20 Remove unnecessary arguments passed to ramdisk routines

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

boot_get_ramdisk() and image_get_ramdisk() do not need all cmdtp, flag, argc and argv arguments. Simplify routines definition.

---

 common/image.c    |   32 ++++++++++++--------------------
 include/image.h   |    5 ++---
 lib_arm/bootm.c   |    6 ++++--
 lib_avr32/bootm.c |    6 ++++--
 lib_i386/bootm.c  |    7 +++++--
 lib_m68k/bootm.c  |    5 ++---
 lib_mips/bootm.c  |    7 +++++--
 lib_ppc/bootm.c   |    5 ++---
 8 files changed, 36 insertions(+), 37 deletions(-)
common/image.c +12 -20
index 3b15853..6458fb1 100644
@@ -66,9 +66,8 @@ extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[],
-		ulong rd_addr, uint8_t arch, int verify);
+static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
+						int verify);
 #else
 #include "mkimage.h"
 #include <time.h>
@@ -379,10 +378,6 @@ inline void image_print_contents_noindent (image_header_t *hdr)
 #ifndef USE_HOSTCC
 /**
  * image_get_ramdisk - get and verify ramdisk image
- * @cmdtp: command table pointer
- * @flag: command flag
- * @argc: command argument count
- * @argv: command argument list
  * @rd_addr: ramdisk image start address
  * @arch: expected ramdisk architecture
  * @verify: checksum verification flag
@@ -399,9 +394,8 @@ inline void image_print_contents_noindent (image_header_t *hdr)
  *     pointer to a ramdisk image header, if image was found and valid
  *     otherwise, return NULL
  */
-static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
-		int argc, char *argv[],
-		ulong rd_addr, uint8_t arch, int verify)
+static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
+						int verify)
 {
 	image_header_t *rd_hdr;
 
@@ -748,8 +742,6 @@ ulong genimg_get_image (ulong img_addr)
 
 /**
  * boot_get_ramdisk - main ramdisk handling routine
- * @cmdtp: command table pointer
- * @flag: command flag
  * @argc: command argument count
  * @argv: command argument list
  * @images: pointer to the bootm images structure
@@ -763,14 +755,15 @@ ulong genimg_get_image (ulong img_addr)
  *      - commandline provided address of decicated ramdisk image.
  *
  * returns:
+ *     0, if ramdisk image was found and valid, or skiped
  *     rd_start and rd_end are set to ramdisk start/end addresses if
  *     ramdisk image is found and valid
+ *
+ *     1, if ramdisk image is found but corrupted
  *     rd_start and rd_end are set to 0 if no ramdisk exists
- *     return 1 if ramdisk image is found but corrupted
  */
-int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		bootm_headers_t *images, uint8_t arch,
-		ulong *rd_start, ulong *rd_end)
+int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
+		uint8_t arch, ulong *rd_start, ulong *rd_end)
 {
 	ulong rd_addr, rd_load;
 	ulong rd_data, rd_len;
@@ -837,8 +830,8 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 			printf ("## Loading init Ramdisk from Legacy "
 					"Image at %08lx ...\n", rd_addr);
 
-			rd_hdr = image_get_ramdisk (cmdtp, flag, argc, argv,
-						rd_addr, arch, images->verify);
+			rd_hdr = image_get_ramdisk (rd_addr, arch,
+							images->verify);
 
 			if (rd_hdr == NULL)
 				return 1;
@@ -901,8 +894,7 @@ int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 			break;
 #endif
 		default:
-			printf ("Wrong Image Format for %s command\n",
-					cmdtp->name);
+			puts ("Wrong Ramdisk Image Format\n");
 			rd_data = rd_len = rd_load = 0;
 		}
 
include/image.h +2 -3
index 681c753..6fca6f4 100644
@@ -250,9 +250,8 @@ int genimg_get_comp_id (const char *name);
 int genimg_get_format (void *img_addr);
 ulong genimg_get_image (ulong img_addr);
 
-int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
-		bootm_headers_t *images, uint8_t arch,
-		ulong *rd_start, ulong *rd_end);
+int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
+		uint8_t arch, ulong *rd_start, ulong *rd_end);
 
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
 int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
lib_arm/bootm.c +4 -2
index 865e711..08eef0b 100644
@@ -95,8 +95,10 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		printf ("Using machid 0x%x from environment\n", machid);
 	}
 
-	boot_get_ramdisk (cmdtp, flag, argc, argv, images,
-			IH_ARCH_ARM, &initrd_start, &initrd_end);
+	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
+			&initrd_start, &initrd_end);
+	if (ret)
+		do_reset (cmdtp, flag, argc, argv);
 
 	show_boot_progress (15);
 
lib_avr32/bootm.c +4 -2
index e8e537a..c9a0190 100644
@@ -196,8 +196,10 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	}
 	theKernel = (void *)ep;
 
-	boot_get_ramdisk (cmdtp, flag, argc, argv, images,
-			IH_ARCH_AVR32, &initrd_start, &initrd_end);
+	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_AVR32,
+			&initrd_start, &initrd_end);
+	if (ret)
+		do_reset (cmdtp, flag, argc, argv);
 
 	show_boot_progress (15);
 
lib_i386/bootm.c +5 -2
index 76bcf6c..b4a52fa 100644
@@ -39,9 +39,12 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	ulong		initrd_start, initrd_end;
 	ulong		ep;
 	image_header_t	*hdr;
+	int		ret;
 
-	boot_get_ramdisk (cmdtp, flag, argc, argv, images,
-			IH_ARCH_I386, &initrd_start, &initrd_end);
+	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_I386,
+			&initrd_start, &initrd_end);
+	if (ret)
+		do_reset (cmdtp, flag, argc, argv);
 
 	if (images->legacy_hdr_valid) {
 		hdr = images->legacy_hdr_os;
lib_m68k/bootm.c +2 -3
index fba7499..f185bea 100644
@@ -111,9 +111,8 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
 
 	/* find ramdisk */
-	ret = boot_get_ramdisk (cmdtp, flag, argc, argv, images,
-			IH_ARCH_M68K, &rd_data_start, &rd_data_end);
-
+	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_M68K,
+			&rd_data_start, &rd_data_end);
 	if (ret)
 		goto error;
 
lib_mips/bootm.c +5 -2
index b336a36..5e7a460 100644
@@ -53,6 +53,7 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 	void	(*theKernel) (int, char **, char **, int *);
 	char	*commandline = getenv ("bootargs");
 	char	env_buf[12];
+	int	ret;
 
 	/* find kernel entry point */
 	if (images->legacy_hdr_valid) {
@@ -68,8 +69,10 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 	}
 	theKernel = (void (*)(int, char **, char **, int *))ep;
 
-	boot_get_ramdisk (cmdtp, flag, argc, argv, images,
-			IH_ARCH_MIPS, &initrd_start, &initrd_end);
+	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_MIPS,
+			&initrd_start, &initrd_end);
+	if (ret)
+		do_reset (cmdtp, flag, argc, argv);
 
 	show_boot_progress (15);
 
lib_ppc/bootm.c +2 -3
index 7977157..ac06b26 100644
@@ -160,9 +160,8 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
 
 	/* find ramdisk */
-	ret = boot_get_ramdisk (cmdtp, flag, argc, argv, images,
-			IH_ARCH_PPC, &rd_data_start, &rd_data_end);
-
+	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_PPC,
+			&rd_data_start, &rd_data_end);
 	if (ret)
 		goto error;
 
#9 lore raw

PATCH 7/20 Re-enable interrupts for non automatic booting

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Re-enable interrupts if we return from do_bootm_<os> and 'autostart' environment variable is not set to 'yes'.

---

 common/cmd_bootm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
common/cmd_bootm.c +5 -1
index 96d09e6..aca54b5 100644
@@ -342,8 +342,12 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	show_boot_progress (-9);
 #ifdef DEBUG
 	puts ("\n## Control returned to monitor - resetting...\n");
-	do_reset (cmdtp, flag, argc, argv);
+	if (images.autostart)
+		do_reset (cmdtp, flag, argc, argv);
 #endif
+	if (!images.autostart && iflag)
+		enable_interrupts();
+
 	return 1;
 }
 
#10 lore raw

PATCH 8/20 ppc: Add new uImage format support to FDT handling routines

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Support for new (FIT) format uImages is added to powerpc specific boot_get_fdt() routine which now recognizes, sanity checks FIT image and is able to access data sections of the requested component image.

---

 lib_ppc/bootm.c |  174 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 151 insertions(+), 23 deletions(-)
lib_ppc/bootm.c +151 -23
index ac06b26..60bc04b 100644
@@ -254,20 +254,24 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		 *   r6: NULL
 		 *   r7: NULL
 		 */
+		debug ("   Booting using OF flat tree...\n");
 		(*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0);
 		/* does not return */
-	}
+	} else
 #endif
-	/*
-	 * Linux Kernel Parameters (passing board info data):
-	 *   r3: ptr to board info data
-	 *   r4: initrd_start or 0 if no initrd
-	 *   r5: initrd_end - unused if r4 is 0
-	 *   r6: Start of command line string
-	 *   r7: End   of command line string
-	 */
-	(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
-	/* does not return */
+	{
+		/*
+		 * Linux Kernel Parameters (passing board info data):
+		 *   r3: ptr to board info data
+		 *   r4: initrd_start or 0 if no initrd
+		 *   r5: initrd_end - unused if r4 is 0
+		 *   r6: Start of command line string
+		 *   r7: End   of command line string
+		 */
+		debug ("   Booting using board info...\n");
+		(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
+		/* does not return */
+	}
 	return ;
 
 error:
@@ -353,6 +357,47 @@ static image_header_t *image_get_fdt (ulong fdt_addr)
 	return fdt_hdr;
 }
 
+/**
+ * fit_check_fdt - verify FIT format FDT subimage
+ * @fit_hdr: pointer to the FIT  header
+ * fdt_noffset: FDT subimage node offset within FIT image
+ * @verify: data CRC verification flag
+ *
+ * fit_check_fdt() verifies integrity of the FDT subimage and from
+ * specified FIT image.
+ *
+ * returns:
+ *     1, on success
+ *     0, on failure
+ */
+#if defined(CONFIG_FIT)
+static int fit_check_fdt (const void *fit, int fdt_noffset, int verify)
+{
+	fit_image_print (fit, fdt_noffset, "   ");
+
+	if (verify) {
+		puts ("   Verifying Hash Integrity ... ");
+		if (!fit_image_check_hashes (fit, fdt_noffset)) {
+			fdt_error ("Bad Data Hash");
+			return 0;
+		}
+		puts ("OK\n");
+	}
+
+	if (!fit_image_check_type (fit, fdt_noffset, IH_TYPE_FLATDT)) {
+		fdt_error ("Not a FDT image");
+		return 0;
+	}
+
+	if (!fit_image_check_comp (fit, fdt_noffset, IH_COMP_NONE)) {
+		fdt_error ("FDT image is compressed");
+		return 0;
+	}
+
+	return 1;
+}
+#endif /* CONFIG_FIT */
+
 static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
 {
@@ -366,8 +411,15 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
         const char      *fit_uname_config = NULL;
         const char      *fit_uname_fdt = NULL;
 	ulong		default_addr;
+	int		conf_noffset;
+	int		fdt_noffset;
+	const void	*data;
+	size_t		size;
 #endif
 
+	*of_flat_tree = NULL;
+	*of_size = 0;
+
 	if (argc > 3) {
 #if defined(CONFIG_FIT)
 		/*
@@ -398,7 +450,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 					fdt_addr);
 		}
 
-		debug ("## Checking for 'FDT'/'FDT image' at %08lx\n",
+		debug ("## Checking for 'FDT'/'FDT Image' at %08lx\n",
 				fdt_addr);
 
 		/* copy from dataflash if needed */
@@ -411,10 +463,8 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		 */
 		switch (genimg_get_format ((void *)fdt_addr)) {
 		case IMAGE_FORMAT_LEGACY:
-			debug ("*  fdt: legacy format image\n");
-
 			/* verify fdt_addr points to a valid image header */
-			printf ("## Flattened Device Tree Legacy Image at %08lx\n",
+			printf ("## Flattened Device Tree from Legacy Image at %08lx\n",
 					fdt_addr);
 			fdt_hdr = image_get_fdt (fdt_addr);
 			if (!fdt_hdr)
@@ -434,11 +484,15 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 				fdt_error ("fdt overwritten");
 				goto error;
 			}
-			memmove ((void *)image_get_load (fdt_hdr),
+
+			debug ("   Loading FDT from 0x%08lx to 0x%08lx\n",
+					image_get_data (fdt_hdr), load_start);
+
+			memmove ((void *)load_start,
 					(void *)image_get_data (fdt_hdr),
 					image_get_data_size (fdt_hdr));
 
-			fdt_blob = (char *)image_get_load (fdt_hdr);
+			fdt_blob = (char *)load_start;
 			break;
 		case IMAGE_FORMAT_FIT:
 			/*
@@ -448,14 +502,90 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 			 */
 #if defined(CONFIG_FIT)
 			/* check FDT blob vs FIT blob */
-			if (0) { /* FIXME: call FIT format verification */
+			if (fit_check_format ((const void *)fdt_addr)) {
 				/*
 				 * FIT image
 				 */
 				fit_hdr = (void *)fdt_addr;
-				debug ("*  fdt: FIT format image\n");
-				fit_unsupported_reset ("PPC fdt");
-				goto error;
+				printf ("## Flattened Device Tree from FIT Image at %08lx\n",
+						fdt_addr);
+
+				if (!fit_uname_fdt) {
+					/*
+					 * no FDT blob image node unit name,
+					 * try to get config node first. If
+					 * config unit node name is NULL
+					 * fit_conf_get_node() will try to
+					 * find default config node
+					 */
+					conf_noffset = fit_conf_get_node (fit_hdr,
+							fit_uname_config);
+					if (conf_noffset < 0)
+						goto error;
+
+					fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
+							conf_noffset);
+					fit_uname_fdt = fit_get_name (fit_hdr,
+							fdt_noffset, NULL);
+				} else {
+					/* get FDT component image node offset */
+					fdt_noffset = fit_image_get_node (fit_hdr,
+							fit_uname_fdt);
+				}
+				if (fdt_noffset < 0)
+					goto error;
+
+				printf ("   Trying '%s' FDT blob subimage\n",
+						fit_uname_fdt);
+
+				if (!fit_check_fdt (fit_hdr, fdt_noffset,
+							images->verify))
+					goto error;
+
+				/* get ramdisk image data address and length */
+				if (fit_image_get_data (fit_hdr, fdt_noffset,
+							&data, &size)) {
+					fdt_error ("Could not find FDT subimage data");
+					goto error;
+				}
+
+				/* verift that image data is a proper FDT blob */
+				if (fdt_check_header ((char *)data) != 0) {
+					fdt_error ("Subimage data is not a FTD");
+					goto error;
+				}
+
+				/*
+				 * move image data to the load address,
+				 * make sure we don't overwrite initial image
+				 */
+				image_start = (ulong)fit_hdr;
+				image_end = fit_get_end (fit_hdr);
+
+				if (fit_image_get_load (fit_hdr, fdt_noffset,
+							&load_start) == 0) {
+					load_end = load_start + size;
+
+					if ((load_start < image_end) &&
+							(load_end > image_start)) {
+						fdt_error ("FDT overwritten");
+						goto error;
+					}
+
+					printf ("   Loading FDT from 0x%08lx to 0x%08lx\n",
+							(ulong)data, load_start);
+
+					memmove ((void *)load_start,
+							(void *)data, size);
+
+					fdt_blob = (char *)load_start;
+				} else {
+					fdt_blob = (char *)data;
+				}
+
+				images->fit_hdr_fdt = fit_hdr;
+				images->fit_uname_fdt = fit_uname_fdt;
+				break;
 			} else
 #endif
 			{
@@ -509,8 +639,6 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		}
 	} else {
 		debug ("## No Flattened Device Tree\n");
-		*of_flat_tree = NULL;
-		*of_size = 0;
 		return 0;
 	}
 
#11 lore raw

PATCH 9/20 Add node offsets for FIT images listed in struct bootm_headers

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

This patch adds new node offset fields to struct bootm_headers and updates bootm_headers processing code to make use of them. Saved node offsets allow to avoid repeating fit_image_get_node() calls.

---

 common/cmd_bootm.c |   23 ++++++++---------------
 common/image.c     |    1 +
 include/image.h    |    7 +++++--
 lib_ppc/bootm.c    |    1 +
 4 files changed, 15 insertions(+), 17 deletions(-)
common/cmd_bootm.c +8 -15
index aca54b5..11c476e 100644
@@ -130,9 +130,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong		image_start, image_end;
 	ulong		load_start, load_end;
 	ulong		mem_start, mem_size;
-#if defined(CONFIG_FIT)
-	int		os_noffset;
-#endif
 
 	struct lmb lmb;
 
@@ -172,32 +169,27 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		os_noffset = fit_image_get_node (images.fit_hdr_os,
-				images.fit_uname_os);
-		if (os_noffset < 0) {
-			printf ("Can't get image node for '%s'!\n",
-					images.fit_uname_os);
-			return 1;
-		}
-
-		if (fit_image_get_type (images.fit_hdr_os, os_noffset, &type)) {
+		if (fit_image_get_type (images.fit_hdr_os,
+					images.fit_noffset_os, &type)) {
 			puts ("Can't get image type!\n");
 			return 1;
 		}
 
-		if (fit_image_get_comp (images.fit_hdr_os, os_noffset, &comp)) {
+		if (fit_image_get_comp (images.fit_hdr_os,
+					images.fit_noffset_os, &comp)) {
 			puts ("Can't get image compression!\n");
 			return 1;
 		}
 
-		if (fit_image_get_os (images.fit_hdr_os, os_noffset, &os)) {
+		if (fit_image_get_os (images.fit_hdr_os,
+					images.fit_noffset_os, &os)) {
 			puts ("Can't get image OS!\n");
 			return 1;
 		}
 
 		image_end = fit_get_end (images.fit_hdr_os);
 
-		if (fit_image_get_load (images.fit_hdr_os, os_noffset,
+		if (fit_image_get_load (images.fit_hdr_os, images.fit_noffset_os,
 					&load_start)) {
 			puts ("Can't get image load address!\n");
 			return 1;
@@ -569,6 +561,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 		*os_data = (ulong)data;
 		images->fit_hdr_os = fit_hdr;
 		images->fit_uname_os = fit_uname_kernel;
+		images->fit_noffset_os = os_noffset;
 		break;
 #endif
 	default:
common/image.c +1 -0
index 6458fb1..e838f65 100644
@@ -891,6 +891,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
 
 			images->fit_hdr_rd = fit_hdr;
 			images->fit_uname_rd = fit_uname_ramdisk;
+			images->fit_noffset_rd = rd_noffset;
 			break;
 #endif
 		default:
include/image.h +5 -2
index 6fca6f4..51c0c89 100644
@@ -208,13 +208,16 @@ typedef struct bootm_headers {
 #if defined(CONFIG_FIT)
 	void		*fit_hdr_os;	/* os FIT image header */
 	const char	*fit_uname_os;	/* os subimage node unit name */
+	int		fit_noffset_os;	/* os subimage node offset */
 
 	void		*fit_hdr_rd;	/* init ramdisk FIT image header */
-	const char	*fit_uname_rd;	/* init ramdisk node unit name */
+	const char	*fit_uname_rd;	/* init ramdisk subimage node unit name */
+	int		fit_noffset_rd;	/* init ramdisk subimage node offset */
 
 #if defined(CONFIG_PPC)
 	void		*fit_hdr_fdt;	/* FDT blob FIT image header */
-	const char	*fit_uname_fdt;	/* FDT blob node unit name */
+	const char	*fit_uname_fdt;	/* FDT blob subimage node unit name */
+	int		fit_noffset_fdt;/* FDT blob subimage node offset */
 #endif
 	int		verify;		/* getenv("verify")[0] != 'n' */
 	int		autostart;	/* getenv("autostart")[0] != 'n' */
lib_ppc/bootm.c +1 -0
index 60bc04b..4d8ef35 100644
@@ -585,6 +585,7 @@ static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 				images->fit_hdr_fdt = fit_hdr;
 				images->fit_uname_fdt = fit_uname_fdt;
+				images->fit_noffset_fdt = fdt_noffset;
 				break;
 			} else
 #endif
#12 lore raw

PATCH 10/20 Add new uImage format support to arch specific do_bootm_linux() routines

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

This patch updates architecture specific implementations of do_bootm_linux() adding new uImage format handling for operations like get kernel entry point address, get kernel image data start address.

---

 lib_arm/bootm.c        |   20 ++++++++++++++++----
 lib_avr32/bootm.c      |   20 ++++++++++++++++----
 lib_blackfin/bootm.c   |   17 ++++++++++++++---
 lib_i386/bootm.c       |   26 +++++++++++++++++++++-----
 lib_m68k/bootm.c       |   12 +++++++-----
 lib_microblaze/bootm.c |   17 ++++++++++++++---
 lib_mips/bootm.c       |   19 +++++++++++++++----
 lib_nios2/bootm.c      |   17 ++++++++++++++---
 lib_ppc/bootm.c        |    8 ++++++--
 lib_sh/bootm.c         |   17 ++++++++++++++---
 10 files changed, 137 insertions(+), 36 deletions(-)
lib_arm/bootm.c +16 -4
index 08eef0b..c5e8cb3 100644
@@ -70,6 +70,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	char	*s;
 	int	machid = bd->bi_arch_number;
 	void	(*theKernel)(int zero, int arch, uint params);
+	int	ret;
 
 #ifdef CONFIG_CMDLINE_TAG
 	char *commandline = getenv ("bootargs");
@@ -80,12 +81,16 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("ARM linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		ret = fit_image_get_entry (images->fit_hdr_os,
+					images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	theKernel = (void (*)(int, int, uint))ep;
 
@@ -98,7 +103,7 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM,
 			&initrd_start, &initrd_end);
 	if (ret)
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 
 	show_boot_progress (15);
 
@@ -151,6 +156,13 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	cleanup_before_linux ();
 
 	theKernel (0, machid, bd->bi_boot_params);
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
 
 
lib_avr32/bootm.c +16 -4
index c9a0190..b1c651a 100644
@@ -181,25 +181,30 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	void	(*theKernel)(int magic, void *tagtable);
 	struct	tag *params, *params_start;
 	char	*commandline = getenv("bootargs");
+	int	ret;
 
 	/* find kernel entry point */
 	if (images->legacy_hdr_valid) {
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("AVR32 linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	theKernel = (void *)ep;
 
 	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_AVR32,
 			&initrd_start, &initrd_end);
 	if (ret)
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 
 	show_boot_progress (15);
 
@@ -225,4 +230,11 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	prepare_to_boot();
 
 	theKernel(ATAG_MAGIC, params_start);
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
lib_blackfin/bootm.c +14 -3
index 33979a9..1ea80f4 100644
@@ -65,12 +65,16 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("AVR32 linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		int ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	appl = (int (*)(char *))ep;
 
@@ -85,6 +89,13 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 		dcache_disable();
 	}
 	(*appl) (cmdline);
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
 
 char *make_command_line(void)
lib_i386/bootm.c +21 -5
index b4a52fa..107ebaa 100644
@@ -40,11 +40,15 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	ulong		ep;
 	image_header_t	*hdr;
 	int		ret;
+#if defined(CONFIG_FIT)
+	const void	*data;
+	size_t		len;
+#endif
 
 	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_I386,
 			&initrd_start, &initrd_end);
 	if (ret)
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 
 	if (images->legacy_hdr_valid) {
 		hdr = images->legacy_hdr_os;
@@ -58,12 +62,18 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		}
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("I386 linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		ret = fit_image_get_data (images->fit_hdr_os,
+					images->fit_noffset_os, &data, &len);
+		if (ret) {
+			puts ("Can't get image data/size!\n");
+			goto error;
+		}
+		os_data = (ulong)data;
+		os_len = (ulong)len;
 #endif
 	} else {
 		puts ("Could not find kernel image!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 
 	base_ptr = load_zimage ((void*)os_data, os_len,
@@ -71,7 +81,7 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 
 	if (NULL == base_ptr) {
 		printf ("## Kernel loading failed ...\n");
-		do_reset(cmdtp, flag, argc, argv);
+		goto error;
 
 	}
 
@@ -87,5 +97,11 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	printf("\nStarting kernel ...\n\n");
 
 	boot_zimage(base_ptr);
+	/* does not return */
+	return;
 
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
lib_m68k/bootm.c +7 -5
index f185bea..6f49c31 100644
@@ -35,8 +35,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
 #define PHYSADDR(x) x
 
 #define LINUX_MAX_ENVS		256
@@ -101,12 +99,16 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("M68K linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
 
lib_microblaze/bootm.c +14 -3
index 99c4533..fab4a54 100644
@@ -47,12 +47,16 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("MICROBLAZE linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		int ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	theKernel = (void (*)(char *))ep;
 
@@ -67,4 +71,11 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 		return ;
 
 	theKernel (commandline);
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
lib_mips/bootm.c +15 -4
index 5e7a460..e4c139e 100644
@@ -60,19 +60,23 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("MIPS linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	theKernel = (void (*)(int, char **, char **, int *))ep;
 
 	ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_MIPS,
 			&initrd_start, &initrd_end);
 	if (ret)
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 
 	show_boot_progress (15);
 
@@ -116,6 +120,13 @@ void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
 	printf ("\nStarting kernel ...\n\n");
 
 	theKernel (linux_argc, linux_argv, linux_env, 0);
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
 
 static void linux_params_init (ulong start, char *line)
lib_nios2/bootm.c +14 -3
index 4b940cb..0c89e96 100644
@@ -37,12 +37,16 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("NIOS2 linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		int ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	void (*kernel)(void) = (void (*)(void))ep;
 
@@ -53,4 +57,11 @@ void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	 * needs to be called ;-)
 	 */
 	kernel ();
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
lib_ppc/bootm.c +6 -2
index 4d8ef35..86e104c 100644
@@ -150,8 +150,12 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("PPC linux bootm");
-		goto error;
+		ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
lib_sh/bootm.c +14 -3
index 8055841..49462c8 100644
@@ -70,12 +70,16 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 		ep = image_get_ep (images->legacy_hdr_os);
 #if defined(CONFIG_FIT)
 	} else if (images->fit_uname_os) {
-		fit_unsupported_reset ("SH linux bootm");
-		do_reset (cmdtp, flag, argc, argv);
+		int ret = fit_image_get_entry (images->fit_hdr_os,
+				images->fit_noffset_os, &ep);
+		if (ret) {
+			puts ("Can't get entry point property!\n");
+			goto error;
+		}
 #endif
 	} else {
 		puts ("Could not find kernel entry point!\n");
-		do_reset (cmdtp, flag, argc, argv);
+		goto error;
 	}
 	void (*kernel) (void) = (void (*)(void))ep;
 
@@ -87,4 +91,11 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
 	strcpy(COMMAND_LINE, bootargs);
 
 	kernel();
+	/* does not return */
+	return;
+
+error:
+	if (images->autostart)
+		do_reset (cmdtp, flag, argc, argv);
+	return;
 }
#13 lore raw

PATCH 11/20 Add new uImage format support to autoscript routine

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

autoscript() routine is updated to accept second argument, which is only used for FIT images and provides a FIT subimage unit name.

autoscript() routine callers must now pass two arguments. For non-interactive use (like in cmd_load.c, cmd_net.c), new environment variable 'autoscript_uname' is introduced and used as a FIT subimage unit name source.

autoscript command accepts extended syntax of the addr argument:
addr:<subimg_uname>

---

 board/pn62/cmd_pn62.c   |   11 +++++-
 common/cmd_autoscript.c |   84 +++++++++++++++++++++++++++++++++++++++--------
 common/cmd_load.c       |   11 +++++-
 common/cmd_net.c        |   11 +++++-
 include/common.h        |    2 +
 5 files changed, 97 insertions(+), 22 deletions(-)
board/pn62/cmd_pn62.c +9 -2
index ffa20cd..3f53e4b 100644
@@ -157,8 +157,15 @@ int do_loadpci (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	char *s;
 
 	if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
-	    printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
-	    rcode = autoscript (bd, load_addr);
+		printf ("Running autoscript at addr 0x%08lX", load_addr);
+
+		s = getenv ("autoscript_uname");
+		if (s)
+			printf (":%s ...\n", s);
+		else
+			puts (" ...\n");
+
+		rcode = autoscript (load_addr, s);
 	}
     }
 #endif
common/cmd_autoscript.c +69 -15

116 lines not on this page · raw message

common/cmd_load.c +9 -2
index 204c3eb..1b75a7b 100644
@@ -521,8 +521,15 @@ int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		char *s;
 
 		if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
-			printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
-			rcode = autoscript (load_addr);
+			printf ("Running autoscript at addr 0x%08lX", load_addr);
+
+			s = getenv ("autoscript_uname");
+			if (s)
+				printf (":%s ...\n", s);
+			else
+				puts (" ...\n");
+
+			rcode = autoscript (load_addr, s);
 		}
 	}
 #endif
common/cmd_net.c +9 -2
index dbf6b86..79e910c 100644
@@ -220,9 +220,16 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
 
 #ifdef CONFIG_AUTOSCRIPT
 	if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
-		printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
+		printf ("Running autoscript at addr 0x%08lX", load_addr);
+
+		s = getenv ("autoscript_uname");
+		if (s)
+			printf (":%s ...\n", s);
+		else
+			puts (" ...\n");
+
 		show_boot_progress (83);
-		rcode = autoscript (load_addr);
+		rcode = autoscript (load_addr, s);
 	}
 #endif
 	if (rcode < 0)
include/common.h +1 -1
index 3f05b5e..3351e2c 100644
@@ -222,7 +222,7 @@ int mac_read_from_eeprom(void);
 void flash_perror (int);
 
 /* common/cmd_autoscript.c */
-int	autoscript (ulong addr);
+int	autoscript (ulong addr, const char *fit_uname);
 
 extern ulong load_addr;		/* Default Load Address */
 
#14 lore raw

PATCH 12/20 Add new uImage format support to imgextract command

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

---

 common/cmd_ximg.c |  109 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 78 insertions(+), 31 deletions(-)
common/cmd_ximg.c +78 -31
index 360b05e..77f68c4 100644
@@ -37,12 +37,21 @@
 int
 do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
-	ulong addr = load_addr, dest = 0;
-	ulong data, len;
-	ulong *len_ptr;
-	int i, verify, part = 0;
-	char pbuf[10], *s;
-	image_header_t *hdr;
+	ulong		addr = load_addr;
+	ulong		dest = 0;
+	ulong		data, len, count;
+	int		i, verify;
+	int		part = 0;
+	char		pbuf[10];
+	char		*s;
+	image_header_t	*hdr;
+#if defined(CONFIG_FIT)
+	const char	*uname;
+	const void*	fit_hdr;
+	int		noffset;
+	const void	*fit_data;
+	size_t		fit_len;
+#endif
 
 	verify = getenv_verify ();
 
@@ -51,16 +60,20 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	}
 	if (argc > 2) {
 		part = simple_strtoul(argv[2], NULL, 16);
+#if defined(CONFIG_FIT)
+		uname = argv[2];
+#endif
 	}
 	if (argc > 3) {
 		dest = simple_strtoul(argv[3], NULL, 16);
 	}
 
-
 	switch (genimg_get_format ((void *)addr)) {
 	case IMAGE_FORMAT_LEGACY:
 
-		printf("## Copying from legacy image at %08lx ...\n", addr);
+		printf("## Copying part %d from legacy image "
+			"at %08lx ...\n", part, addr);
+
 		hdr = (image_header_t *)addr;
 		if (!image_check_magic (hdr)) {
 			printf("Bad Magic Number\n");
@@ -71,9 +84,9 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 			printf("Bad Header Checksum\n");
 			return 1;
 		}
-	#ifdef DEBUG
+#ifdef DEBUG
 		image_print_contents (hdr);
-	#endif
+#endif
 
 		if (!image_check_type (hdr, IH_TYPE_MULTI)) {
 			printf("Wrong Image Type for %s command\n",
@@ -96,31 +109,60 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 			printf("OK\n");
 		}
 
-		data = image_get_data (hdr);
-		len_ptr = (ulong *) data;
-
-		data += 4;		/* terminator */
-		for (i = 0; len_ptr[i]; ++i) {
-			data += 4;
-			if (argc > 2 && part > i) {
-				u_long tail;
-				len = uimage_to_cpu (len_ptr[i]);
-				tail = len % 4;
-				data += len;
-				if (tail) {
-					data += 4 - tail;
-				}
-			}
-		}
-		if (argc > 2 && part >= i) {
+		count = image_multi_count (hdr);
+		if (part >= count) {
 			printf("Bad Image Part\n");
 			return 1;
 		}
-		len = uimage_to_cpu (len_ptr[part]);
+
+		image_multi_getimg (hdr, part, &data, &len);
+		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("imxtract");
-		return 1;
+		if (uname == NULL) {
+			puts ("No FIT subimage unit name\n");
+			return 1;
+		}
+
+		printf("## Copying '%s' subimage from FIT image "
+			"at %08lx ...\n", uname, addr);
+
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("Bad FIT image format\n");
+			return 1;
+		}
+
+		/* get subimage node offset */
+		noffset = fit_image_get_node (fit_hdr, fit_uname);
+		if (noffset < 0) {
+			printf ("Can't find '%s' FIT subimage\n", uname);
+			return 1;
+		}
+
+		if (fit_image_check_comp (fit_hdr, noffset, IH_COMP_NONE)) {
+			printf("Wrong Compression Type for %s command\n",
+					cmdtp->name);
+			return 1;
+		}
+
+		/* verify integrity */
+		if (verify) {
+			if (!fit_image_check_hashes (fit_hdr, noffset)) {
+				puts ("Bad Data Hash\n");
+				return 1;
+			}
+		}
+
+		/* get subimage data address and length */
+		if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) {
+			puts ("Could not find script subimage data\n");
+			return 1;
+		}
+
+		data = (ulong *)fit_data;
+		len = (ulong)fit_len;
+		break;
 #endif
 	default:
 		puts ("Invalid image type for imxtract\n");
@@ -142,6 +184,11 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(imxtract, 4, 1, do_imgextract,
 	   "imxtract- extract a part of a multi-image\n",
 	   "addr part [dest]\n"
-	   "    - extract <part> from image at <addr> and copy to <dest>\n");
+	   "    - extract <part> from legacy image at <addr> and copy to <dest>\n"
+#if defined(CONFIG_FIT)
+	   "addr uname [dest]\n"
+	   "    - extract <uname> subimage from FIT image at <addr> and copy to <dest>\n"
+#endif
+);
 
 #endif
#15 lore raw

PATCH 13/20 Add new uImage format handling to other bootm related commands

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Updated commands:

docboot - cmd_doc.c
fdcboot - cmd_fdc.c
diskboot - cmd_ide.c
nboot - cmd_nand.c
scsiboot - cmd_scsi.c
usbboot - cmd_usb.c

---

 common/cmd_doc.c  |   34 ++++++++++++++++++----------
 common/cmd_fdc.c  |   27 ++++++++++++++++------
 common/cmd_ide.c  |   25 +++++++++++++++-----
 common/cmd_nand.c |   65 ++++++++++++++++++++++++++++++++++-------------------
 common/cmd_scsi.c |   26 +++++++++++++++------
 common/cmd_usb.c  |   27 +++++++++++++++-------
 6 files changed, 140 insertions(+), 64 deletions(-)
common/cmd_doc.c +22 -12
index 293b1aa..bf2f0a9 100644
@@ -205,6 +205,9 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	ulong offset = 0;
 	image_header_t *hdr;
 	int rcode = 0;
+#if defined(CONFIG_FIT)
+	const void *fit_hdr;
+#endif
 
 	show_boot_progress (34);
 	switch (argc) {
@@ -265,29 +268,30 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
 
-		if (image_check_magic (hdr)) {
+		image_print_contents (hdr);
 
-			image_print_contents (hdr);
-
-			cnt = image_get_image_size (hdr);
-			cnt -= SECTORSIZE;
-		} else {
-			puts ("\n** Bad Magic Number **\n");
-			show_boot_progress (-39);
-			return 1;
-		}
+		cnt = image_get_image_size (hdr);
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("docboot");
-		return 1;
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("** Bad FIT image format\n");
+			return 1;
+		}
+		puts ("Fit image detected...\n");
+
+		cnt = fit_get_size (fit_hdr);
+		break;
 #endif
 	default:
+		show_boot_progress (-39);
 		puts ("** Unknown image type\n");
 		return 1;
 	}
 	show_boot_progress (39);
 
+	cnt -= SECTORSIZE;
 	if (doc_rw (doc_dev_desc + dev, 1, offset + SECTORSIZE, cnt,
 		    NULL, (u_char *)(addr+SECTORSIZE))) {
 		printf ("** Read error on %d\n", dev);
@@ -296,6 +300,12 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 	show_boot_progress (40);
 
+#if defined(CONFIG_FIT)
+	/* This cannot be done earlier, we need complete FIT image in RAM first */
+	if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+		fit_print_contents ((const void *)addr);
+#endif
+
 	/* Loading ok, update default load address */
 
 	load_addr = addr;
common/cmd_fdc.c +20 -7
index 80301b9..bf28370 100644
@@ -788,6 +788,9 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	int i,nrofblk;
 	char *ep;
 	int rcode = 0;
+#if defined(CONFIG_FIT)
+	const void *fit_hdr;
+#endif
 
 	switch (argc) {
 	case 1:
@@ -839,18 +842,21 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	switch (genimg_get_format ((void *)addr)) {
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
-		if (!image_check_magic (hdr)) {
-			printf ("Bad Magic Number\n");
-			return 1;
-		}
 		image_print_contents (hdr);
 
 		imsize = image_get_image_size (hdr);
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("fdcboot");
-		return 1;
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("** Bad FIT image format\n");
+			return 1;
+		}
+		puts ("Fit image detected...\n");
+
+		imsize = fit_get_size (fit_hdr);
+		break;
 #endif
 	default:
 		puts ("** Unknown image type\n");
@@ -872,9 +878,16 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	printf("OK %ld Bytes loaded.\n",imsize);
 
 	flush_cache (addr, imsize);
-	/* Loading ok, update default load address */
 
+#if defined(CONFIG_FIT)
+	/* This cannot be done earlier, we need complete FIT image in RAM first */
+	if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+		fit_print_contents ((const void *)addr);
+#endif
+
+	/* Loading ok, update default load address */
 	load_addr = addr;
+
 	/* Check if we should attempt an auto-start */
 	if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
 		char *local_args[2];
common/cmd_ide.c +18 -7
index 79b7dfb..6a67dd6 100644
@@ -370,6 +370,9 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	disk_partition_t info;
 	image_header_t *hdr;
 	int rcode = 0;
+#if defined(CONFIG_FIT)
+	const void *fit_hdr;
+#endif
 
 	show_boot_progress (41);
 	switch (argc) {
@@ -450,11 +453,6 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
 
-		if (!image_check_magic (hdr)) {
-			printf("\n** Bad Magic Number **\n");
-			show_boot_progress (-49);
-			return 1;
-		}
 		show_boot_progress (49);
 
 		if (!image_check_hcrc (hdr)) {
@@ -470,10 +468,18 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("diskboot");
-		return 1;
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("** Bad FIT image format\n");
+			return 1;
+		}
+		puts ("Fit image detected...\n");
+
+		cnt = fit_get_size (fit_hdr);
+		break;
 #endif
 	default:
+		show_boot_progress (-49);
 		puts ("** Unknown image type\n");
 		return 1;
 	}
@@ -490,6 +496,11 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 	show_boot_progress (51);
 
+#if defined(CONFIG_FIT)
+	/* This cannot be done earlier, we need complete FIT image in RAM first */
+	if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+		fit_print_contents ((const void *)addr);
+#endif
 
 	/* Loading ok, update default load address */
 
common/cmd_nand.c +42 -23

116 lines not on this page · raw message

common/cmd_scsi.c +19 -7
index 7868805..f49531e 100644
@@ -211,6 +211,9 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	disk_partition_t info;
 	image_header_t *hdr;
 	int rcode = 0;
+#if defined(CONFIG_FIT)
+	const void *fit_hdr;
+#endif
 
 	switch (argc) {
 	case 1:
@@ -277,11 +280,6 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
 
-		if (!image_check_magic (hdr)) {
-			printf("\n** Bad Magic Number **\n");
-			return 1;
-		}
-
 		if (!image_check_hcrc (hdr)) {
 			puts ("\n** Bad Header Checksum **\n");
 			return 1;
@@ -292,8 +290,15 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("scsi");
-		return 1;
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("** Bad FIT image format\n");
+			return 1;
+		}
+		puts ("Fit image detected...\n");
+
+		cnt = fit_get_size (fit_hdr);
+		break;
 #endif
 	default:
 		puts ("** Unknown image type\n");
@@ -309,6 +314,13 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		printf ("** Read error on %d:%d\n", dev, part);
 		return 1;
 	}
+
+#if defined(CONFIG_FIT)
+	/* This cannot be done earlier, we need complete FIT image in RAM first */
+	if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+		fit_print_contents ((const void *)addr);
+#endif
+
 	/* Loading ok, update default load address */
 	load_addr = addr;
 
common/cmd_usb.c +19 -8
index 8ee7d27..bf56c6a 100644
@@ -315,7 +315,9 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	disk_partition_t info;
 	image_header_t *hdr;
 	block_dev_desc_t *stor_dev;
-
+#if defined(CONFIG_FIT)
+	const void *fit_hdr;
+#endif
 
 	switch (argc) {
 	case 1:
@@ -390,11 +392,6 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
 
-		if (!image_check_magic (hdr)) {
-			printf("\n** Bad Magic Number **\n");
-			return 1;
-		}
-
 		if (!image_check_hcrc (hdr)) {
 			puts ("\n** Bad Header Checksum **\n");
 			return 1;
@@ -406,8 +403,15 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
-		fit_unsupported ("usbboot");
-		return 1;
+		fit_hdr = (const void *)addr;
+		if (!fit_check_format (fit_hdr)) {
+			puts ("** Bad FIT image format\n");
+			return 1;
+		}
+		puts ("Fit image detected...\n");
+
+		cnt = fit_get_size (fit_hdr);
+		break;
 #endif
 	default:
 		puts ("** Unknown image type\n");
@@ -423,6 +427,13 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		printf ("\n** Read error on %d:%d\n", dev, part);
 		return 1;
 	}
+
+#if defined(CONFIG_FIT)
+	/* This cannot be done earlier, we need complete FIT image in RAM first */
+	if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
+		fit_print_contents ((const void *)addr);
+#endif
+
 	/* Loading ok, update default load address */
 	load_addr = addr;
 
#16 lore raw

PATCH 14/20 Add new uImage fromat support to fpga command

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

---

 common/cmd_fpga.c |   85 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 76 insertions(+), 9 deletions(-)
common/cmd_fpga.c +76 -9
index 0bb82f6..9141dcc 100644
@@ -164,6 +164,10 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	char *devstr = getenv ("fpga");
 	char *datastr = getenv ("fpgadata");
 	int rc = FPGA_FAIL;
+#if defined (CONFIG_FIT)
+	const char *fit_uname = NULL;
+	ulong fit_addr;
+#endif
 
 	if (devstr)
 		dev = (int) simple_strtoul (devstr, NULL, 16);
@@ -173,9 +177,22 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	switch (argc) {
 	case 5:		/* fpga <op> <dev> <data> <datasize> */
 		data_size = simple_strtoul (argv[4], NULL, 16);
+
 	case 4:		/* fpga <op> <dev> <data> */
-		fpga_data = (void *) simple_strtoul (argv[3], NULL, 16);
+#if defined(CONFIG_FIT)
+		if (fit_parse_subimage (argv[3], (ulong)fpga_data,
+					&fit_addr, &fit_uname)) {
+			fpga_data = (void *)fit_addr;
+			debug ("*  fpga: subimage '%s' from FIT image at 0x%08lx\n",
+					fit_uname, fit_addr);
+		} else
+#endif
+		{
+			fpga_data = (void *) simple_strtoul (argv[3], NULL, 16);
+			debug ("*  fpga: cmdline image address = 0x%08lx\n", (ulong)fpga_data);
+		}
 		PRINTF ("%s: fpga_data = 0x%x\n", __FUNCTION__, (uint) fpga_data);
+
 	case 3:		/* fpga <op> <dev | data addr> */
 		dev = (int) simple_strtoul (argv[2], NULL, 16);
 		PRINTF ("%s: device = %d\n", __FUNCTION__, dev);
@@ -183,14 +200,29 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		if ((argc == 3) && (dev > fpga_count ())) {	/* must be buffer ptr */
 			PRINTF ("%s: Assuming buffer pointer in arg 3\n",
 				__FUNCTION__);
-			fpga_data = (void *) dev;
+
+#if defined(CONFIG_FIT)
+			if (fit_parse_subimage (argv[2], (ulong)fpga_data,
+						&fit_addr, &fit_uname)) {
+				fpga_data = (void *)fit_addr;
+				debug ("*  fpga: subimage '%s' from FIT image at 0x%08lx\n",
+						fit_uname, fit_addr);
+			} else
+#endif
+			{
+				fpga_data = (void *) dev;
+				debug ("*  fpga: cmdline image address = 0x%08lx\n", (ulong)fpga_data);
+			}
+
 			PRINTF ("%s: fpga_data = 0x%x\n",
 				__FUNCTION__, (uint) fpga_data);
 			dev = FPGA_INVALID_DEVICE;	/* reset device num */
 		}
+
 	case 2:		/* fpga <op> */
 		op = (int) fpga_get_op (argv[1]);
 		break;
+
 	default:
 		PRINTF ("%s: Too many or too few args (%d)\n",
 			__FUNCTION__, argc);
@@ -222,10 +254,6 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 				image_header_t *hdr = (image_header_t *)fpga_data;
 				ulong	data;
 
-				if (!image_check_magic (hdr)) {
-					puts ("Bad Magic Number\n");
-					return 1;
-				}
 				data = (ulong)image_get_data (hdr);
 				data_size = image_get_data_size (hdr);
 				rc = fpga_load (dev, (void *)data, data_size);
@@ -233,8 +261,42 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 			break;
 #if defined(CONFIG_FIT)
 		case IMAGE_FORMAT_FIT:
-			fit_unsupported ("fpga");
-			rc = FPGA_FAIL;
+			{
+				const void *fit_hdr = (const void *)fpga_data;
+				int noffset;
+				void *fit_data;
+
+				if (fit_uname == NULL) {
+					puts ("No FIT subimage unit name\n");
+					return 1;
+				}
+
+				if (!fit_check_format (fit_hdr)) {
+					puts ("Bad FIT image format\n");
+					return 1;
+				}
+
+				/* get fpga component image node offset */
+				noffset = fit_image_get_node (fit_hdr, fit_uname);
+				if (noffset < 0) {
+					printf ("Can't find '%s' FIT subimage\n", fit_uname);
+					return 1;
+				}
+
+				/* verify integrity */
+				if (!fit_image_check_hashes (fit_hdr, noffset)) {
+					puts ("Bad Data Hash\n");
+					return 1;
+				}
+
+				/* get fpga subimage data address and length */
+				if (fit_image_get_data (fit_hdr, noffset, &fit_data, &data_size)) {
+					puts ("Could not find fpga subimage data\n");
+					return 1;
+				}
+
+				rc = fpga_load (dev, fit_data, data_size);
+			}
 			break;
 #endif
 		default:
@@ -295,4 +357,9 @@ U_BOOT_CMD (fpga, 6, 1, do_fpga,
 	    "\tload\tLoad device from memory buffer\n"
 	    "\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n"
 	    "\tloadmk\tLoad device generated with mkimage\n"
-	    "\tdump\tLoad device to memory buffer\n");
+	    "\tdump\tLoad device to memory buffer\n"
+#if defined(CONFIG_FIT)
+	    "\tFor loadmk operating on FIT format uImage address must include\n"
+	    "\tsubimage unit name in the form of addr:<subimg_uname>\n"
+#endif
+);
#17 lore raw

PATCH 15/20 Use show_boot_progress() for new uImage format

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

This patch allocates a set of show_boot_progress() IDs for new uImage format and adds show_boot_progress() calls in new uImage format handling code.

---

 README             |   83 +++++++++++++++++++++++++++++++++++++++++++---------
 common/cmd_bootm.c |   30 ++++++++++++++++---
 common/cmd_doc.c   |    2 +
 common/cmd_ide.c   |    2 +
 common/cmd_nand.c  |    4 +++
 common/image.c     |   28 ++++++++++++++----
 6 files changed, 125 insertions(+), 24 deletions(-)
README +69 -14
index 491397a..183246e 100644
@@ -1659,6 +1659,8 @@ The following options need to be configured:
 		example, some LED's) on your board. At the moment,
 		the following checkpoints are implemented:
 
+Legacy uImage format:
+
   Arg	Where			When
     1	common/cmd_bootm.c	before attempting to boot an image
    -1	common/cmd_bootm.c	Image header has bad	 magic number
@@ -1669,25 +1671,26 @@ The following options need to be configured:
     4	common/cmd_bootm.c	Image data   has correct checksum
    -4	common/cmd_bootm.c	Image is for unsupported architecture
     5	common/cmd_bootm.c	Architecture check OK
-   -5	common/cmd_bootm.c	Wrong Image Type (not kernel, multi, standalone)
+   -5	common/cmd_bootm.c	Wrong Image Type (not kernel, multi)
     6	common/cmd_bootm.c	Image Type check OK
    -6	common/cmd_bootm.c	gunzip uncompression error
    -7	common/cmd_bootm.c	Unimplemented compression type
     7	common/cmd_bootm.c	Uncompression OK
-   -8	common/cmd_bootm.c	Wrong Image Type (not kernel, multi, standalone)
-    8	common/cmd_bootm.c	Image Type check OK
+    8	common/cmd_bootm.c	No uncompress/copy overwrite error
    -9	common/cmd_bootm.c	Unsupported OS (not Linux, BSD, VxWorks, QNX)
-    9	common/cmd_bootm.c	Start initial ramdisk verification
-  -10	common/cmd_bootm.c	Ramdisk header has bad	   magic number
-  -11	common/cmd_bootm.c	Ramdisk header has bad	   checksum
-   10	common/cmd_bootm.c	Ramdisk header is OK
-  -12	common/cmd_bootm.c	Ramdisk data   has bad	   checksum
-   11	common/cmd_bootm.c	Ramdisk data   has correct checksum
-   12	common/cmd_bootm.c	Ramdisk verification complete, start loading
-  -13	common/cmd_bootm.c	Wrong Image Type (not PPC Linux Ramdisk)
-   13	common/cmd_bootm.c	Start multifile image verification
-   14	common/cmd_bootm.c	No initial ramdisk, no multifile, continue.
-   15	common/cmd_bootm.c	All preparation done, transferring control to OS
+
+    9	common/image.c		Start initial ramdisk verification
+  -10	common/image.c		Ramdisk header has bad	   magic number
+  -11	common/image.c		Ramdisk header has bad	   checksum
+   10	common/image.c		Ramdisk header is OK
+  -12	common/image.c		Ramdisk data   has bad	   checksum
+   11	common/image.c		Ramdisk data   has correct checksum
+   12	common/image.c		Ramdisk verification complete, start loading
+  -13	common/image.c		Wrong Image Type (not PPC Linux Ramdisk)
+   13	common/image.c		Start multifile image verification
+   14	common/image.c		No initial ramdisk, no multifile, continue.
+
+   15	lib_<arch>/bootm.c	All preparation done, transferring control to OS
 
   -30	lib_ppc/board.c		Fatal error, hang the system
   -31	post/post.c		POST test failed, detected by post_output_backlog()
@@ -1757,6 +1760,58 @@ The following options need to be configured:
   -83	common/cmd_net.c	some error in automatic boot or autoscript
    84	common/cmd_net.c	end without errors
 
+FIT uImage format:
+
+  Arg	Where			When
+  100	common/cmd_bootm.c	Kernel FIT Image has correct format
+ -100	common/cmd_bootm.c	Kernel FIT Image has incorrect format
+  101	common/cmd_bootm.c	No Kernel subimage unit name, using configuration
+ -101	common/cmd_bootm.c	Can't get configuration for kernel subimage
+  102	common/cmd_bootm.c	Kernel unit name specified
+ -103	common/cmd_bootm.c	Can't get kernel subimage node offset
+  104	common/cmd_bootm.c	Got kernel subimage node offset
+ -104	common/cmd_bootm.c	Kernel subimage hash verification failed
+  105	common/cmd_bootm.c	Kernel subimage hash verification OK
+ -105	common/cmd_bootm.c	Kernel subimage is for unsupported architecture
+  106	common/cmd_bootm.c	Architecture check OK
+ -106	common/cmd_bootm.c	Kernel subimage has wrong typea
+  107	common/cmd_bootm.c	Kernel subimge type OK
+ -107	common/cmd_bootm.c	Can't get kernel subimage data/size
+  108	common/cmd_bootm.c	Got kernel subimage data/size
+ -108	common/cmd_bootm.c	Wrong image type (not legacy, FIT)
+ -109	common/cmd_bootm.c	Can't get kernel subimage type
+ -110	common/cmd_bootm.c	Can't get kernel subimage comp
+ -111	common/cmd_bootm.c	Can't get kernel subimage os
+ -112	common/cmd_bootm.c	Can't get kernel subimage load address
+ -113	common/cmd_bootm.c	Image uncompress/copy overwrite error
+
+  120	common/image.c		Start initial ramdisk verification
+ -120	common/image.c		Ramdisk FIT image has incorrect format
+  121	common/image.c		Ramdisk FIT image has correct format
+  122	common/image.c		No Ramdisk subimage unit name, using configuration
+ -122	common/image.c		Can't get configuration for ramdisk subimage
+  123	common/image.c		Ramdisk unit name specified
+ -124	common/image.c		Can't get ramdisk subimage node offset
+  125	common/image.c		Got ramdisk subimage node offset
+ -125	common/image.c		Ramdisk subimage hash verification failed
+  126	common/image.c		Ramdisk subimage hash verification OK
+ -126	common/image.c		Ramdisk subimage for unsupported architecture
+  127	common/image.c		Architecture check OK
+ -127	common/image.c		Can't get ramdisk subimage data/size
+  128	common/image.c		Got ramdisk subimage data/size
+  129	common/image.c		Can't get ramdisk load address
+ -129	common/image.c		Got ramdisk load address
+
+ -130	common/cmd_doc.c	Icorrect FIT image format
+  131	common/cmd_doc.c	FIT image format OK
+
+ -140	common/cmd_ide.c	Icorrect FIT image format
+  141	common/cmd_ide.c	FIT image format OK
+
+ -150	common/cmd_nand.c	Icorrect FIT image format
+  151	common/cmd_nand.c	FIT image format OK
+
+
 Modem Support:
 --------------
 
common/cmd_bootm.c +26 -4
index 11c476e..6591e61 100644
@@ -155,8 +155,6 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	show_boot_progress (6);
-
 	/* get image parameters */
 	switch (genimg_get_format (os_hdr)) {
 	case IMAGE_FORMAT_LEGACY:
@@ -172,18 +170,21 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		if (fit_image_get_type (images.fit_hdr_os,
 					images.fit_noffset_os, &type)) {
 			puts ("Can't get image type!\n");
+			show_boot_progress (-109);
 			return 1;
 		}
 
 		if (fit_image_get_comp (images.fit_hdr_os,
 					images.fit_noffset_os, &comp)) {
 			puts ("Can't get image compression!\n");
+			show_boot_progress (-110);
 			return 1;
 		}
 
 		if (fit_image_get_os (images.fit_hdr_os,
 					images.fit_noffset_os, &os)) {
 			puts ("Can't get image OS!\n");
+			show_boot_progress (-111);
 			return 1;
 		}
 
@@ -192,6 +193,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		if (fit_image_get_load (images.fit_hdr_os, images.fit_noffset_os,
 					&load_start)) {
 			puts ("Can't get image load address!\n");
+			show_boot_progress (-112);
 			return 1;
 		}
 		break;
@@ -284,6 +286,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		debug ("load_start = 0x%lx, load_end = 0x%lx\n", load_start, load_end);
 
 		puts ("ERROR: image overwritten - must RESET the board to recover.\n");
+		show_boot_progress (-113);
 		do_reset (cmdtp, flag, argc, argv);
 	}
 
@@ -416,21 +419,27 @@ static int fit_check_kernel (const void *fit, int os_noffset, int verify)
 		puts ("   Verifying Hash Integrity ... ");
 		if (!fit_image_check_hashes (fit, os_noffset)) {
 			puts ("Bad Data Hash\n");
+			show_boot_progress (-104);
 			return 0;
 		}
 		puts ("OK\n");
 	}
+	show_boot_progress (105);
 
 	if (!fit_image_check_target_arch (fit, os_noffset)) {
 		puts ("Unsupported Architecture\n");
+		show_boot_progress (-105);
 		return 0;
 	}
 
+	show_boot_progress (106);
 	if (!fit_image_check_type (fit, os_noffset, IH_TYPE_KERNEL)) {
 		puts ("Not a kernel image\n");
+		show_boot_progress (-106);
 		return 0;
 	}
 
+	show_boot_progress (107);
 	return 1;
 }
 #endif /* CONFIG_FIT */
@@ -515,6 +524,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 		images->legacy_hdr_os = hdr;
 		images->legacy_hdr_valid = 1;
 
+		show_boot_progress (6);
 		break;
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
@@ -524,8 +534,10 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 
 		if (!fit_check_format (fit_hdr)) {
 			puts ("Bad FIT kernel image format!\n");
+			show_boot_progress (-100);
 			return NULL;
 		}
+		show_boot_progress (100);
 
 		if (!fit_uname_kernel) {
 			/*
@@ -533,29 +545,38 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 			 * node first. If config unit node name is NULL
 			 * fit_conf_get_node() will try to find default config node
 			 */
+			show_boot_progress (101);
 			conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
-			if (conf_noffset < 0)
+			if (conf_noffset < 0) {
+				show_boot_progress (-101);
 				return NULL;
+			}
 
 			os_noffset = fit_conf_get_kernel_node (fit_hdr, conf_noffset);
 			fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL);
 		} else {
 			/* get kernel component image node offset */
+			show_boot_progress (102);
 			os_noffset = fit_image_get_node (fit_hdr, fit_uname_kernel);
 		}
-		if (os_noffset < 0)
+		if (os_noffset < 0) {
+			show_boot_progress (-103);
 			return NULL;
+		}
 
 		printf ("   Trying '%s' kernel subimage\n", fit_uname_kernel);
 
+		show_boot_progress (104);
 		if (!fit_check_kernel (fit_hdr, os_noffset, images->verify))
 			return NULL;
 
 		/* get kernel image data address and length */
 		if (fit_image_get_data (fit_hdr, os_noffset, &data, &len)) {
 			puts ("Could not find kernel subimage data!\n");
+			show_boot_progress (-107);
 			return NULL;
 		}
+		show_boot_progress (108);
 
 		*os_len = len;
 		*os_data = (ulong)data;
@@ -566,6 +587,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 #endif
 	default:
 		printf ("Wrong Image Format for %s command\n", cmdtp->name);
+		show_boot_progress (-108);
 		return NULL;
 	}
 
common/cmd_doc.c +2 -0
index bf2f0a9..83aba37 100644
@@ -276,9 +276,11 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *)addr;
 		if (!fit_check_format (fit_hdr)) {
+			show_boot_progress (-130);
 			puts ("** Bad FIT image format\n");
 			return 1;
 		}
+		show_boot_progress (131);
 		puts ("Fit image detected...\n");
 
 		cnt = fit_get_size (fit_hdr);
common/cmd_ide.c +2 -0
index 6a67dd6..8ace970 100644
@@ -470,9 +470,11 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *)addr;
 		if (!fit_check_format (fit_hdr)) {
+			show_boot_progress (-140);
 			puts ("** Bad FIT image format\n");
 			return 1;
 		}
+		show_boot_progress (141);
 		puts ("Fit image detected...\n");
 
 		cnt = fit_get_size (fit_hdr);
common/cmd_nand.c +4 -0
index 9a168ea..7b1f830 100644
@@ -528,9 +528,11 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *)addr;
 		if (!fit_check_format (fit_hdr)) {
+			show_boot_progress (-150);
 			puts ("** Bad FIT image format\n");
 			return 1;
 		}
+		show_boot_progress (151);
 		puts ("Fit image detected...\n");
 
 		cnt = fit_get_size (fit_hdr);
@@ -1020,9 +1022,11 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *)addr;
 		if (!fit_check_format (fit_hdr)) {
+			show_boot_progress (-150);
 			puts ("** Bad FIT image format\n");
 			return 1;
 		}
+		show_boot_progress (151);
 		puts ("Fit image detected...\n");
 
 		cnt = fit_get_size (fit_hdr);
common/image.c +22 -6
index e838f65..f29614b 100644
@@ -397,10 +397,7 @@ inline void image_print_contents_noindent (image_header_t *hdr)
 static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
 						int verify)
 {
-	image_header_t *rd_hdr;
-
-	show_boot_progress (9);
-	rd_hdr = (image_header_t *)rd_addr;
+	image_header_t *rd_hdr = (image_header_t *)rd_addr;
 
 	if (!image_check_magic (rd_hdr)) {
 		puts ("Bad Magic Number\n");
@@ -830,6 +827,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
 			printf ("## Loading init Ramdisk from Legacy "
 					"Image at %08lx ...\n", rd_addr);
 
+			show_boot_progress (9);
 			rd_hdr = image_get_ramdisk (rd_addr, arch,
 							images->verify);
 
@@ -846,10 +844,13 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
 			printf ("## Loading init Ramdisk from FIT "
 					"Image at %08lx ...\n", rd_addr);
 
+			show_boot_progress (120);
 			if (!fit_check_format (fit_hdr)) {
 				puts ("Bad FIT ramdisk image format!\n");
+				show_boot_progress (-120);
 				return 0;
 			}
+			show_boot_progress (121);
 
 			if (!fit_uname_ramdisk) {
 				/*
@@ -857,37 +858,48 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
 				 * node first. If config unit node name is NULL
 				 * fit_conf_get_node() will try to find default config node
 				 */
+				show_boot_progress (122);
 				conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
-				if (conf_noffset < 0)
+				if (conf_noffset < 0) {
+					show_boot_progress (-122);
 					return 0;
+				}
 
 				rd_noffset = fit_conf_get_ramdisk_node (fit_hdr, conf_noffset);
 				fit_uname_ramdisk = fit_get_name (fit_hdr, rd_noffset, NULL);
 			} else {
 				/* get ramdisk component image node offset */
+				show_boot_progress (123);
 				rd_noffset = fit_image_get_node (fit_hdr, fit_uname_ramdisk);
 			}
-			if (rd_noffset < 0)
+			if (rd_noffset < 0) {
+				show_boot_progress (-124);
 				return 0;
+			}
 
 			printf ("   Trying '%s' ramdisk subimage\n", fit_uname_ramdisk);
 
+			show_boot_progress (125);
 			if (!fit_check_ramdisk (fit_hdr, rd_noffset, arch, images->verify))
 				return 0;
 
 			/* get ramdisk image data address and length */
 			if (fit_image_get_data (fit_hdr, rd_noffset, &data, &size)) {
 				puts ("Could not find ramdisk subimage data!\n");
+				show_boot_progress (-127);
 				return 0;
 			}
+			show_boot_progress (128);
 
 			rd_data = (ulong)data;
 			rd_len = size;
 
 			if (fit_image_get_load (fit_hdr, rd_noffset, &rd_load)) {
 				puts ("Can't get ramdisk subimage load address!\n");
+				show_boot_progress (-129);
 				return 0;
 			}
+			show_boot_progress (129);
 
 			images->fit_hdr_rd = fit_hdr;
 			images->fit_uname_rd = fit_uname_ramdisk;
@@ -2445,19 +2457,23 @@ static int fit_check_ramdisk (const void *fit, int rd_noffset, uint8_t arch, int
 		puts ("   Verifying Hash Integrity ... ");
 		if (!fit_image_check_hashes (fit, rd_noffset)) {
 			puts ("Bad Data Hash\n");
+			show_boot_progress (-125);
 			return 0;
 		}
 		puts ("OK\n");
 	}
 
+	show_boot_progress (126);
 	if (!fit_image_check_os (fit, rd_noffset, IH_OS_LINUX) ||
 	    !fit_image_check_arch (fit, rd_noffset, arch) ||
 	    !fit_image_check_type (fit, rd_noffset, IH_TYPE_RAMDISK)) {
 		printf ("No Linux %s Ramdisk Image\n",
 				genimg_get_arch_name(arch));
+		show_boot_progress (-126);
 		return 0;
 	}
 
+	show_boot_progress (127);
 	return 1;
 }
 #endif /* USE_HOSTCC */
#18 lore raw

PATCH 16/20 More verbose kernel image uncompress error message

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

---

 common/cmd_bootm.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
common/cmd_bootm.c +4 -2
index 6591e61..e95c5dd 100644
@@ -243,7 +243,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		printf ("   Uncompressing %s ... ", type_name);
 		if (gunzip ((void *)load_start, unc_len,
 					(uchar *)os_data, &os_len) != 0) {
-			puts ("GUNZIP ERROR - must RESET board to recover\n");
+			puts ("GUNZIP: uncompress or overwrite error "
+				"- must RESET board to recover\n");
 			show_boot_progress (-6);
 			do_reset (cmdtp, flag, argc, argv);
 		}
@@ -262,7 +263,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 					&unc_len, (char *)os_data, os_len,
 					CFG_MALLOC_LEN < (4096 * 1024), 0);
 		if (i != BZ_OK) {
-			printf ("BUNZIP2 ERROR %d - must RESET board to recover\n", i);
+			printf ("BUNZIP2: uncompress or overwrite error %d "
+				"- must RESET board to recover\n", i);
 			show_boot_progress (-6);
 			do_reset (cmdtp, flag, argc, argv);
 		}
#19 lore raw

PATCH 17/20 Add proper ramdisk/FDT handling when FIT configuration is used

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Save FIT configuration provied in the first bootm argument and use it when to get ramdisk/FDT subimages when second and third (ramdisk/FDT) arguments are not specified.

---

 README             |    1 
 common/cmd_bootm.c |   14 +++++--
 common/image.c     |  112 +++++++++++++++++++++++++++++++++++++++-------------
 include/image.h    |    3 +
 lib_ppc/bootm.c    |  104 ++++++++++++++++++++++++++++++++++--------------
 5 files changed, 170 insertions(+), 64 deletions(-)
README +1 -0
index 183246e..0ed47f0 100644
@@ -1769,6 +1769,7 @@ FIT uImage format:
  -101	common/cmd_bootm.c	Can't get configuration for kernel subimage
   102	common/cmd_bootm.c	Kernel unit name specified
  -103	common/cmd_bootm.c	Can't get kernel subimage node offset
+  103	common/cmd_bootm.c	Found configuration node
   104	common/cmd_bootm.c	Got kernel subimage node offset
  -104	common/cmd_bootm.c	Kernel subimage hash verification failed
   105	common/cmd_bootm.c	Kernel subimage hash verification OK
common/cmd_bootm.c +10 -4
index e95c5dd..2f232e7 100644
@@ -469,7 +469,7 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 	const char	*fit_uname_kernel = NULL;
 	const void	*data;
 	size_t		len;
-	int		conf_noffset;
+	int		cfg_noffset;
 	int		os_noffset;
 #endif
 
@@ -548,13 +548,19 @@ static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]
 			 * fit_conf_get_node() will try to find default config node
 			 */
 			show_boot_progress (101);
-			conf_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
-			if (conf_noffset < 0) {
+			cfg_noffset = fit_conf_get_node (fit_hdr, fit_uname_config);
+			if (cfg_noffset < 0) {
 				show_boot_progress (-101);
 				return NULL;
 			}
+			/* save configuration uname provided in the first
+			 * bootm argument
+			 */
+			images->fit_uname_cfg = fdt_get_name (fit_hdr, cfg_noffset, NULL);
+			printf ("   Using '%s' configuration\n", images->fit_uname_cfg);
+			show_boot_progress (103);
 
-			os_noffset = fit_conf_get_kernel_node (fit_hdr, conf_noffset);
+			os_noffset = fit_conf_get_kernel_node (fit_hdr, cfg_noffset);
 			fit_uname_kernel = fit_get_name (fit_hdr, os_noffset, NULL);
 		} else {
 			/* get kernel component image node offset */
common/image.c +83 -29

155 lines not on this page · raw message

include/image.h +3 -0
index 51c0c89..0109560 100644
@@ -206,6 +206,8 @@ typedef struct bootm_headers {
 	ulong		legacy_hdr_valid;
 
 #if defined(CONFIG_FIT)
+	const char	*fit_uname_cfg;	/* configuration node unit name */
+
 	void		*fit_hdr_os;	/* os FIT image header */
 	const char	*fit_uname_os;	/* os subimage node unit name */
 	int		fit_noffset_os;	/* os subimage node offset */
@@ -251,6 +253,7 @@ int genimg_get_comp_id (const char *name);
 #define IMAGE_FORMAT_FIT	0x02	/* new, libfdt based format */
 
 int genimg_get_format (void *img_addr);
+int genimg_has_config (bootm_headers_t *images);
 ulong genimg_get_image (ulong img_addr);
 
 int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
lib_ppc/bootm.c +73 -31

136 lines not on this page · raw message

#20 lore raw

PATCH 18/20 Fix build problems on trab board

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

---

 board/trab/auto_update.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
board/trab/auto_update.c +2 -2
index fa08bff..5311e12 100644
@@ -224,7 +224,7 @@ au_check_cksum_valid(int idx, long nbytes)
 		return -1;
 	}
 	/* check the data CRC */
-	if (!image_check_dcrc (hdr)) {
+	if (!image_check_dcrc (hdr))
 	{
 		printf ("Image %s bad data checksum\n", aufile[idx]);
 		return -1;
@@ -284,7 +284,7 @@ au_check_header_valid(int idx, long nbytes)
 		return -1;
 	}
 	if ((idx == IDX_APP) && !image_check_type (hdr, IH_TYPE_RAMDISK)
-	    && !image_check_type (hdr, FILESYSTEM)) {
+		&& !image_check_type (hdr, IH_TYPE_FILESYSTEM)) {
 		printf ("Image %s wrong type\n", aufile[idx]);
 		return -1;
 	}
#21 lore raw

PATCH 18/20 Fix build problems on trab board

board/trab/auto_update.c au_check_cksum_valid(int idx, long nbytes) · line 228

Quoted 12 lines · In message <[email protected]> you wrote:
board/trab/auto_update.c +1 -1
index fa08bff..5311e12 100644
@@ -224,7 +224,7 @@ au_check_cksum_valid(int idx, long nbytes)
 		return -1;
 	}
 	/* check the data CRC */
-	if (!image_check_dcrc (hdr)) {
+	if (!image_check_dcrc (hdr))
 	{

This patch looks broken to me. You should keep the brace on the same line with the if, and rather delete the next line with the single brace.

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
Too many people are ready to carry the stool when the piano needs  to
be moved.
#22 lore raw

PATCH 18/20 Fix build problems on trab board

Quoted 16 lines · Wolfgang Denk

board/trab/auto_update.c au_check_cksum_valid(int idx, long nbytes) · line 228

Quoted 11 lines · In message <[email protected]> you wrote:
board/trab/auto_update.c +1 -1
index fa08bff..5311e12 100644
@@ -224,7 +224,7 @@ au_check_cksum_valid(int idx, long nbytes)
 		return -1;
 	}
 	/* check the data CRC */
-	if (!image_check_dcrc (hdr)) {
+	if (!image_check_dcrc (hdr))
 	{

This patch looks broken to me. You should keep the brace on the same line with the if, and rather delete the next line with the single brace.

Will fix.

Regards,
Bartlomiej

#23 lore raw

PATCH 19/20 Fix definition of common bootm_headers_t fields

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

verify, autostart and lmb fields are used regardless of CONFIG_FIT setting, move their definitions to common section.

---

 include/image.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/image.h +2 -1
index 0109560..fbd8c30 100644
@@ -221,10 +221,11 @@ typedef struct bootm_headers {
 	const char	*fit_uname_fdt;	/* FDT blob subimage node unit name */
 	int		fit_noffset_fdt;/* FDT blob subimage node offset */
 #endif
+#endif
+
 	int		verify;		/* getenv("verify")[0] != 'n' */
 	int		autostart;	/* getenv("autostart")[0] != 'n' */
 	struct lmb	*lmb;		/* for memory mgmt */
-#endif
 } bootm_headers_t;
 
 /*
#24 lore raw

PATCH 20/20 Add new uImage format documentation and examples

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Create doc/uImage.FIT documentation directory with the following files:
- command_syntax_extensions.txt : extended command syntax description
- howto.txt : short usage howto
- source_file_format.txt : internal new uImage format description

Add example image source files:
- kernel.its
- kernel_fdt.its
- multi.its

Update README appropriately.

---

 README                                       |   30 ++-
 doc/uImage.FIT/command_syntax_extensions.txt |  191 +++++++++++++++++
 doc/uImage.FIT/howto.txt                     |  296 ++++++++++++++++++++++++++
 doc/uImage.FIT/kernel.its                    |   34 +++
 doc/uImage.FIT/kernel_fdt.its                |   48 ++++
 doc/uImage.FIT/multi.its                     |  124 +++++++++++
 doc/uImage.FIT/source_file_format.txt        |  262 +++++++++++++++++++++++
 7 files changed, 981 insertions(+), 4 deletions(-)
 create mode 100644 doc/uImage.FIT/command_syntax_extensions.txt
 create mode 100644 doc/uImage.FIT/howto.txt
 create mode 100644 doc/uImage.FIT/kernel.its
 create mode 100644 doc/uImage.FIT/kernel_fdt.its
 create mode 100644 doc/uImage.FIT/multi.its
 create mode 100644 doc/uImage.FIT/source_file_format.txt
README +26 -4
index 0ed47f0..26bd0cf 100644
@@ -2684,6 +2684,14 @@ Some configuration options can be set using Environment Variables:
 		  configuration from the BOOTP server, but not try to
 		  load any image using TFTP
 
+  autoscript	- if set to "yes" commands like "loadb", "loady",
+		  "bootp", "tftpb", "rarpboot" and "nfs" will attempt
+		  to automatically run script images (by internally
+		  calling "autoscript").
+
+  autoscript_uname - if script image is in a format (FIT) this
+		     variable is used to get script subimage unit name.
+
   autostart	- if set to "yes", an image loaded using the "bootp",
 		  "rarpboot", "tftpboot" or "diskboot" commands will
 		  be automatically started (by internally calling
@@ -2898,10 +2906,24 @@ o If neither SROM nor the environment contain a MAC address, an error
 Image Formats:
 ==============
 
-The "boot" commands of this monitor operate on "image" files which
-can be basicly anything, preceeded by a special header; see the
-definitions in include/image.h for details; basicly, the header
-defines the following image properties:
+U-Boot is capable of booting (and performing other auxiliary operations on)
+images in two formats:
+
+New uImage format (FIT)
+-----------------------
+
+Flexible and powerful format based on Flattened Image Tree -- FIT (similar
+to Flattened Device Tree). It allows the use of images with multiple
+components (several kernels, ramdisks, etc.), with contents protected by
+SHA1, MD5 or CRC32. More details are found in the doc/uImage.FIT directory.
+
+
+Old uImage format
+-----------------
+
+Old image format is based on binary files which can be basically anything,
+preceded by a special header; see the definitions in include/image.h for
+details; basically, the header defines the following image properties:
 
 * Target Operating System (Provisions for OpenBSD, NetBSD, FreeBSD,
   4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks,
doc/uImage.FIT/command_syntax_extensions.txt new file +191 -0

191 lines not on this page · raw message

doc/uImage.FIT/howto.txt new file +296 -0

296 lines not on this page · raw message

doc/uImage.FIT/kernel.its new file +34 -0
new file mode 100644
index 0000000..d1a5939
@@ -0,0 +1,34 @@
+/*
+ * Simple U-boot uImage source file containing a single kernel
+ */
+/ {
+	description = "Simple image with single Linux kernel";
+	#address-cells = <1>;
+
+	images {
+		kernel at 1 {
+			description = "Vanilla Linux kernel";
+			data = /incbin/("./vmlinux.bin.gz");
+			type = "kernel";
+			arch = "ppc";
+			os = "linux";
+			compression = "gzip";
+			load = <00000000>;
+			entry = <00000000>;
+			hash at 1 {
+				algo = "crc32";
+			};
+			hash at 2 {
+				algo = "sha1";
+			};
+		};
+	};
+
+	configurations {
+		default = "config at 1";
+		config at 1 {
+			description = "Boot Linux kernel";
+			kernel = "kernel at 1";
+		};
+	};
+};
doc/uImage.FIT/kernel_fdt.its new file +48 -0

48 lines not on this page · raw message

doc/uImage.FIT/multi.its new file +124 -0

124 lines not on this page · raw message

doc/uImage.FIT/source_file_format.txt new file +262 -0

262 lines not on this page · raw message