Skip to contentSkip to conversation

PXE parsing fixes and local file support

PATCH New Rob Herring 3 participants 22 messages Mar 28, 2012 – Jun 21, 2012

lore
Share & tools
lore
#0 lore raw

cover PXE parsing fixes and local file support

From: Rob Herring <[email protected]>

The first 6 patches are menu file parsing fixes found in testing ubuntu/ debian generated menu files. The menu display is cleaned up to display the friendly menu label string and boot the default image on timeout as is typical for a PC bootloader.

The last patch adds support for parsing local disk files on ext2 or fat filesystems. This is essentially syslinux/extlinux emulation and simply reuses the existing pxe support.

Rob

Rob Herring (7):
menu: only timeout when menu is displayed
pxe: support include files at top-level
pxe: add support for label menu text
pxe: support linux entries for labels
pxe: support absolute paths
pxe: parse initrd file from append string
pxe: add support for parsing local syslinux files

 common/cmd_pxe.c |  198 +++++++++++++++++++++++++++++++++++++++++++++++-------
 common/menu.c    |   36 +---------
 doc/README.pxe   |    3 -
 include/common.h |    6 ++
 4 files changed, 184 insertions(+), 59 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/7 menu: only timeout when menu is displayed

From: Rob Herring <[email protected]>

Make the menu timeout apply only when prompt flag is set and after the menu is displayed. This allows auto boot to work no matter whether prompt is set or cleared. Use the default selection if the menu times out.

This also fixes the timeout value given to readline_into_buffer to be seconds instead of 10th of seconds.

Old behavior:

if prompt
display menu and wait for choice
else
wait for timeout
if key pressed
display menu and wait for choice
else
exit command

New behavior:

if prompt
display menu
if key pressed
wait for choice
else
boot default entry on timeout
else
boot default entry

---
 common/menu.c |   36 ++++--------------------------------
 1 files changed, 4 insertions(+), 32 deletions(-)
common/menu.c +4 -32
index aa16c9a..6b2a2db 100644
@@ -171,32 +171,6 @@ static inline struct menu_item *menu_item_by_key(struct menu *m,
 }
 
 /*
- * Wait for the user to hit a key according to the timeout set for the menu.
- * Returns 1 if the user hit a key, or 0 if the timeout expired.
- */
-static inline int menu_interrupted(struct menu *m)
-{
-	if (!m->timeout)
-		return 0;
-
-	if (abortboot(m->timeout/10))
-		return 1;
-
-	return 0;
-}
-
-/*
- * Checks whether or not the default menu item should be used without
- * prompting for a user choice. If the menu is set to always prompt, or the
- * user hits a key during the timeout period, return 0. Otherwise, return 1 to
- * indicate we should use the default menu item.
- */
-static inline int menu_use_default(struct menu *m)
-{
-	return !m->prompt && !menu_interrupted(m);
-}
-
-/*
  * Set *choice to point to the default item's data, if any default item was
  * set, and returns 1. If no default item was set, returns -ENOENT.
  */
@@ -231,7 +205,7 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 		menu_display(m);
 
 		readret = readline_into_buffer("Enter choice: ", cbuf,
-				m->timeout);
+				m->timeout / 10);
 
 		if (readret >= 0) {
 			choice_item = menu_item_by_key(m, cbuf);
@@ -240,10 +214,8 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 				printf("%s not found\n", cbuf);
 				m->timeout = 0;
 			}
-		} else {
-			puts("^C\n");
-			return -EINTR;
-		}
+		} else
+			return menu_default_choice(m, choice);
 	}
 
 	*choice = choice_item->data;
@@ -300,7 +272,7 @@ int menu_get_choice(struct menu *m, void **choice)
 	if (!m || !choice)
 		return -EINVAL;
 
-	if (menu_use_default(m))
+	if (!m->prompt)
 		return menu_default_choice(m, choice);
 
 	return menu_interactive_choice(m, choice);
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 1/7 menu: only timeout when menu is displayed

Dear Rob Herring,

Quoted 31 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

Make the menu timeout apply only when prompt flag is set and after the menu is displayed. This allows auto boot to work no matter whether prompt is set or cleared. Use the default selection if the menu times out.

This also fixes the timeout value given to readline_into_buffer to be seconds instead of 10th of seconds.

Old behavior:

if prompt
display menu and wait for choice
else
wait for timeout
if key pressed
display menu and wait for choice
else
exit command

New behavior:

