[U-Boot] [PATCH 00/10] PXE support updates

From: Rob Herring rob.herring@calxeda.com
This is a series of various enhancements and fixes for u-boot pxe support. These patches are a result of testing with server side tools like Cobbler and ubuntu MAAS.
Rob
Rob Herring (10): pxe: Use ethact setting for pxe pxe: make string parameters const pxe: fix handling of different localboot values bootz: un-staticize do_bootz pxe: use bootz instead of bootm when enabled pxe: always display a menu when present pxe: simplify menu display and selection pxe: add support for ontimeout token pxe: add support for per arch and SoC default paths pxe: add ipappend support
common/cmd_bootm.c | 2 +- common/cmd_pxe.c | 210 ++++++++++++++++++++++++++++++++-------------------- include/command.h | 2 + 3 files changed, 132 insertions(+), 82 deletions(-)

From: Rob Herring rob.herring@calxeda.com
Get the MAC address using eth_getenv_enetaddr_by_index so that the MAC address of ethact is used. This enables using the a NIC other than the first one for PXE boot.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index ee75db9..306c483 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -55,37 +55,21 @@ static char *from_env(char *envvar) */ static int format_mac_pxe(char *outbuf, size_t outbuf_len) { - size_t ethaddr_len; - char *p, *ethaddr; + uchar ethaddr[6];
- ethaddr = from_env("ethaddr"); - - if (!ethaddr) - return -ENOENT; - - ethaddr_len = strlen(ethaddr); - - /* - * ethaddr_len + 4 gives room for "01-", ethaddr, and a NUL byte at - * the end. - */ - if (outbuf_len < ethaddr_len + 4) { - printf("outbuf is too small (%d < %d)\n", - outbuf_len, ethaddr_len + 4); + if (outbuf_len < 21) { + printf("outbuf is too small (%d < 21)\n", outbuf_len);
return -EINVAL; }
- strcpy(outbuf, "01-"); - - for (p = outbuf + 3; *ethaddr; ethaddr++, p++) { - if (*ethaddr == ':') - *p = '-'; - else - *p = tolower(*ethaddr); - } + if (!eth_getenv_enetaddr_by_index("eth", eth_get_dev_index(), + ethaddr)) + return -ENOENT;
- *p = '\0'; + sprintf(outbuf, "01-%02x-%02x-%02x-%02x-%02x-%02x", + ethaddr[0], ethaddr[1], ethaddr[2], + ethaddr[3], ethaddr[4], ethaddr[5]);
return 1; }

On Sun, Dec 2, 2012 at 9:00 PM, Rob Herring robherring2@gmail.com wrote:
From: Rob Herring rob.herring@calxeda.com
Get the MAC address using eth_getenv_enetaddr_by_index so that the MAC address of ethact is used. This enables using the a NIC other than the first one for PXE boot.
Signed-off-by: Rob Herring rob.herring@calxeda.com
Applied series, Thanks. -Joe

From: Rob Herring rob.herring@calxeda.com
Convert a bunch of string parameters to be const.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 306c483..8b897ad 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -31,7 +31,7 @@ * environment. It always returns what getenv does, so it can be used in * place of getenv without changing error handling otherwise. */ -static char *from_env(char *envvar) +static char *from_env(const char *envvar) { char *ret;
@@ -115,14 +115,14 @@ static int get_bootfile_path(const char *file_path, char *bootfile_path, return 1; }
-static int (*do_getfile)(char *file_path, char *file_addr); +static int (*do_getfile)(const char *file_path, char *file_addr);
-static int do_get_tftp(char *file_path, char *file_addr) +static int do_get_tftp(const char *file_path, char *file_addr) { char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
tftp_argv[1] = file_addr; - tftp_argv[2] = file_path; + tftp_argv[2] = (void *)file_path;
if (do_tftpb(NULL, 0, 3, tftp_argv)) return -ENOENT; @@ -132,12 +132,12 @@ static int do_get_tftp(char *file_path, char *file_addr)
static char *fs_argv[5];
-static int do_get_ext2(char *file_path, char *file_addr) +static int do_get_ext2(const char *file_path, char *file_addr) { #ifdef CONFIG_CMD_EXT2 fs_argv[0] = "ext2load"; fs_argv[3] = file_addr; - fs_argv[4] = file_path; + fs_argv[4] = (void *)file_path;
if (!do_ext2load(NULL, 0, 5, fs_argv)) return 1; @@ -145,12 +145,12 @@ static int do_get_ext2(char *file_path, char *file_addr) return -ENOENT; }
-static int do_get_fat(char *file_path, char *file_addr) +static int do_get_fat(const char *file_path, char *file_addr) { #ifdef CONFIG_CMD_FAT fs_argv[0] = "fatload"; fs_argv[3] = file_addr; - fs_argv[4] = file_path; + fs_argv[4] = (void *)file_path;
if (!do_fat_fsload(NULL, 0, 5, fs_argv)) return 1; @@ -166,7 +166,7 @@ static int do_get_fat(char *file_path, char *file_addr) * * Returns 1 for success, or < 0 on error. */ -static int get_relfile(char *file_path, void *file_addr) +static int get_relfile(const char *file_path, void *file_addr) { size_t path_len; char relfile[MAX_TFTP_PATH_LEN+1]; @@ -205,7 +205,7 @@ static int get_relfile(char *file_path, void *file_addr) * * Returns 1 on success, or < 0 for error. */ -static int get_pxe_file(char *file_path, void *file_addr) +static int get_pxe_file(const char *file_path, void *file_addr) { unsigned long config_file_size; char *tftp_filesize; @@ -242,7 +242,7 @@ static int get_pxe_file(char *file_path, void *file_addr) * * Returns 1 on success or < 0 on error. */ -static int get_pxelinux_path(char *file, void *pxefile_addr_r) +static int get_pxelinux_path(const char *file, void *pxefile_addr_r) { size_t base_len = strlen(PXELINUX_DIR); char path[MAX_TFTP_PATH_LEN+1]; @@ -382,7 +382,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * * Returns 1 on success or < 0 on error. */ -static int get_relfile_envaddr(char *file_path, char *envaddr_name) +static int get_relfile_envaddr(const char *file_path, const char *envaddr_name) { unsigned long file_addr; char *envaddr;

From: Rob Herring rob.herring@calxeda.com
Add support for value of -1 For localboot. A value of -1 means return to u-boot prompt.
The localboot value is often 0, so we need to distinguish the value from localboot being selected. A value of greater than or equal to 0 means attempt local boot command.
If localboot is selected, we don't want to try other entries.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 8b897ad..02ed645 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -437,6 +437,7 @@ struct pxe_label { char *fdt; int attempted; int localboot; + int localboot_val; struct list_head list; };
@@ -575,7 +576,7 @@ static int label_localboot(struct pxe_label *label) * If the label specifies an 'append' line, its contents will overwrite that * of the 'bootargs' environment variable. */ -static void label_boot(struct pxe_label *label) +static int label_boot(struct pxe_label *label) { char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; int bootm_argc = 3; @@ -585,21 +586,22 @@ static void label_boot(struct pxe_label *label) label->attempted = 1;
if (label->localboot) { - label_localboot(label); - return; + if (label->localboot_val >= 0) + label_localboot(label); + return 0; }
if (label->kernel == NULL) { printf("No kernel given, skipping %s\n", label->name); - return; + return 1; }
if (label->initrd) { if (get_relfile_envaddr(label->initrd, "ramdisk_addr_r") < 0) { printf("Skipping %s for failure retrieving initrd\n", label->name); - return; + return 1; }
bootm_argv[2] = getenv("ramdisk_addr_r"); @@ -610,7 +612,7 @@ static void label_boot(struct pxe_label *label) if (get_relfile_envaddr(label->kernel, "kernel_addr_r") < 0) { printf("Skipping %s for failure retrieving kernel\n", label->name); - return; + return 1; }
if (label->append) @@ -638,7 +640,7 @@ static void label_boot(struct pxe_label *label) if (get_relfile_envaddr(label->fdt, "fdt_addr_r") < 0) { printf("Skipping %s for failure retrieving fdt\n", label->name); - return; + return 1; } } else bootm_argv[3] = getenv("fdt_addr"); @@ -647,6 +649,7 @@ static void label_boot(struct pxe_label *label) bootm_argc = 4;
do_bootm(NULL, 0, bootm_argc, bootm_argv); + return 1; }
/* @@ -887,7 +890,6 @@ static int parse_integer(char **c, int *dst) { struct token t; char *s = *c; - unsigned long temp;
get_token(c, &t, L_SLITERAL);
@@ -896,12 +898,7 @@ static int parse_integer(char **c, int *dst) return -EINVAL; }
- if (strict_strtoul(t.val, 10, &temp) < 0) { - printf("Expected unsigned integer: %s\n", t.val); - return -EINVAL; - } - - *dst = (int)temp; + *dst = simple_strtol(t.val, NULL, 10);
free(t.val);
@@ -1092,7 +1089,8 @@ static int parse_label(char **c, struct pxe_menu *cfg) break;
case T_LOCALBOOT: - err = parse_integer(c, &label->localboot); + label->localboot = 1; + err = parse_integer(c, &label->localboot_val); break;
case T_EOL: @@ -1350,8 +1348,11 @@ static void handle_pxe_menu(struct pxe_menu *cfg) * we give up. */
- if (err == 1) - label_boot(choice); + if (err == 1) { + err = label_boot(choice); + if (!err) + return; + } else if (err != -ENOENT) return;

From: Rob Herring rob.herring@calxeda.com
Make do_bootz available for other functions like do_bootm is.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_bootm.c | 2 +- include/command.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 4dbe952..fc32a2f 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -1612,7 +1612,7 @@ static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc, return 0; }
-static int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { bootm_headers_t images;
diff --git a/include/command.h b/include/command.h index 10bc260..593a332 100644 --- a/include/command.h +++ b/include/command.h @@ -110,6 +110,8 @@ static inline int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd) } #endif
+extern int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); + extern int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc, char *const argv[]);

From: Rob Herring rob.herring@calxeda.com
Standard pxelinux servers would use zImage rather than u-boot image format, so use bootz instead of bootm if enabled.
Signed-off-by: Rob Herring rob.herring@calxeda.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 02ed645..cad5d36 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] = "-"; } @@ -648,7 +652,11 @@ static int label_boot(struct pxe_label *label) if (bootm_argv[3]) bootm_argc = 4;
+#ifdef CONFIG_CMD_BOOTZ + do_bootz(NULL, 0, bootm_argc, bootm_argv); +#else do_bootm(NULL, 0, bootm_argc, bootm_argv); +#endif return 1; }

Dear Rob Herring,
In message 1354503629-25621-6-git-send-email-robherring2@gmail.com you wrote:
From: Rob Herring rob.herring@calxeda.com
Standard pxelinux servers would use zImage rather than u-boot image format, so use bootz instead of bootm if enabled.
Why would this be the case? We should encourage the use of a checksum-protected image format, i. e. the default setting should be for FIT images, followed by legacy U-Boot images, and fall back on archaic formats like zImage only when there is really no other way.
Best regards,
Wolfgang Denk

On 12/03/2012 06:22 AM, Wolfgang Denk wrote:
Dear Rob Herring,
In message 1354503629-25621-6-git-send-email-robherring2@gmail.com you wrote:
From: Rob Herring rob.herring@calxeda.com
Standard pxelinux servers would use zImage rather than u-boot image format, so use bootz instead of bootm if enabled.
Why would this be the case? We should encourage the use of a checksum-protected image format, i. e. the default setting should be for FIT images, followed by legacy U-Boot images, and fall back on archaic formats like zImage only when there is really no other way.
There is no way for the client to tell the server what kind of client it is and therefore what kind of image to serve. There is the dhcp client id string, but that can't be used in situations were you don't control the dhcp server setup. That problem is also the reason for patch 9 where you can't distinguish between x86 and ARM for "default".
When we have systems that boot from UEFI, they will certainly not use u-boot image formats and we don't want to have different setup based on the client/bootloader type.
I can actually just make this run-time rather than compile time. When do_bootm returns when it fails to find a valid u-boot image, I can just call do_bootz.
Rob

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(-)
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; }

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

From: Rob Herring rob.herring@calxeda.com
The prompt flag is for displaying a "boot:" prompt in pxelinux. This doesn't make sense for u-boot as we don't support the pxelinux command interface. So we should just ignore prompt statements and always show the menu if a menu is present.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index cad5d36..85a27e0 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -1154,6 +1154,7 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level) err = 0; switch (t.type) { case T_MENU: + cfg->prompt = 1; err = parse_menu(&p, cfg, b, nest_level); break;
@@ -1183,7 +1184,7 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level) break;
case T_PROMPT: - err = parse_integer(&p, &cfg->prompt); + eol_or_eof(&p); break;
case T_EOL:

