[U-Boot] [PATCH] pxe: automatically add console= to bootargs when not specified in append

Hans de Goede hdegoede at redhat.com
Fri Aug 1 09:46:20 CEST 2014


From: Dennis Gilmore <dennis at ausil.us>

if there is a console variable in the u-boot environment and not one on
the append line from syslinux config add what is in the environment to
the bootargs.

This is necessary to allow distros to have a single extlinux/extlinux.conf
file which will work on multiple boards, even if these boards have different
consoles (e.g. ttyS0 vs ttyAMA0).

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 common/cmd_pxe.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c
index ba48692..147d7d1 100644
--- a/common/cmd_pxe.c
+++ b/common/cmd_pxe.c
@@ -606,6 +606,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 	char initrd_str[22];
 	char mac_str[29] = "";
 	char ip_str[68] = "";
+	char console[30] = "";
 	char *bootargs;
 	int bootm_argc = 3;
 	int len = 0;
@@ -665,8 +666,14 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 	}
 #endif
 
-	if (label->append)
+	if (label->append) {
 		len += strlen(label->append);
+		/* If no console in append and $console is set, use it */
+		if (!strstr(label->append, "console=") && getenv("console")) {
+			sprintf(console, " console=%s", getenv("console"));
+			len += strlen(console);
+		}
+	}
 
 	if (len) {
 		bootargs = malloc(len + 1);
@@ -675,6 +682,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		bootargs[0] = '\0';
 		if (label->append)
 			strcpy(bootargs, label->append);
+		strcat(bootargs, console);
 		strcat(bootargs, ip_str);
 		strcat(bootargs, mac_str);
 
-- 
2.0.3



More information about the U-Boot mailing list