if prompt
display menu
if key pressed
wait for choice
else
boot default entry on timeout
else
boot default entry

Quoted 4 lines
---
 common/menu.c |   36 ++++--------------------------------
 1 files changed, 4 insertions(+), 32 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
We fight only when there is no other choice. We prefer  the  ways  of
peaceful contact.
	-- Kirk, "Spectre of the Gun", stardate 4385.3
#3 lore raw

PATCH 2/7 pxe: support include files at top-level

In reply to Rob Herring

From: Rob Herring <[email protected]>

Include files outside of a menu were not getting included and parsed.

---
 common/cmd_pxe.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
common/cmd_pxe.c +5 -0
index 8a68fa1..25054ba 100644
@@ -1110,6 +1110,11 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level)
 
 			break;
 
+		case T_INCLUDE:
+			err = handle_include(&p, b + strlen(b) + 1, cfg,
+							nest_level + 1);
+			break;
+
 		case T_PROMPT:
 			err = parse_integer(&p, &cfg->prompt);
 			break;
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH v2 1/1 pxe: support include files at top-level

From: Rob Herring <[email protected]>

Include files outside of a menu were not getting included and parsed.

---
v2:
- ensure include file load address is aligned

 common/cmd_pxe.c |    5 +++++
 1 file changed, 5 insertions(+)
common/cmd_pxe.c +5 -0
index b3c1f67..5949b24 100644
@@ -1110,6 +1110,11 @@ static int parse_pxefile_top(char *p, struct pxe_menu *cfg, int nest_level)
 
 			break;
 
+		case T_INCLUDE:
+			err = handle_include(&p, b + ALIGN(strlen(b), 4), cfg,
+							nest_level + 1);
+			break;
+
 		case T_PROMPT:
 			err = parse_integer(&p, &cfg->prompt);
 			break;
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v2 1/1 pxe: support include files at top-level

Dear Rob Herring,

Quoted 11 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

Include files outside of a menu were not getting included and parsed.

---
v2:
- ensure include file load address is aligned

 common/cmd_pxe.c |    5 +++++
 1 file changed, 5 insertions(+)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Imagination is more important than knowledge.      -- Albert Einstein
#6 lore raw

PATCH 3/7 pxe: add support for label menu text

In reply to Rob Herring

From: Rob Herring <[email protected]>

Use a menu string if present, otherwise use the kernel string.

---
 common/cmd_pxe.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
common/cmd_pxe.c +9 -4
index 25054ba..2497b73 100644
@@ -409,6 +409,7 @@ static int get_relfile_envaddr(char *file_path, char *envaddr_name)
  */
 struct pxe_label {
 	char *name;
+	char *menu;
 	char *kernel;
 	char *append;
 	char *initrd;
@@ -491,17 +492,18 @@ 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;
 
-	printf("Label: %s\n", label->name);
+	printf("%s:\t%s\n", label->name, c);
 
 	if (label->kernel)
-		printf("\tkernel: %s\n", label->kernel);
+		printf("\t\tkernel: %s\n", label->kernel);
 
 	if (label->append)
-		printf("\tappend: %s\n", label->append);
+		printf("\t\tappend: %s\n", label->append);
 
 	if (label->initrd)
-		printf("\tinitrd: %s\n", label->initrd);
+		printf("\t\tinitrd: %s\n", label->initrd);
 }
 
 /*
@@ -970,6 +972,9 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg,
 			return -ENOMEM;
 
 		break;
+	case T_LABEL:
+		parse_sliteral(c, &label->menu);
+		break;
 	default:
 		printf("Ignoring malformed menu command: %.*s\n",
 				(int)(*c - s), s);
Signature · 1 line
1.7.5.4
#7 lore raw

PATCH 3/7 pxe: add support for label menu text

Dear Rob Herring,

Quoted 8 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

Use a menu string if present, otherwise use the kernel string.

---
 common/cmd_pxe.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The ultimate barrier is one's viewpoint.
                        - Terry Pratchett, _The Dark Side of the Sun_
#8 lore raw

PATCH 4/7 pxe: support linux entries for labels

In reply to Rob Herring

From: Rob Herring <[email protected]>

Kernels can be specified using "linux" or "kernel" entry. The difference is kernel is supposed to detect the type of file, but for u-boot both are treated the same.

---
 common/cmd_pxe.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
common/cmd_pxe.c +3 -0
index 2497b73..b8cb4f3 100644
@@ -628,6 +628,7 @@ enum token_type {
 	T_TIMEOUT,
 	T_LABEL,
 	T_KERNEL,
+	T_LINUX,
 	T_APPEND,
 	T_INITRD,
 	T_LOCALBOOT,
@@ -656,6 +657,7 @@ static const struct token keywords[] = {
 	{"prompt", T_PROMPT},
 	{"label", T_LABEL},
 	{"kernel", T_KERNEL},
+	{"linux", T_LINUX},
 	{"localboot", T_LOCALBOOT},
 	{"append", T_APPEND},
 	{"initrd", T_INITRD},
@@ -1024,6 +1026,7 @@ static int parse_label(char **c, struct pxe_menu *cfg)
 			break;
 
 		case T_KERNEL:
+		case T_LINUX:
 			err = parse_sliteral(c, &label->kernel);
 			break;
 
Signature · 1 line
1.7.5.4
#9 lore raw

PATCH 4/7 pxe: support linux entries for labels

Dear Rob Herring,

Quoted 10 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

Kernels can be specified using "linux" or "kernel" entry. The difference is kernel is supposed to detect the type of file, but for u-boot both are treated the same.

---
 common/cmd_pxe.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A stone was placed at a ford in a river with the inscription:
"When this stone is covered it is dangerous to ford here."
#10 lore raw

PATCH 5/7 pxe: support absolute paths

In reply to Rob Herring

From: Rob Herring <[email protected]>

If the file path starts with a '/', then don't pre-pend the bootfile path. This fixes a problem with running 'pxe boot' multiple times where the bootfile path gets pre-pended to itself each time.

---
 common/cmd_pxe.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
common/cmd_pxe.c +12 -11
index b8cb4f3..ac1bc56 100644
@@ -96,24 +96,24 @@ static int format_mac_pxe(char *outbuf, size_t outbuf_len)
  * in. If bootfile isn't defined in the environment, return NULL, which should
  * be interpreted as "don't prepend anything to paths".
  */
