Skip to contentSkip to conversation

patchset4 - assorted patches

PATCH RESEND New Bartlomiej Sieka 2 participants 8 messages Feb 21, 2008 – Feb 22, 2008

lore
Share & tools
lore
#0 lore raw

cover patchset4 - assorted patches

Addressed comments posted to the first version, dropped patch fixing fdt_support.c compilation with DEBUG enabled.

Patches apply on top of new-image branch of the u-boot-testing, with recent master pulled. Original description:

This patchset encompasses some clean-ups and fixes, and adds the new uImage #define knob (CONFIG_FIT), which is enabled by default. The patchset also adds some new uImage-specific functionality: (1) a routine to parse new-style arguments to bootm (and other commands), (2) a generic function for retrieving images. It lays foundation for the soon-to-follow:
- low-level new uImage handling functions
- mkimage extensions to allow generation of new format images
- U-Boot support for booting new format images

Code from this patchset will be soon available from the new-image branch of the u-boot-testing repository.

Please review, test and provide comments.

Marian Balakowicz (5):
[new uImage] Fix erroneous use of image_get_magic() in fdc/usb cmds [new uImage] Rename and move print_image_hdr() routine [new uImage] Add fit_parse_conf() and fit_parse_subimage() routines [new uImage] Add gen_get_image() routine
[new uImage] Pull in libfdt if CONFIG_FIT is enabled

Regards,
Bartlomiej

#1 lore raw

PATCH 1/5 Pull in libfdt if CONFIG_FIT is enabled

From: Marian Balakowicz <[email protected]>

New uImage format (Flattened Image Tree) requires libfdt functionality, print out error message if CONFIG_OF_LIBFDT is not defined.

New uImage support is enabled by defining CONFIG_FIT (and CONFIG_OF_LIBFDT). This commit turns it on by default.

---

 cpu/mpc5xxx/cpu.c |    2 +-
 cpu/mpc8260/cpu.c |    2 +-
 cpu/mpc8xx/cpu.c  |    2 +-
 include/image.h   |    9 +++++++++
 4 files changed, 12 insertions(+), 3 deletions(-)
cpu/mpc5xxx/cpu.c +1 -1
index e4d6168..7522afe 100644
@@ -114,7 +114,7 @@ unsigned long get_tbclk (void)
 
 /* ------------------------------------------------------------------------- */
 
