Patchwork [U-Boot,v2] pxe: try bootz if bootm fails to find a valid image

login
register
mail settings
Submitter Rob Herring
Date Dec. 3, 2012, 7:17 p.m.
Message ID <1354562241-18733-1-git-send-email-robherring2@gmail.com>
Download mbox | patch
Permalink /patch/203419/
State Accepted
Delegated to: Joe Hershberger
Headers show

Comments

Rob Herring - Dec. 3, 2012, 7:17 p.m.
From: Rob Herring <rob.herring@calxeda.com>

Standard pxelinux servers will typically use a zImage rather than u-boot
image format, so fallback to bootz if bootm fails.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
v2:
- Only fall back to bootz when bootm fails instead of being either or
  option.

 common/cmd_pxe.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Joe Hershberger - July 8, 2013, 3:52 p.m.
On Mon, Dec 3, 2012 at 1:17 PM, Rob Herring <robherring2@gmail.com> wrote:
> From: Rob Herring <rob.herring@calxeda.com>
>
> Standard pxelinux servers will typically use a zImage rather than u-boot
> image format, so fallback to bootz if bootm fails.
>
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>

Applied, Thanks.
-Joe

Patch

diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index 02ed645..4bfacf3 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -579,6 +579,7 @@  static int label_localboot(struct pxe_label *label)
 static int label_boot(struct pxe_label *label)
 {
 	char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL };
+	char initrd_str[22];
 	int bootm_argc = 3;
 
 	label_print(label);
@@ -604,7 +605,10 @@  static int label_boot(struct pxe_label *label)
 			return 1;
 		}
 
-		bootm_argv[2] = getenv("ramdisk_addr_r");
+		bootm_argv[2] = initrd_str;
+		strcpy(bootm_argv[2], getenv("ramdisk_addr_r"));
+		strcat(bootm_argv[2], ":");
+		strcat(bootm_argv[2], getenv("filesize"));
 	} else {
 		bootm_argv[2] = "-";
 	}
@@ -649,6 +653,11 @@  static int label_boot(struct pxe_label *label)
 		bootm_argc = 4;
 
 	do_bootm(NULL, 0, bootm_argc, bootm_argv);
+
+#ifdef CONFIG_CMD_BOOTZ
+	/* Try booting a zImage if do_bootm returns */
+	do_bootz(NULL, 0, bootm_argc, bootm_argv);
+#endif
 	return 1;
 }