Skip to contentSkip to conversation

cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc

PATCH New Tom Rini 3 participants 6 messages Jul 9, 2013 – Jul 10, 2013

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/2 cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc

Like 'bootm', 'bootz' needs to consume 'bootz' so that the rest of the state functions will work.

---
 common/cmd_bootm.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
common/cmd_bootm.c +13 -5
index d0ad80f..3a899bc 100644
@@ -1763,12 +1763,12 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
 			      images, 1);
 
 	/* Setup Linux kernel zImage entry point */
-	if (argc < 2) {
+	if (!argc) {
 		images->ep = load_addr;
 		debug("*  kernel: default image load address = 0x%08lx\n",
 				load_addr);
 	} else {
-		images->ep = simple_strtoul(argv[1], NULL, 16);
+		images->ep = simple_strtoul(argv[0], NULL, 16);
 		debug("*  kernel: cmdline image address = 0x%08lx\n",
 			images->ep);
 	}
@@ -1779,16 +1779,24 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
 
-	ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_FINDOTHER,
-			      images, 1);
+	if (bootm_find_ramdisk(flag, argc, argv))
+		return 1;
 
-	return ret;
+#if defined(CONFIG_OF_LIBFDT)
+	if (bootm_find_fdt(flag, argc, argv))
+		return 1;
+#endif
+
+	return 0;
 }
 
 int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int ret;
 
+	/* Consume 'bootz' */
+	argc--; argv++;
+
 	if (bootz_start(cmdtp, flag, argc, argv, &images))
 		return 1;
 
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/2 cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc

Quoted 4 lines · Tom Rini

Like 'bootm', 'bootz' needs to consume 'bootz' so that the rest of the state functions will work.

This and 2/2 have now been applied to u-boot/master.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130710/57347543/attachment.pgp>
#2 lore raw

PATCH 1/2 cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc

In reply to Tom Rini
Quoted 2 lines · Tom Rini

Like 'bootm', 'bootz' needs to consume 'bootz' so that the rest of the state functions will work.

I found that the Raspberry Pi was randomly crashing with recent u-boot/master (bisect points at/near commit 35fc84f "Refactor the bootm command to reduce code duplication"; there is some slight variation in symptoms around there), or sometimes just spewing errors from bootz. I found the following commits on the mailing list:

Quoted 7 lines

e1ec5e0 cmd_bootm.c: Make bootz handle BOOTM_STATE_FINDOTHER itself c83a89d cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc d18cab6 bootm: Add the missing PREP stage to bootz and correct image handling 4766b32 bootm: Clean up bootz_setup() function
f65d734 bootm: Require boot function only if it is about to be used bf6f341 bootm: Disable interrupts only when loading
a01d5e4 bootm: Handle errors consistently