-static int get_bootfile_path(char *bootfile_path, size_t bootfile_path_size)
+static int get_bootfile_path(const char *file_path, char *bootfile_path,
+			     size_t bootfile_path_size)
 {
 	char *bootfile, *last_slash;
-	size_t path_len;
+	size_t path_len = 0;
+
+	if (file_path[0] == '/')
+		goto ret;
 
 	bootfile = from_env("bootfile");
 
-	if (!bootfile) {
-		bootfile_path[0] = '\0';
-		return 1;
-	}
+	if (!bootfile)
+		goto ret;
 
 	last_slash = strrchr(bootfile, '/');
 
-	if (last_slash == NULL) {
-		bootfile_path[0] = '\0';
-		return 1;
-	}
+	if (last_slash == NULL)
+		goto ret;
 
 	path_len = (last_slash - bootfile) + 1;
 
@@ -126,6 +126,7 @@ static int get_bootfile_path(char *bootfile_path, size_t bootfile_path_size)
 
 	strncpy(bootfile_path, bootfile, path_len);
 
+ ret:
 	bootfile_path[path_len] = '\0';
 
 	return 1;
@@ -147,7 +148,7 @@ static int get_relfile(char *file_path, void *file_addr)
 	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
 	int err;
 
-	err = get_bootfile_path(relfile, sizeof(relfile));
+	err = get_bootfile_path(file_path, relfile, sizeof(relfile));
 
 	if (err < 0)
 		return err;
Signature · 1 line
1.7.5.4
#11 lore raw

PATCH 5/7 pxe: support absolute paths

Dear Rob Herring,

Quoted 10 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

If the file path starts with a '/', then don't pre-pend the bootfile path. This fixes a problem with running 'pxe boot' multiple times where the bootfile path gets pre-pended to itself each time.

---
 common/cmd_pxe.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Pain is a thing of the mind.  The mind can be controlled.
	-- Spock, "Operation -- Annihilate!" stardate 3287.2
#12 lore raw

PATCH 6/7 pxe: parse initrd file from append string

In reply to Rob Herring

From: Rob Herring <[email protected]>

For syslinux, the initrd can be set in the append string as "initrd=<file>", so try to find it there if we haven't already set the initrd.

---
 common/cmd_pxe.c |   15 ++++++++++++++-
 doc/README.pxe   |    3 ---
 2 files changed, 14 insertions(+), 4 deletions(-)
common/cmd_pxe.c +14 -1
index ac1bc56..4ad067a 100644
@@ -999,6 +999,7 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg,
 static int parse_label(char **c, struct pxe_menu *cfg)
 {
 	struct token t;
+	int len;
 	char *s = *c;
 	struct pxe_label *label;
 	int err;
@@ -1033,10 +1034,22 @@ static int parse_label(char **c, struct pxe_menu *cfg)
 
 		case T_APPEND:
 			err = parse_sliteral(c, &label->append);
+			if (label->initrd)
+				break;
+			s = strstr(label->append, "initrd=");
+			if (!s)
+				break;
+			s += 7;
+			len = (int)(strchr(s, ' ') - s);
+			label->initrd = malloc(len + 1);
+			strncpy(label->initrd, s, len);
+			label->initrd[len] = '\0';
+
 			break;
 
 		case T_INITRD:
-			err = parse_sliteral(c, &label->initrd);
+			if (!label->initrd)
+				err = parse_sliteral(c, &label->initrd);
 			break;
 
 		case T_LOCALBOOT:
doc/README.pxe +0 -3
index 95cd9b9..2bbf53d 100644
@@ -224,9 +224,6 @@ PXELINUX and U-boot's pxe support.
 - U-boot's pxe expects U-boot uimg's as kernels.  Anything that would work
   with the 'bootm' command in U-boot could work with the 'pxe boot' command.
 
-- U-boot's pxe doesn't recognize initrd options in the append command - you
-  must specify initrd files using the initrd command.
-
 - U-boot's pxe only recognizes a single file on the initrd command line.  It
   could be extended to support multiple.
 
Signature · 1 line
1.7.5.4
#13 lore raw

PATCH 6/7 pxe: parse initrd file from append string

Dear Rob Herring,

Quoted 11 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

For syslinux, the initrd can be set in the append string as "initrd=<file>", so try to find it there if we haven't already set the initrd.

---
 common/cmd_pxe.c |   15 ++++++++++++++-
 doc/README.pxe   |    3 ---
 2 files changed, 14 insertions(+), 4 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
First study the enemy.  Seek weakness.
	-- Romulan Commander, "Balance of Terror", stardate 1709.2
#14 lore raw

PATCH 7/7 pxe: add support for parsing local syslinux files

In reply to Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

---
 common/cmd_pxe.c |  139 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 include/common.h |    6 ++
 2 files changed, 137 insertions(+), 8 deletions(-)
common/cmd_pxe.c +131 -8
index 4ad067a..82b0a8e 100644
@@ -132,6 +132,49 @@ 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_get_tftp(char *file_path, char *file_addr)
+{
+	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
+
+	tftp_argv[1] = file_addr;
+	tftp_argv[2] = file_path;
+
+	if (do_tftpb(NULL, 0, 3, tftp_argv))
+		return -ENOENT;
+
+	return 1;
+}
+
+static char *fs_argv[5];
+
+static int do_get_ext2(char *file_path, char *file_addr)
+{
+	fs_argv[0] = "ext2load";
+	fs_argv[3] = file_addr;
+	fs_argv[4] = file_path;
+
+	if (do_ext2load(NULL, 0, 5, fs_argv))
+		return -ENOENT;
+
+	return 1;
+}
+
+static int do_get_fat(char *file_path, char *file_addr)
+{
+	fs_argv[0] = "fatload";
+	fs_argv[3] = file_addr;
+	fs_argv[4] = file_path;
+
+	if (do_fat_fsload(NULL, 0, 5, fs_argv))
+		return -ENOENT;
+
+	return 1;
+}
+
+
+
 /*
  * As in pxelinux, paths to files referenced from files we retrieve are
  * relative to the location of bootfile. get_relfile takes such a path and
@@ -145,7 +188,6 @@ static int get_relfile(char *file_path, void *file_addr)
 	size_t path_len;
 	char relfile[MAX_TFTP_PATH_LEN+1];
 	char addr_buf[10];
-	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
 	int err;
 
 	err = get_bootfile_path(file_path, relfile, sizeof(relfile));
@@ -170,13 +212,7 @@ static int get_relfile(char *file_path, void *file_addr)
 
 	sprintf(addr_buf, "%p", file_addr);
 
-	tftp_argv[1] = addr_buf;
-	tftp_argv[2] = relfile;
-
-	if (do_tftpb(NULL, 0, 3, tftp_argv))
-		return -ENOENT;
-
-	return 1;
+	return do_getfile(relfile, addr_buf);
 }
 
 /*
@@ -322,6 +358,8 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	void *pxefile_addr_r;
 	int err;
 
+	do_getfile = do_get_tftp;
+
 	if (argc != 1)
 		return CMD_RET_USAGE;
 
@@ -1331,6 +1369,8 @@ do_pxe_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	struct pxe_menu *cfg;
 	char *pxefile_addr_str;
 
+	do_getfile = do_get_tftp;
+
 	if (argc == 1) {
 		pxefile_addr_str = from_env("pxefile_addr_r");
 		if (!pxefile_addr_str)
@@ -1391,3 +1431,86 @@ U_BOOT_CMD(
 	"get - try to retrieve a pxe file using tftp\npxe "
 	"boot [pxefile_addr_r] - boot from the pxe file at pxefile_addr_r\n"
 );
+
+/*
+ * Boots a system using a local disk syslinux/extlinux file
+ *
+ * Returns 0 on success, 1 on error.
+ */
+int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	unsigned long pxefile_addr_r;
+	struct pxe_menu *cfg;
+	char *pxefile_addr_str;
+	char *filename;
+	int prompt = 0;
+
+	if (strstr(argv[1], "-p")) {
+		prompt = 1;
+		argc--;
+		argv++;
+	}
+
+	if (argc < 4)
+		return cmd_usage(cmdtp);
+
+	if (argc < 5) {
+		pxefile_addr_str = from_env("pxefile_addr_r");
+		if (!pxefile_addr_str)
+			return 1;
+	} else {
+		pxefile_addr_str = argv[4];
+	}
+
+	if (argc < 6)
+		filename = getenv("bootfile");
+	else {
+		filename = argv[5];
+		setenv("bootfile", filename);
+	}
+
+	if (strstr(argv[3], "ext2"))
+		do_getfile = do_get_ext2;
+	else if (strstr(argv[3], "fat"))
+		do_getfile = do_get_fat;
+	else {
+		printf("Invalid filesystem: %s\n", argv[3]);
+		return 1;
+	}
+	fs_argv[1] = argv[1];
+	fs_argv[2] = argv[2];
+
+	if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) {
+		printf("Invalid pxefile address: %s\n", pxefile_addr_str);
+		return 1;
+	}
+
+	if (get_pxe_file(filename, (void *)pxefile_addr_r) < 0) {
+		printf("Error reading config file\n");
+		return 1;
+	}
+
+	cfg = parse_pxefile((char *)(pxefile_addr_r));
+
+	if (cfg == NULL) {
+		printf("Error parsing config file\n");
+		return 1;
+	}
+
+	if (prompt)
+		cfg->prompt = 1;
+
+	handle_pxe_menu(cfg);
+
+	destroy_pxe_menu(cfg);
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	sysboot, 7, 1, do_sysboot,
+	"command to get and boot from syslinux files",
+	"[-p] <interface> <dev[:part]> <ext2|fat> [addr] [filename]\n"
+	"    - load and parse syslinux menu file 'filename' from ext2 or fat\n"
+	"      filesystem on 'dev' on 'interface' to address 'addr'"
+);
include/common.h +6 -0
index 74d9704..67029b8 100644
@@ -307,6 +307,12 @@ void	doc_probe(unsigned long physadr);
 /* common/cmd_net.c */
 int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