-#ifdef CONFIG_OF_LIBFDT
+#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
 void ft_cpu_setup(void *blob, bd_t *bd)
 {
 	int div = in_8((void*)CFG_MBAR + 0x204) & 0x0020 ? 8 : 4;
cpu/mpc8260/cpu.c +1 -1
index 55e61a1..414759e 100644
@@ -300,7 +300,7 @@ void watchdog_reset (void)
 #endif /* CONFIG_WATCHDOG */
 
 /* ------------------------------------------------------------------------- */
-#if defined(CONFIG_OF_LIBFDT)
+#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
 void ft_cpu_setup (void *blob, bd_t *bd)
 {
 	char * cpu_path = "/cpus/" OF_CPU;
cpu/mpc8xx/cpu.c +1 -1
index c878352..5d4ab82 100644
@@ -638,7 +638,7 @@ void reset_8xx_watchdog (volatile immap_t * immr)
 #endif /* CONFIG_WATCHDOG */
 
 /* ------------------------------------------------------------------------- */
-#if defined(CONFIG_OF_LIBFDT)
+#if defined(CONFIG_OF_LIBFDT) && defined (CONFIG_OF_BOARD_SETUP)
 void ft_cpu_setup (void *blob, bd_t *bd)
 {
 	char * cpu_path = "/cpus/" OF_CPU;
include/image.h +9 -0
index dbbbee9..ecfce72 100644
@@ -35,10 +35,19 @@
 
 #include <asm/byteorder.h>
 #include <command.h>
+
 #ifndef USE_HOSTCC
 #include <linux/string.h>
 #include <asm/u-boot.h>
+
+/* new uImage format support enabled by default */
+#define CONFIG_FIT		1
+#define CONFIG_OF_LIBFDT	1
+
+#if defined(CONFIG_FIT) && !defined(CONFIG_OF_LIBFDT)
+#error "CONFIG_OF_LIBFDT not enabled, required by CONFIG_FIT!"
 #endif
+#endif /* USE_HOSTCC */
 
 /*
  * Operating System Codes
#2 lore raw

PATCH 2/5 Add gen_get_image() routine

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

This routine assures that image (whether legacy or FIT) is not in a special dataflash storage.

If image address is a dataflash address image is moved to system RAM.

---

 common/cmd_bootm.c |   22 +--------
 common/image.c     |  126 +++++++++++++++++++++++++++++++++++++++++++---------
 include/image.h    |    6 ++
 lib_ppc/bootm.c    |    5 ++
 4 files changed, 119 insertions(+), 40 deletions(-)
common/cmd_bootm.c +3 -19
index 2ddb191..ebb6b69 100644
@@ -44,10 +44,6 @@
 #include <hush.h>
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-#include <dataflash.h>
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
@@ -304,12 +300,8 @@ static image_header_t *get_kernel (cmd_tbl_t *cmdtp, int flag,
 	show_boot_progress (1);
 	printf ("## Booting image at %08lx ...\n", img_addr);
 
-#ifdef CONFIG_HAS_DATAFLASH
-	if (addr_dataflash (img_addr)){
-		hdr = (image_header_t *)CFG_LOAD_ADDR;
-		read_dataflash (img_addr, image_get_header_size (), (char *)hdr);
-	} else
-#endif
+	/* copy from dataflash if needed */
+	img_addr = gen_get_image (img_addr);
 	hdr = (image_header_t *)img_addr;
 
 	if (!image_check_magic(hdr)) {
@@ -324,16 +316,8 @@ static image_header_t *get_kernel (cmd_tbl_t *cmdtp, int flag,
 		show_boot_progress (-2);
 		return NULL;
 	}
-	show_boot_progress (3);
 
-#ifdef CONFIG_HAS_DATAFLASH
-	if (addr_dataflash (img_addr))
-		read_dataflash (img_addr + image_get_header_size (),
-				image_get_data_size (hdr),
-				(char *)image_get_data (hdr));
-#endif
-
-	/* uImage is in a system RAM, pointed to by hdr */
+	show_boot_progress (3);
 	print_image_hdr (hdr);
 
 	if (verify) {
common/image.c +105 -21

150 lines not on this page · raw message

include/image.h +6 -0
index ecfce72..b4de49d 100644
@@ -343,6 +343,12 @@ const char* image_get_arch_name (uint8_t arch);
 const char* image_get_type_name (uint8_t type);
 const char* image_get_comp_name (uint8_t comp);
 
+#define IMAGE_FORMAT_INVALID	0x00
+#define IMAGE_FORMAT_LEGACY	0x01
+#define IMAGE_FORMAT_FIT	0x02
+int gen_image_get_format (void *img_addr);
+ulong gen_get_image (ulong img_addr);
+
 image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
 		int argc, char *argv[],
 		ulong rd_addr, uint8_t arch, int verify);
lib_ppc/bootm.c +5 -0
index 69ec459..04a9665 100644
@@ -234,6 +234,11 @@ static ulong get_fdt (ulong alloc_current,
 
 	if(argc > 3) {
 		fdt = (char *)simple_strtoul (argv[3], NULL, 16);
+
+		debug ("## Checking for 'FDT'/'FDT image' at %08lx\n", fdt);
+
+		/* copy from dataflash if needed */
+		fdt = (char *)gen_get_image ((ulong)fdt);
 		fdt_hdr = (image_header_t *)fdt;
 
 		if (fdt_check_header (fdt) == 0) {
#3 lore raw

PATCH 3/5 Add fit_parse_conf() and fit_parse_subimage() routines

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Introducing routines for parsing new uImage format bootm arguments:
[<addr>]#<conf> - configuration specification
[<addr>]:<subimg> - subimage specification

New format images can contain multiple subimages of the same type. For example a single new format image file can contain three kernels, two ramdisks and a couple of FDT blobs. Subimage and configuration specifications are extensions to bootm (and other image-related commands) arguments' syntax that allow to specify which particular subimage should be operated on.

Subimage specification is used to denote a particular subimage. Configurations are a bit more complex -- they are used to define a particualr booting setup, for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple, etc.

---

 common/image.c  |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/image.h |   10 +++++++
 2 files changed, 88 insertions(+), 0 deletions(-)
common/image.c +78 -0
index ab6b8e6..7362328 100644
@@ -774,4 +774,82 @@ ulong get_boot_kbd (ulong alloc_current, bd_t **kbd)
 }
 #endif /* CONFIG_PPC || CONFIG_M68K */
 
+#if defined(CONFIG_FIT)
+/*****************************************************************************/
+/* New uImage format routines */
+/*****************************************************************************/
+static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr,
+		ulong *addr, const char **name)
+{
+	const char *sep;
+
+	*addr = addr_curr;
+	*name = NULL;
+
+	sep = strchr (spec, sepc);
+	if (sep) {
+		if (sep - spec > 0)
+			*addr = simple_strtoul (spec, NULL, 16);
+
+		*name = sep + 1;
+		return 1;
+	}
+
+	return 0;
+}
+
+/**
+ * fit_parse_conf - parse FIT configuration spec
+ * @spec: input string, containing configuration spec
+ * @add_curr: current image address (to be used as a possible default)
+ * @addr: pointer to a ulong variable, will hold FIT image address of a given
+ * configuration
+ * @conf_name double pointer to a char, will hold pointer to a configuration
+ * unit name
+ *
+ * fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>,
+ * where <addr> is a FIT image address that contains configuration
+ * with a <conf> unit name.
+ *
+ * Address part is optional, and if omitted default add_curr will
+ * be used instead.
+ *
+ * returns:
+ *     1 if spec is a valid configuration string,
+ *     addr and conf_name are set accordingly
+ *     0 otherwise
+ */
+inline int fit_parse_conf (const char *spec, ulong addr_curr,
+		ulong *addr, const char **conf_name)
+{
+	return fit_parse_spec (spec, '#', addr_curr, addr, conf_name);
+}
+
+/**
+ * fit_parse_subimage - parse FIT subimage spec
+ * @spec: input string, containing subimage spec
+ * @add_curr: current image address (to be used as a possible default)
+ * @addr: pointer to a ulong variable, will hold FIT image address of a given
+ * subimage
+ * @image_name: double pointer to a char, will hold pointer to a subimage name
+ *
+ * fit_parse_subimage() expects subimage spec in the for of
+ * [<addr>]:<subimage>, where <addr> is a FIT image address that contains
+ * subimage with a <subimg> unit name.
+ *
+ * Address part is optional, and if omitted default add_curr will
+ * be used instead.
+ *
+ * returns:
+ *     1 if spec is a valid subimage string,
+ *     addr and image_name are set accordingly
+ *     0 otherwise
+ */
+inline int fit_parse_subimage (const char *spec, ulong addr_curr,
+		ulong *addr, const char **image_name)
+{
+	return fit_parse_spec (spec, ':', addr_curr, addr, image_name);
+}
+#endif /* CONFIG_FIT */
+
 #endif /* USE_HOSTCC */
include/image.h +10 -0
index b4de49d..4923612 100644
@@ -367,6 +367,16 @@ ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end);
 ulong get_boot_kbd (ulong alloc_current, bd_t **kbd);
 #endif /* CONFIG_PPC || CONFIG_M68K */
 
+#if defined(CONFIG_FIT)
+/*
+ * New uImage format
+ */
+inline int fit_parse_conf (const char *spec, ulong addr_curr,
+		ulong *addr, const char **conf_name);
+inline int fit_parse_subimage (const char *spec, ulong addr_curr,
+		ulong *addr, const char **image_name);
+#endif /* CONFIG_FIT */
+
 #endif /* USE_HOSTCC */
 
 #endif	/* __IMAGE_H__ */
#4 lore raw

PATCH 3/5 Add fit_parse_conf() and fit_parse_subimage() routines

Quoted 24 lines · Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

Introducing routines for parsing new uImage format bootm arguments:
[<addr>]#<conf> - configuration specification
[<addr>]:<subimg> - subimage specification

New format images can contain multiple subimages of the same type. For example
a single new format image file can contain three kernels, two ramdisks and a
couple of FDT blobs. Subimage and configuration specifications are extensions
to bootm (and other image-related commands) arguments' syntax that allow to
specify which particular subimage should be operated on.

Subimage specification is used to denote a particular subimage. Configurations
are a bit more complex -- they are used to define a particualr booting setup,
for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple,
etc.

Quoted 1 line

Mind adding a example of what <conf> and <subimg> would/could be set to. (Its not clear to me if these are indexes [0..n] or labels)

- k

#5 lore raw

PATCH 3/5 Add fit_parse_conf() and fit_parse_subimage() routines

Kumar Gala wrote:
[...]

Quoted 22 lines
Quoted 22 lines

Introducing routines for parsing new uImage format bootm arguments:
[<addr>]#<conf> - configuration specification
[<addr>]:<subimg> - subimage specification

New format images can contain multiple subimages of the same type. For example
a single new format image file can contain three kernels, two ramdisks and a
couple of FDT blobs. Subimage and configuration specifications are extensions
to bootm (and other image-related commands) arguments' syntax that allow to
specify which particular subimage should be operated on.

Subimage specification is used to denote a particular subimage. Configurations
are a bit more complex -- they are used to define a particualr booting setup,
for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple,
etc.

Quoted 4 lines
Quoted 1 line

Mind adding a example of what <conf> and <subimg> would/could be set to. (Its not clear to me if these are indexes [0..n] or labels)

Both <conf> and <subimg> are unit names from the image source file (dts format) used to generate the image. For example, having an image generated using the source file with the following structure:

/{
         images {
                 kernel at 1 { ...
                 kernel at 2 { ...
                 ramdisk at 1 { ...
                 fdt at 1 { ...
                 fdt at 2 { ...
                 fdt at 3 { ...
         };

         configurations {
                 conf at 1 { ...
         };
};

one could in U-Boot do:

bootm 300000:kernel at 1
bootm 300000:kernel at 2 :ramdisk at 1 :fdt at 3
bootm 300000:kernel at 2 - 300000:fdt at 1
bootm 300000:config at 1

This will be documented better in the form of a doc/README.<something> file that we plan to post. And I'd rather not add too much documentation
to the commit log, especially now that Wolfgang has merged the patches
to the new-image branch of u-boot-testing.

Regards,
Bartlomiej

#6 lore raw

PATCH 4/5 Rename and move print_image_hdr() routine

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

---

 board/mpl/common/common_util.c |    2 +
 common/cmd_bootm.c             |   61 ++--------------------------------------
 common/cmd_doc.c               |    2 +
 common/cmd_fdc.c               |    2 +
 common/cmd_ide.c               |    2 +
 common/cmd_nand.c              |    4 +--
 common/cmd_scsi.c              |    2 +
 common/cmd_usb.c               |    2 +
 common/cmd_ximg.c              |    2 +
 common/image.c                 |   56 ++++++++++++++++++++++++++++++++++++-
 include/common.h               |    3 --
 include/image.h                |    1 +
 lib_ppc/bootm.c                |    2 +
 13 files changed, 69 insertions(+), 72 deletions(-)
board/mpl/common/common_util.c +1 -1
index 30c6ca9..b171ca5 100644
@@ -185,7 +185,7 @@ mpl_prg_image(uchar *ld_addr)
 		puts("Bad Magic Number\n");
 		return 1;
 	}
-	print_image_hdr(hdr);
+	image_print_contents (hdr);
 	if (!image_check_os (hdr, IH_OS_U_BOOT)) {
 		puts("No U-Boot Image\n");
 		return 1;
common/cmd_bootm.c +3 -58

97 lines not on this page · raw message

common/cmd_doc.c +1 -1
index b20a2e1..70bbd31 100644
@@ -265,7 +265,7 @@ int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	if (image_check_magic (hdr)) {
 
-		print_image_hdr (hdr);
+		image_print_contents (hdr);
 
 		cnt = image_get_image_size (hdr);
 		cnt -= SECTORSIZE;
common/cmd_fdc.c +1 -1
index 3b8f80b..c97abfb 100644
@@ -840,7 +840,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		printf ("Bad Magic Number\n");
 		return 1;
 	}
-	print_image_hdr (hdr);
+	image_print_contents (hdr);
 
 	imsize= image_get_image_size (hdr);
 	nrofblk=imsize/512;
common/cmd_ide.c +1 -1
index bcd1325..a396643 100644
@@ -462,7 +462,7 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 	show_boot_progress (50);
 
-	print_image_hdr (hdr);
+	image_print_contents (hdr);
 
 	cnt = image_get_image_size (hdr);
 	cnt += info.blksz - 1;
common/cmd_nand.c +2 -2
index bfa39d7..7fd6667 100644
@@ -521,7 +521,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 	}
 	show_boot_progress (57);
 
-	print_image_hdr (hdr);
+	image_print_contents (hdr);
 
 	cnt = image_get_image_size (hdr);
 	if (jffs2) {
@@ -984,7 +984,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	if (image_check_magic (hdr)) {
 
-		print_image_hdr (hdr);
+		image_print_contents (hdr);
 
 		cnt = image_get_image_size (hdr);
 		cnt -= SECTORSIZE;
common/cmd_scsi.c +1 -1
index c2b27a5..5aae7ec 100644
@@ -285,7 +285,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	print_image_hdr (hdr);
+	image_print_contents (hdr);
 	cnt = image_get_image_size (hdr);
 	cnt += info.blksz - 1;
 	cnt /= info.blksz;
common/cmd_usb.c +1 -1
index db2e754..2d7a85a 100644
@@ -398,7 +398,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 
-	print_image_hdr (hdr);
+	image_print_contents (hdr);
 
 	cnt = image_get_image_size (hdr);
 	cnt += info.blksz - 1;
common/cmd_ximg.c +1 -1
index ab579cd..7d83dc3 100644
@@ -70,7 +70,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 #ifdef DEBUG
-	print_image_hdr (hdr);
+	image_print_contents (hdr);
 #endif
 
 	if (!image_check_type (hdr, IH_TYPE_MULTI)) {
common/image.c +55 -1

74 lines not on this page · raw message

include/common.h +0 -3
index cd8aad0..3f05b5e 100644
@@ -224,9 +224,6 @@ void flash_perror (int);
 /* common/cmd_autoscript.c */
 int	autoscript (ulong addr);
 
-/* common/cmd_bootm.c */
-void	print_image_hdr (image_header_t *hdr);
-
 extern ulong load_addr;		/* Default Load Address */
 
 /* common/cmd_nvedit.c */
include/image.h +1 -0
index 4923612..502d35a 100644
@@ -342,6 +342,7 @@ const char* image_get_os_name (uint8_t os);
 const char* image_get_arch_name (uint8_t arch);
 const char* image_get_type_name (uint8_t type);
 const char* image_get_comp_name (uint8_t comp);
+void image_print_contents (image_header_t *hdr);
 
 #define IMAGE_FORMAT_INVALID	0x00
 #define IMAGE_FORMAT_LEGACY	0x01
lib_ppc/bootm.c +1 -1
index 04a9665..d2ee3dc 100644
@@ -254,7 +254,7 @@ static ulong get_fdt (ulong alloc_current,
 			printf ("## Flattened Device Tree Image@%08lx\n",
 					fdt_hdr);
 
-			print_image_hdr (fdt_hdr);
+			image_print_contents (fdt_hdr);
 
 			image_start = (ulong)fdt_hdr;
 			image_end = image_get_image_end (fdt_hdr);
#7 lore raw

PATCH 5/5 Fix erroneous use of image_get_magic() in fdc/usb cmds

In reply to Bartlomiej Sieka

From: Marian Balakowicz <[email protected]>

---

 common/cmd_fdc.c |    2 +-
 common/cmd_usb.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
common/cmd_fdc.c +1 -1
index c97abfb..9ddc59b 100644
@@ -836,7 +836,7 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		return 1;
 	}
 	hdr = (image_header_t *)addr;
-	if (!image_get_magic (hdr)) {
+	if (!image_check_magic (hdr)) {
 		printf ("Bad Magic Number\n");
 		return 1;
 	}
common/cmd_usb.c +1 -1
index 2d7a85a..3f1aa7d 100644
@@ -388,7 +388,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	hdr = (image_header_t *)addr;
 
-	if (!image_get_magic (hdr)) {
+	if (!image_check_magic (hdr)) {
 		printf("\n** Bad Magic Number **\n");
 		return 1;
 	}