... and the combination of all 7 of them (but not just Simon's 5 patches) seems to solve this, so,

#3 lore raw

PATCH 1/2 cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc

Quoted 19 lines · Stephen Warren
Quoted 2 lines · Tom Rini

Like 'bootm', 'bootz' needs to consume 'bootz' so that the rest of the state functions will work.

I found that the Raspberry Pi was randomly crashing with recent u-boot/master (bisect points at/near commit 35fc84f "Refactor the bootm command to reduce code duplication"; there is some slight variation in symptoms around there), or sometimes just spewing errors from bootz. I found the following commits on the mailing list:

Quoted 3 lines

e1ec5e0 cmd_bootm.c: Make bootz handle BOOTM_STATE_FINDOTHER itself c83a89d cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc d18cab6 bootm: Add the missing PREP stage to bootz and correct image

handling

Quoted 4 lines

4766b32 bootm: Clean up bootz_setup() function
f65d734 bootm: Require boot function only if it is about to be used bf6f341 bootm: Disable interrupts only when loading a01d5e4 bootm: Handle errors consistently

Quoted 6 lines

... and the combination of all 7 of them (but not just Simon's 5 patches) seems to solve this, so,

Thanks Stephen. Is this with an attached dtb or not? What 'bootz' command line are you testing here? I just want to make sure we are covering all the options

Regards,
Simon

#4 lore raw

PATCH 1/2 cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc

Quoted 23 lines · Simon Glass

On Tue, Jul 9, 2013 at 9:59 PM, Stephen Warren <[email protected] <mailto:[email protected]>> wrote:

On 07/09/2013 01:34 PM, Tom Rini wrote:
> Like 'bootm', 'bootz' needs to consume 'bootz' so that the rest of the > state functions will work.

I found that the Raspberry Pi was randomly crashing with recent u-boot/master (bisect points at/near commit 35fc84f "Refactor the bootm command to reduce code duplication"; there is some slight variation in symptoms around there), or sometimes just spewing errors from bootz. I found the following commits on the mailing list:

> e1ec5e0 cmd_bootm.c: Make bootz handle BOOTM_STATE_FINDOTHER itself > c83a89d cmd_bootm.c: Make bootz consume 'bootz' from argv, decrement argc
> d18cab6 bootm: Add the missing PREP stage to bootz and correct image handling
> 4766b32 bootm: Clean up bootz_setup() function
> f65d734 bootm: Require boot function only if it is about to be used > bf6f341 bootm: Disable interrupts only when loading
> a01d5e4 bootm: Handle errors consistently

Quoted 8 lines

... and the combination of all 7 of them (but not just Simon's 5 patches) seems to solve this, so,

Thanks Stephen. Is this with an attached dtb or not? What 'bootz' command line are you testing here? I just want to make sure we are covering all the options

This is a separate kernel and DTB; the command-line is roughly:

bootz addr_of_zimage - addr_of_dtb

author
#5 lore raw

PATCH 2/2 cmd_bootm.c: Make bootz handle BOOTM_STATE_FINDOTHER itself

In reply to Tom Rini

As a zImage does not have a U-Boot header, we cannot really do what BOOTM_STATE_FINDOTHER does, exactly. Break the ramdisk/fdt portions of bootm_find_other into bootm_find_ramdisk/fdt which can be called in both cases.

---
 common/cmd_bootm.c |   56 +++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 16 deletions(-)
common/cmd_bootm.c +40 -16
index 3a899bc..1498380 100644
@@ -309,33 +309,53 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
 	return 0;
 }
 
-static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
-			    char * const argv[])
+static int bootm_find_ramdisk(int flag, int argc, char * const argv[])
+{
+	int ret;
+
+	/* find ramdisk */
+	ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
+			       &images.rd_start, &images.rd_end);
+	if (ret) {
+		puts("Ramdisk image is corrupt or invalid\n");
+		return 1;
+	}
+
+	return 0;
+}
+
+#if defined(CONFIG_OF_LIBFDT)
+static int bootm_find_fdt(int flag, int argc, char * const argv[])
 {
 	int ret;
 
+	/* find flattened device tree */
+	ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
+			   &images.ft_addr, &images.ft_len);
+	if (ret) {
+		puts("Could not find a valid device tree\n");
+		return 1;
+	}
+
+	set_working_fdt_addr(images.ft_addr);
+
+	return 0;
+}
+#endif
+
+static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
+			    char * const argv[])
+{
 	if (((images.os.type == IH_TYPE_KERNEL) ||
 	     (images.os.type == IH_TYPE_KERNEL_NOLOAD) ||
 	     (images.os.type == IH_TYPE_MULTI)) &&
 	    (images.os.os == IH_OS_LINUX)) {
-		/* find ramdisk */
-		ret = boot_get_ramdisk(argc, argv, &images, IH_INITRD_ARCH,
-				&images.rd_start, &images.rd_end);
-		if (ret) {
-			puts("Ramdisk image is corrupt or invalid\n");
+		if (bootm_find_ramdisk(flag, argc, argv))
 			return 1;
-		}
 
 #if defined(CONFIG_OF_LIBFDT)
-		/* find flattened device tree */
-		ret = boot_get_fdt(flag, argc, argv, IH_ARCH_DEFAULT, &images,
-				   &images.ft_addr, &images.ft_len);
-		if (ret) {
-			puts("Could not find a valid device tree\n");
+		if (bootm_find_fdt(flag, argc, argv))
 			return 1;
-		}
-
-		set_working_fdt_addr(images.ft_addr);
 #endif
 	}
 
@@ -1779,6 +1799,10 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
 
+	/*
+	 * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
+	 * have a header that provide this informaiton.
+	 */
 	if (bootm_find_ramdisk(flag, argc, argv))
 		return 1;
 
Signature · 1 line
1.7.9.5