From: Rob Herring rob.herring@calxeda.com
Menus with lots of entries and long append lines are hard to read. Just show a numbered list using the label or name and make the choice by entering the number.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 85a27e0..d697045 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -429,6 +429,7 @@ static int get_relfile_envaddr(const char *file_path, const char *envaddr_name) * list - lets these form a list, which a pxe_menu struct will hold. */ struct pxe_label { + char num[4]; char *name; char *menu; char *kernel; @@ -518,21 +519,9 @@ static void label_destroy(struct pxe_label *label) static void label_print(void *data) { struct pxe_label *label = data; - const char *c = label->menu ? label->menu : label->kernel; + const char *c = label->menu ? label->menu : label->name;
- printf("%s:\t%s\n", label->name, c); - - if (label->kernel) - printf("\t\tkernel: %s\n", label->kernel); - - if (label->append) - printf("\t\tappend: %s\n", label->append); - - if (label->initrd) - printf("\t\tinitrd: %s\n", label->initrd); - - if (label->fdt) - printf("\tfdt: %s\n", label->fdt); + printf("%s:\t%s\n", label->num, c); }
/* @@ -619,8 +608,10 @@ static int label_boot(struct pxe_label *label) return 1; }
- if (label->append) + if (label->append) { setenv("bootargs", label->append); + printf("append: %s\n", label->append); + }
bootm_argv[1] = getenv("kernel_addr_r");
@@ -1267,6 +1258,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) struct list_head *pos; struct menu *m; int err; + int i = 1; + char *default_num = NULL;
/* * Create a menu and add items for all the labels. @@ -1279,18 +1272,23 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg) list_for_each(pos, &cfg->labels) { label = list_entry(pos, struct pxe_label, list);
- if (menu_item_add(m, label->name, label) != 1) { + sprintf(label->num, "%d", i++); + if (menu_item_add(m, label->num, label) != 1) { menu_destroy(m); return NULL; } + if (cfg->default_label && + (strcmp(label->name, cfg->default_label) == 0)) + default_num = label->num; + }
/* * After we've created items for each label in the menu, set the * menu's default label if one was specified. */ - if (cfg->default_label) { - err = menu_default_set(m, cfg->default_label); + if (default_num) { + err = menu_default_set(m, default_num); if (err != 1) { if (err != -ENOENT) { menu_destroy(m);

From: Rob Herring rob.herring@calxeda.com
ontimeout is similar to default, but is the selection on menu timeout. This is how cobbler sets a default. The label default is supposed to be the default selection when <enter> is pressed. If both default and ontimeout are set, last one parsed wins.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index d697045..93c8df5 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -671,6 +671,7 @@ enum token_type { T_PROMPT, T_INCLUDE, T_FDT, + T_ONTIMEOUT, T_INVALID };
@@ -699,6 +700,7 @@ static const struct token keywords[] = { {"initrd", T_INITRD}, {"include", T_INCLUDE}, {"fdt", T_FDT}, + {"ontimeout", T_ONTIMEOUT,}, {NULL, T_INVALID} };
@@ -996,10 +998,8 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg,
switch (t.type) { case T_DEFAULT: - if (cfg->default_label) - free(cfg->default_label); - - cfg->default_label = strdup(label->name); + if (!cfg->default_label) + cfg->default_label = strdup(label->name);
if (!cfg->default_label) return -ENOMEM; @@ -1158,6 +1158,7 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level) break;
case T_DEFAULT: + case T_ONTIMEOUT: err = parse_sliteral(&p, &label_name);
if (label_name) {

From: Rob Herring rob.herring@calxeda.com
A pxelinux server setup for "default" menu is typically an x86 binary. This does not work well with a mixed architecture setup. Extend the default search to look for default-<arch>-<soc> and then default-<arch> before falling back to just "default".
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index 93c8df5..f834d31 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -26,6 +26,13 @@
#define MAX_TFTP_PATH_LEN 127
+const char *pxe_default_paths[] = { + "default-" CONFIG_SYS_ARCH "-" CONFIG_SYS_SOC, + "default-" CONFIG_SYS_ARCH, + "default", + NULL +}; + /* * Like getenv, but prints an error if envvar isn't defined in the * environment. It always returns what getenv does, so it can be used in @@ -339,7 +346,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *pxefile_addr_str; unsigned long pxefile_addr_r; - int err; + int err, i = 0;
do_getfile = do_get_tftp;
@@ -362,14 +369,21 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) */ if (pxe_uuid_path((void *)pxefile_addr_r) > 0 || pxe_mac_path((void *)pxefile_addr_r) > 0 - || pxe_ipaddr_paths((void *)pxefile_addr_r) > 0 - || get_pxelinux_path("default", (void *)pxefile_addr_r) > 0) { + || pxe_ipaddr_paths((void *)pxefile_addr_r) > 0) {
printf("Config file found\n");
return 0; }
+ while (pxe_default_paths[i]) { + if (get_pxelinux_path(pxe_default_paths[i], (void *)pxefile_addr_r) > 0) { + printf("Config file found\n"); + return 0; + } + i++; + } + printf("Config file not found\n");
return 1;

From: Rob Herring rob.herring@calxeda.com
Add ipappend support to pass network device information to the kernel.
Signed-off-by: Rob Herring rob.herring@calxeda.com --- common/cmd_pxe.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index f834d31..893cabc 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -450,6 +450,7 @@ struct pxe_label { char *append; char *initrd; char *fdt; + int ipappend; int attempted; int localboot; int localboot_val; @@ -583,7 +584,11 @@ static int label_boot(struct pxe_label *label) { char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL }; char initrd_str[22]; + char mac_str[29] = ""; + char ip_str[68] = ""; + char *bootargs; int bootm_argc = 3; + int len = 0;
label_print(label);
@@ -622,9 +627,39 @@ static int label_boot(struct pxe_label *label) return 1; }
- if (label->append) { - setenv("bootargs", label->append); - printf("append: %s\n", label->append); + if (label->ipappend & 0x1) { + sprintf(ip_str, " ip=%s:%s:%s:%s", + getenv("ipaddr"), getenv("serverip"), + getenv("gatewayip"), getenv("netmask")); + len += strlen(ip_str); + } + + if (label->ipappend & 0x2) { + int err; + strcpy(mac_str, " BOOTIF="); + err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); + if (err < 0) + mac_str[0] = '\0'; + len += strlen(mac_str); + } + + if (label->append) + len += strlen(label->append); + + if (len) { + bootargs = malloc(len + 1); + if (!bootargs) + return 1; + bootargs[0] ='\0'; + if (label->append) + strcpy(bootargs, label->append); + strcat(bootargs, ip_str); + strcat(bootargs, mac_str); + + setenv("bootargs", bootargs); + printf("append: %s\n", bootargs); + + free(bootargs); }
bootm_argv[1] = getenv("kernel_addr_r"); @@ -686,6 +721,7 @@ enum token_type { T_INCLUDE, T_FDT, T_ONTIMEOUT, + T_IPAPPEND, T_INVALID };
@@ -715,6 +751,7 @@ static const struct token keywords[] = { {"include", T_INCLUDE}, {"fdt", T_FDT}, {"ontimeout", T_ONTIMEOUT,}, + {"ipappend", T_IPAPPEND,}, {NULL, T_INVALID} };
@@ -1106,6 +1143,10 @@ static int parse_label(char **c, struct pxe_menu *cfg) err = parse_integer(c, &label->localboot_val); break;
+ case T_IPAPPEND: + err = parse_integer(c, &label->ipappend); + break; + case T_EOL: break;

On Sun, Dec 2, 2012 at 9:00 PM, Rob Herring robherring2@gmail.com wrote:
From: Rob Herring rob.herring@calxeda.com
This is a series of various enhancements and fixes for u-boot pxe support. These patches are a result of testing with server side tools like Cobbler and ubuntu MAAS.
Rob
Rob Herring (10): pxe: Use ethact setting for pxe pxe: make string parameters const pxe: fix handling of different localboot values bootz: un-staticize do_bootz pxe: use bootz instead of bootm when enabled pxe: always display a menu when present pxe: simplify menu display and selection pxe: add support for ontimeout token pxe: add support for per arch and SoC default paths pxe: add ipappend support
common/cmd_bootm.c | 2 +- common/cmd_pxe.c | 210 ++++++++++++++++++++++++++++++++-------------------- include/command.h | 2 + 3 files changed, 132 insertions(+), 82 deletions(-)
Is someone going to pick these patches up? The single comment by Wolfgang I've addressed.
Rob

Hi Rob,
On Tue, May 14, 2013 at 2:48 PM, Rob Herring robherring2@gmail.com wrote:
On Sun, Dec 2, 2012 at 9:00 PM, Rob Herring robherring2@gmail.com wrote:
From: Rob Herring rob.herring@calxeda.com
This is a series of various enhancements and fixes for u-boot pxe support. These patches are a result of testing with server side tools like Cobbler and ubuntu MAAS.
Rob
Rob Herring (10): pxe: Use ethact setting for pxe pxe: make string parameters const pxe: fix handling of different localboot values bootz: un-staticize do_bootz pxe: use bootz instead of bootm when enabled pxe: always display a menu when present pxe: simplify menu display and selection pxe: add support for ontimeout token pxe: add support for per arch and SoC default paths pxe: add ipappend support
common/cmd_bootm.c | 2 +- common/cmd_pxe.c | 210 ++++++++++++++++++++++++++++++++-------------------- include/command.h | 2 + 3 files changed, 132 insertions(+), 82 deletions(-)
Is someone going to pick these patches up? The single comment by Wolfgang I've addressed.
Yes... I'll pick these up... apologies for the delays.
-Joe

On Tue, May 14, 2013 at 3:32 PM, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Rob,
On Tue, May 14, 2013 at 2:48 PM, Rob Herring robherring2@gmail.com wrote:
On Sun, Dec 2, 2012 at 9:00 PM, Rob Herring robherring2@gmail.com wrote:
From: Rob Herring rob.herring@calxeda.com
This is a series of various enhancements and fixes for u-boot pxe support. These patches are a result of testing with server side tools like Cobbler and ubuntu MAAS.
Rob
Rob Herring (10): pxe: Use ethact setting for pxe pxe: make string parameters const pxe: fix handling of different localboot values bootz: un-staticize do_bootz pxe: use bootz instead of bootm when enabled pxe: always display a menu when present pxe: simplify menu display and selection pxe: add support for ontimeout token pxe: add support for per arch and SoC default paths pxe: add ipappend support
common/cmd_bootm.c | 2 +- common/cmd_pxe.c | 210 ++++++++++++++++++++++++++++++++-------------------- include/command.h | 2 + 3 files changed, 132 insertions(+), 82 deletions(-)
Is someone going to pick these patches up? The single comment by Wolfgang I've addressed.
Yes... I'll pick these up... apologies for the delays.
When can I expect to see these land?
Rob

Hi Rob,
On Sun, Jun 16, 2013 at 10:24 AM, Rob Herring robherring2@gmail.com wrote:
On Tue, May 14, 2013 at 3:32 PM, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Rob,
On Tue, May 14, 2013 at 2:48 PM, Rob Herring robherring2@gmail.com wrote:
On Sun, Dec 2, 2012 at 9:00 PM, Rob Herring robherring2@gmail.com wrote:
From: Rob Herring rob.herring@calxeda.com
This is a series of various enhancements and fixes for u-boot pxe support. These patches are a result of testing with server side tools like Cobbler and ubuntu MAAS.
Rob
Rob Herring (10): pxe: Use ethact setting for pxe pxe: make string parameters const pxe: fix handling of different localboot values bootz: un-staticize do_bootz pxe: use bootz instead of bootm when enabled pxe: always display a menu when present pxe: simplify menu display and selection pxe: add support for ontimeout token pxe: add support for per arch and SoC default paths pxe: add ipappend support
common/cmd_bootm.c | 2 +- common/cmd_pxe.c | 210 ++++++++++++++++++++++++++++++++-------------------- include/command.h | 2 + 3 files changed, 132 insertions(+), 82 deletions(-)
Is someone going to pick these patches up? The single comment by Wolfgang I've addressed.
Yes... I'll pick these up... apologies for the delays.
When can I expect to see these land?
I've got these patches in my local repo and I'm build testing them.
I'll likely send a PR by the end of today or tomorrow.
-Joe

Hi Rob,
On Sun, Jun 16, 2013 at 9:29 PM, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Rob,
On Sun, Jun 16, 2013 at 10:24 AM, Rob Herring robherring2@gmail.com wrote:
On Tue, May 14, 2013 at 3:32 PM, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Rob,
On Tue, May 14, 2013 at 2:48 PM, Rob Herring robherring2@gmail.com wrote:
On Sun, Dec 2, 2012 at 9:00 PM, Rob Herring robherring2@gmail.com wrote:
From: Rob Herring rob.herring@calxeda.com
This is a series of various enhancements and fixes for u-boot pxe support. These patches are a result of testing with server side tools like Cobbler and ubuntu MAAS.
Rob
Rob Herring (10): pxe: Use ethact setting for pxe pxe: make string parameters const pxe: fix handling of different localboot values bootz: un-staticize do_bootz pxe: use bootz instead of bootm when enabled pxe: always display a menu when present pxe: simplify menu display and selection pxe: add support for ontimeout token pxe: add support for per arch and SoC default paths pxe: add ipappend support
common/cmd_bootm.c | 2 +- common/cmd_pxe.c | 210 ++++++++++++++++++++++++++++++++-------------------- include/command.h | 2 + 3 files changed, 132 insertions(+), 82 deletions(-)
Is someone going to pick these patches up? The single comment by Wolfgang I've addressed.
Yes... I'll pick these up... apologies for the delays.
When can I expect to see these land?
I've got these patches in my local repo and I'm build testing them.
I'll likely send a PR by the end of today or tomorrow.
-Joe
I ran into some build failures on some boards from some of the patches so I'm working on fixing them.
-Joe
participants (3)
-
Joe Hershberger
-
Rob Herring
-
Wolfgang Denk