+/* common/cmd_fat.c */
+int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
+
+/* common/cmd_ext2.c */
+int do_ext2load(cmd_tbl_t *, int, int, char * const []);
+
 /* common/cmd_nvedit.c */
 int	env_init     (void);
 void	env_relocate (void);
Signature · 1 line
1.7.5.4
#15 lore raw

PATCH 7/7 pxe: add support for parsing local syslinux files

Hi Rob,

Quoted 7 lines · Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

I attempted to apply this patch but it failed.

Applying: pxe: add support for parsing local syslinux files
error: patch failed: common/cmd_pxe.c:322
error: common/cmd_pxe.c: patch does not apply
fatal: sha1 information is lacking or useless (common/cmd_pxe.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0007.

Please rebase the series and resend.

Thanks,
-Joe

#16 lore raw

PATCH 7/7 pxe: add support for parsing local syslinux files

Quoted 21 lines · Joe Hershberger

Hi Rob,

Quoted 7 lines · Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

I attempted to apply this patch but it failed.

Applying: pxe: add support for parsing local syslinux files
error: patch failed: common/cmd_pxe.c:322
error: common/cmd_pxe.c: patch does not apply
fatal: sha1 information is lacking or useless (common/cmd_pxe.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0007.

Quoted 1 line

Please rebase the series and resend.

I rebased to Wolfgang's current master without any conflicts, so I'm puzzled why this failed for you. I was originally based on this commit plus a few otherwise unrelated highbank fixes:

commit 7cb30b13f12077c7eec8ce2419cd96cd65ace8e2
Merge: 636f77a 85c344e
Author: Wolfgang Denk <[email protected]>
Date: Fri Mar 23 21:59:16 2012 +0100

Merge branch 'master' of git://git.denx.de/u-boot-cfi-flash

* 'master' of git://git.denx.de/u-boot-cfi-flash:
cfi: fix the incomplete erased status check in buffer write

What base were you applying these to?

Rob

#17 lore raw

PATCH 7/7 pxe: add support for parsing local syslinux files

Hi Rob,

Quoted 33 lines · Rob Herring
Quoted 21 lines · Joe Hershberger

Hi Rob,

Quoted 7 lines · Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

I attempted to apply this patch but it failed.

Applying: pxe: add support for parsing local syslinux files
error: patch failed: common/cmd_pxe.c:322
error: common/cmd_pxe.c: patch does not apply
fatal: sha1 information is lacking or useless (common/cmd_pxe.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0007.

Quoted 1 line

Please rebase the series and resend.

I rebased to Wolfgang's current master without any conflicts, so I'm puzzled why this failed for you. I was originally based on this commit plus a few otherwise unrelated highbank fixes:

commit 7cb30b13f12077c7eec8ce2419cd96cd65ace8e2
Merge: 636f77a 85c344e
Author: Wolfgang Denk <[email protected]>
Date: ? Fri Mar 23 21:59:16 2012 +0100

Quoted 6 lines

? ?Merge branch 'master' of git://git.denx.de/u-boot-cfi-flash

? ?* 'master' of git://git.denx.de/u-boot-cfi-flash:
? ? ?cfi: fix the incomplete erased status check in buffer write

What base were you applying these to?

I just tried again on u-boot.git/master...

Quoted 1 line

git checkout origin/master

Note: moving to "origin/master" which isn't a local branch If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at b86a475... MAKEALL: Report boards with errors vs warnings

Quoted 1 line

git am < bundle-2943.mbox

Applying: menu: only timeout when menu is displayed
Applying: pxe: support include files at top-level
Applying: pxe: add support for label menu text
Applying: pxe: support linux entries for labels
Applying: pxe: support absolute paths
Applying: pxe: parse initrd file from append string
Applying: pxe: add support for parsing local syslinux files
error: patch failed: common/cmd_pxe.c:322
error: common/cmd_pxe.c: patch does not apply
Patch failed@0007.
When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".

I'm attempting to apply these patches in patchwork:

http://patchwork.ozlabs.org/patch/149281/
http://patchwork.ozlabs.org/patch/149280/
http://patchwork.ozlabs.org/patch/149282/
http://patchwork.ozlabs.org/patch/149283/
http://patchwork.ozlabs.org/patch/149284/
http://patchwork.ozlabs.org/patch/149286/
http://patchwork.ozlabs.org/patch/149285/

in that order... is that incorrect?

Thanks
-Joe

#18 lore raw

PATCH 7/7 pxe: add support for parsing local syslinux files

Hi Rob,

Quoted 77 lines · Joe Hershberger

Hi Rob,

Quoted 33 lines · Rob Herring
Quoted 21 lines · Joe Hershberger

Hi Rob,

Quoted 7 lines · Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

I attempted to apply this patch but it failed.

Applying: pxe: add support for parsing local syslinux files
error: patch failed: common/cmd_pxe.c:322
error: common/cmd_pxe.c: patch does not apply
fatal: sha1 information is lacking or useless (common/cmd_pxe.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0007.

Quoted 1 line

Please rebase the series and resend.

I rebased to Wolfgang's current master without any conflicts, so I'm puzzled why this failed for you. I was originally based on this commit plus a few otherwise unrelated highbank fixes:

commit 7cb30b13f12077c7eec8ce2419cd96cd65ace8e2
Merge: 636f77a 85c344e
Author: Wolfgang Denk <[email protected]>
Date: ? Fri Mar 23 21:59:16 2012 +0100

Quoted 6 lines

? ?Merge branch 'master' of git://git.denx.de/u-boot-cfi-flash

? ?* 'master' of git://git.denx.de/u-boot-cfi-flash:
? ? ?cfi: fix the incomplete erased status check in buffer write

What base were you applying these to?

I just tried again on u-boot.git/master...

Quoted 1 line

git checkout origin/master

Note: moving to "origin/master" which isn't a local branch If you want to create a new branch from this checkout, you may do so (now or later) by using -b with the checkout command again. Example:
?git checkout -b <new_branch_name>
HEAD is now at b86a475... MAKEALL: Report boards with errors vs warnings

Quoted 1 line

git am < bundle-2943.mbox

Applying: menu: only timeout when menu is displayed
Applying: pxe: support include files at top-level
Applying: pxe: add support for label menu text
Applying: pxe: support linux entries for labels
Applying: pxe: support absolute paths
Applying: pxe: parse initrd file from append string
Applying: pxe: add support for parsing local syslinux files
error: patch failed: common/cmd_pxe.c:322
error: common/cmd_pxe.c: patch does not apply
Patch failed at 0007.
When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".

I'm attempting to apply these patches in patchwork:

http://patchwork.ozlabs.org/patch/149281/
http://patchwork.ozlabs.org/patch/149280/
http://patchwork.ozlabs.org/patch/149282/
http://patchwork.ozlabs.org/patch/149283/
http://patchwork.ozlabs.org/patch/149284/
http://patchwork.ozlabs.org/patch/149286/
http://patchwork.ozlabs.org/patch/149285/

Quoted 4 lines

in that order... is that incorrect?

Thanks
-Joe

Any luck figuring out why the patch at
http://patchwork.ozlabs.org/patch/149285/ will not apply? Perhaps just rebase (since that works for you) and resend.

Thanks,
-Joe

#19 lore raw

PATCH v2 1/1 pxe: add support for parsing local syslinux files

In reply to Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

---
v2:
- rebase to current mainline
- fix compile if ext2 or fat is disabled

 common/cmd_pxe.c |  141 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 include/common.h |    6 +++
 2 files changed, 139 insertions(+), 8 deletions(-)
common/cmd_pxe.c +133 -8
index 0fc863b..2b1115d 100644
@@ -132,6 +132,51 @@ 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_get_tftp(char *file_path, char *file_addr)
+{
+	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
+
+	tftp_argv[1] = file_addr;
+	tftp_argv[2] = file_path;
+
+	if (do_tftpb(NULL, 0, 3, tftp_argv))
+		return -ENOENT;
+
+	return 1;
+}
+
+static char *fs_argv[5];
+
+static int do_get_ext2(char *file_path, char *file_addr)
+{
+#ifdef CONFIG_CMD_EXT2
+	fs_argv[0] = "ext2load";
+	fs_argv[3] = file_addr;
+	fs_argv[4] = file_path;
+
+	if (!do_ext2load(NULL, 0, 5, fs_argv))
+		return 1;
+#endif
+	return -ENOENT;
+}
+
+static int do_get_fat(char *file_path, char *file_addr)
+{
+#ifdef CONFIG_CMD_FAT
+	fs_argv[0] = "fatload";
+	fs_argv[3] = file_addr;
+	fs_argv[4] = file_path;
+
+	if (!do_fat_fsload(NULL, 0, 5, fs_argv))
+		return 1;
+#endif
+	return -ENOENT;
+}
+
+
+
 /*
  * As in pxelinux, paths to files referenced from files we retrieve are
  * relative to the location of bootfile. get_relfile takes such a path and
@@ -145,7 +190,6 @@ static int get_relfile(char *file_path, void *file_addr)
 	size_t path_len;
 	char relfile[MAX_TFTP_PATH_LEN+1];
 	char addr_buf[10];
-	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
 	int err;
 
 	err = get_bootfile_path(file_path, relfile, sizeof(relfile));
@@ -170,13 +214,7 @@ static int get_relfile(char *file_path, void *file_addr)
 
 	sprintf(addr_buf, "%p", file_addr);
 
-	tftp_argv[1] = addr_buf;
-	tftp_argv[2] = relfile;
-
-	if (do_tftpb(NULL, 0, 3, tftp_argv))
-		return -ENOENT;
-
-	return 1;
+	return do_getfile(relfile, addr_buf);
 }
 
 /*
@@ -322,6 +360,8 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	unsigned long pxefile_addr_r;
 	int err;
 
+	do_getfile = do_get_tftp;
+
 	if (argc != 1)
 		return CMD_RET_USAGE;
 
@@ -1331,6 +1371,8 @@ do_pxe_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	struct pxe_menu *cfg;
 	char *pxefile_addr_str;
 
+	do_getfile = do_get_tftp;
+
 	if (argc == 1) {
 		pxefile_addr_str = from_env("pxefile_addr_r");
 		if (!pxefile_addr_str)
@@ -1391,3 +1433,86 @@ U_BOOT_CMD(
 	"get - try to retrieve a pxe file using tftp\npxe "
 	"boot [pxefile_addr_r] - boot from the pxe file at pxefile_addr_r\n"
 );
+
+/*
+ * Boots a system using a local disk syslinux/extlinux file
+ *
+ * Returns 0 on success, 1 on error.
+ */
+int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	unsigned long pxefile_addr_r;
+	struct pxe_menu *cfg;
+	char *pxefile_addr_str;
+	char *filename;
+	int prompt = 0;
+
+	if (strstr(argv[1], "-p")) {
+		prompt = 1;
+		argc--;
+		argv++;
+	}
+
+	if (argc < 4)
+		return cmd_usage(cmdtp);
+
+	if (argc < 5) {
+		pxefile_addr_str = from_env("pxefile_addr_r");
+		if (!pxefile_addr_str)
+			return 1;
+	} else {
+		pxefile_addr_str = argv[4];
+	}
+
+	if (argc < 6)
+		filename = getenv("bootfile");
+	else {
+		filename = argv[5];
+		setenv("bootfile", filename);
+	}
+
+	if (strstr(argv[3], "ext2"))
+		do_getfile = do_get_ext2;
+	else if (strstr(argv[3], "fat"))
+		do_getfile = do_get_fat;
+	else {
+		printf("Invalid filesystem: %s\n", argv[3]);
+		return 1;
+	}
+	fs_argv[1] = argv[1];
+	fs_argv[2] = argv[2];
+
+	if (strict_strtoul(pxefile_addr_str, 16, &pxefile_addr_r) < 0) {
+		printf("Invalid pxefile address: %s\n", pxefile_addr_str);
+		return 1;
+	}
+
+	if (get_pxe_file(filename, (void *)pxefile_addr_r) < 0) {
+		printf("Error reading config file\n");
+		return 1;
+	}
+
+	cfg = parse_pxefile((char *)(pxefile_addr_r));
+
+	if (cfg == NULL) {
+		printf("Error parsing config file\n");
+		return 1;
+	}
+
+	if (prompt)
+		cfg->prompt = 1;
+
+	handle_pxe_menu(cfg);
+
+	destroy_pxe_menu(cfg);
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	sysboot, 7, 1, do_sysboot,
+	"command to get and boot from syslinux files",
+	"[-p] <interface> <dev[:part]> <ext2|fat> [addr] [filename]\n"
+	"    - load and parse syslinux menu file 'filename' from ext2 or fat\n"
+	"      filesystem on 'dev' on 'interface' to address 'addr'"
+);
include/common.h +6 -0
index eb9de18..49b1f75 100644
@@ -325,6 +325,12 @@ void	doc_probe(unsigned long physadr);
 /* common/cmd_net.c */
 int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
+/* common/cmd_fat.c */
+int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
+
+/* common/cmd_ext2.c */
+int do_ext2load(cmd_tbl_t *, int, int, char * const []);
+
 /* common/cmd_nvedit.c */
 int	env_init     (void);
 void	env_relocate (void);
Signature · 1 line
1.7.9.5
#20 lore raw

PATCH v2 1/1 pxe: add support for parsing local syslinux files

Hi Rob,

Quoted 11 lines · Rob Herring

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

---
v2:
- rebase to current mainline
- fix compile if ext2 or fat is disabled

It applies now.

Thanks,
-Joe

#21 lore raw

PATCH v2 1/1 pxe: add support for parsing local syslinux files

In reply to Rob Herring

Dear Rob Herring,

Quoted 7 lines · In message <[email protected]> you wrote:

From: Rob Herring <[email protected]>

Add a new command "sysboot" which parses syslinux menu files and boots using kernel and initrd specified by menu files. The operation is similar to "pxe boot" except local files on ext2 or fat filesystem are parsed.

Quoted 8 lines

---
v2:
- rebase to current mainline
- fix compile if ext2 or fat is disabled

 common/cmd_pxe.c |  141 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 include/common.h |    6 +++
 2 files changed, 139 insertions(+), 8 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When a child is taught ... its programmed with simple instructions --
and at some point, if its mind develops properly, it exceeds the  sum
of what it was taught, thinks independently.
	-- Dr. Richard Daystrom, "The Ultimate Computer",
	   stardate 4731.3.