Skip to contentSkip to conversation

pxe: allow compilation when !defined(CONFIG_CMD_NET)

PATCH New Stephen Warren 3 participants 9 messages Feb 6, 2014 – Feb 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 pxe: allow compilation when !defined(CONFIG_CMD_NET)

pxe.c provides both the "pxe" command which relies on a network, and the "sysboot" command which doesn't. Fix the file to compile when network support isn't enabled. This is useful e.g. on the Raspberry Pi which has no network support yet, but will soon support the sysboot command.

---
v2: No change.

This patch doesn't appear to depend on anything much, but is needed by the rest of this series. Given the dependencies in the rest of this series, either (a) this one patch can be applied to u-boot/master, and then u-boot/arm can merge that in before the rest of the series, or (b) u-boot/master can be merged into u-boot-arm/master, then this whole series applied there.

---
 common/cmd_pxe.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
common/cmd_pxe.c +11 -0
index 29e48db..3d13268 100644
@@ -45,6 +45,7 @@ static char *from_env(const char *envvar)
 	return ret;
 }
 
+#ifdef CONFIG_CMD_NET
 /*
  * Convert an ethaddr from the environment to the format used by pxelinux
  * filenames based on mac addresses. Convert's ':' to '-', and adds "01-" to
@@ -75,6 +76,7 @@ static int format_mac_pxe(char *outbuf, size_t outbuf_len)
 
 	return 1;
 }
+#endif
 
 /*
  * Returns the directory the file specified in the bootfile env variable is
@@ -120,6 +122,7 @@ static int get_bootfile_path(const char *file_path, char *bootfile_path,
 
 static int (*do_getfile)(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr);
 
+#ifdef CONFIG_CMD_NET
 static int do_get_tftp(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
 {
 	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
@@ -132,6 +135,7 @@ static int do_get_tftp(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
 
 	return 1;
 }
+#endif
 
 static char *fs_argv[5];
 
@@ -249,6 +253,8 @@ static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr
 	return 1;
 }
 
+#ifdef CONFIG_CMD_NET
+
 #define PXELINUX_DIR "pxelinux.cfg/"
 
 /*
@@ -397,6 +403,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	return 1;
 }
+#endif
 
 /*
  * Wrapper to make it easier to store the file at file_path in the location
@@ -647,6 +654,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		len += strlen(ip_str);
 	}
 
+#ifdef CONFIG_CMD_NET
 	if (label->ipappend & 0x2) {
 		int err;
 		strcpy(mac_str, " BOOTIF=");
@@ -655,6 +663,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 			mac_str[0] = '\0';
 		len += strlen(mac_str);
 	}
+#endif
 
 	if (label->append)
 		len += strlen(label->append);
@@ -1500,6 +1509,7 @@ static void handle_pxe_menu(cmd_tbl_t *cmdtp, struct pxe_menu *cfg)
 	boot_unattempted_labels(cmdtp, cfg);
 }
 
+#ifdef CONFIG_CMD_NET
 /*
  * Boots a system using a pxe file
  *
@@ -1576,6 +1586,7 @@ 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"
 );
+#endif
 
 /*
  * Boots a system using a local disk syslinux/extlinux file
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/4 pxe: allow compilation when !defined(CONFIG_CMD_NET)

Quoted 4 lines · Stephen Warren

pxe.c provides both the "pxe" command which relies on a network, and the "sysboot" command which doesn't. Fix the file to compile when network support isn't enabled. This is useful e.g. on the Raspberry Pi which has no network support yet, but will soon support the sysboot command.

Albert, does this series look good? Everything it relies on should be in u-boot/master for a while now. Thanks.

#2 lore raw

PATCH v2 1/4 pxe: allow compilation when !defined(CONFIG_CMD_NET)

Hi Stephen,

Quoted 8 lines · Stephen Warren
Quoted 4 lines · Stephen Warren

pxe.c provides both the "pxe" command which relies on a network, and the "sysboot" command which doesn't. Fix the file to compile when network support isn't enabled. This is useful e.g. on the Raspberry Pi which has no network support yet, but will soon support the sysboot command.

Albert, does this series look good? Everything it relies on should be in u-boot/master for a while now. Thanks.

Series looks good, just waiting to be applied and tested.

Amicalement,

Signature · 1 line
Albert.
#3 lore raw

PATCH v2 1/4 pxe: allow compilation when !defined(CONFIG_CMD_NET)

Quoted 11 lines · Albert ARIBAUD

Hi Stephen,

Quoted 6 lines · Stephen Warren
Quoted 4 lines · Stephen Warren

pxe.c provides both the "pxe" command which relies on a network, and the "sysboot" command which doesn't. Fix the file to compile when network support isn't enabled. This is useful e.g. on the Raspberry Pi which has no network support yet, but will soon support the sysboot command.

Quoted 4 lines
Quoted 2 lines

Albert, does this series look good? Everything it relies on should be in u-boot/master for a while now. Thanks.

Series looks good, just waiting to be applied and tested.

Soon then please? Thanks! :)

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/20140221/c82b4794/attachment.pgp>
#4 lore raw

PATCH v2 2/4 ARM: rpi_b: convert to use distro defaults

In reply to Stephen Warren

Modify the rpi_b board to include the "distro defaults" header, so that all the config options distros expect are enabled. Remove any #defines that enable the same options from the rpi_b.h.

---
v2: No change.

Patches 2/4 and 4/4 depend on various patches in u-boot/master, so that will need to be merged into u-boot-arm/master if this series gets applied there. In particular, "config: add config_distro_defaults.h" and various patches before that are required.

---
 include/configs/rpi_b.h | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)
include/configs/rpi_b.h +13 -16
index 976ceaa..202c9c3 100644
@@ -147,37 +147,34 @@
 #define CONFIG_BOOTDELAY		2
 
 /* Shell */
-#define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_MAXARGS		8
 #define CONFIG_SYS_PROMPT		"U-Boot> "
-#define CONFIG_SYS_LONGHELP
-#define CONFIG_CMDLINE_EDITING
 #define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTO_COMPLETE
 
 /* Commands */
 #include <config_cmd_default.h>
-#define CONFIG_CMD_BOOTZ
 #define CONFIG_CMD_GPIO
 #define CONFIG_CMD_MMC
-#define CONFIG_DOS_PARTITION
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
-#define CONFIG_CMD_FS_GENERIC
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_EXT
-/* Some things don't make sense on this HW or yet */
-#undef CONFIG_CMD_FPGA
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
-#undef CONFIG_CMD_SAVEENV
 
-/* Device tree support for bootm/bootz */
-#define CONFIG_OF_LIBFDT
+/* Device tree support */
 #define CONFIG_OF_BOARD_SETUP
 /* ATAGs support for bootm/bootz */
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 
+#include <config_distro_defaults.h>
+
+/* Some things don't make sense on this HW or yet */
+#undef CONFIG_CMD_FPGA
+#undef CONFIG_CMD_NET
+#undef CONFIG_CMD_NFS
+#undef CONFIG_CMD_SAVEENV
+#undef CONFIG_CMD_DHCP
+#undef CONFIG_CMD_MII
+#undef CONFIG_CMD_NET
+#undef CONFIG_CMD_PING
+
 #endif
Signature · 1 line
1.8.3.2
#5 lore raw

PATCH v2 3/4 ARM: rpi_b: load /uEnv.txt from MMC at startup

In reply to Stephen Warren

The Pi has no flash to store an environment in the usual fashion. However, the user may wish to customize the environment. We know that the SD card must be present, since that's where the boot ROM has loaded U-Boot from. So, load uEnv.txt from there early during boot. This allows the user to e.g. customize boot_targets, in order to automatically select network boot.

---
v2: No change.

---
 include/configs/rpi_b.h | 5 +++++
 1 file changed, 5 insertions(+)
include/configs/rpi_b.h +5 -0
index 202c9c3..4b5a0c2 100644
@@ -95,6 +95,11 @@
 #define CONFIG_SYS_LOAD_ADDR		0x1000000
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
+#define CONFIG_PREBOOT \
+	"if load mmc 0:1 ${loadaddr} /uEnv.txt; then " \
+		"env import -t ${loadaddr} ${filesize}; " \
+	"fi"
+
 /*
  * Memory layout for where various images get loaded by boot scripts:
  *
Signature · 1 line
1.8.3.2
#6 lore raw

PATCH v2 1/4 pxe: allow compilation when !defined(CONFIG_CMD_NET)

In reply to Stephen Warren

Hi Stephen,

Quoted 9 lines · Stephen Warren

pxe.c provides both the "pxe" command which relies on a network, and the "sysboot" command which doesn't. Fix the file to compile when network support isn't enabled. This is useful e.g. on the Raspberry Pi which has no network support yet, but will soon support the sysboot command.

---
v2: No change.

Quoted 6 lines

This patch doesn't appear to depend on anything much, but is needed by the rest of this series. Given the dependencies in the rest of this series, either (a) this one patch can be applied to u-boot/master, and then u-boot/arm can merge that in before the rest of the series, or (b) u-boot/master can be merged into u-boot-arm/master, then this whole series applied there.

I'm ok with applying the series to u-boot-arm since it is 75% arm-specific and I prefer whole series to be applied in the same repo.

Amicalement,

Signature · 1 line
Albert.
#7 lore raw

PATCH v2 4/4 ARM: rpi_b: rework boot scripts, enable sysboot

In reply to Stephen Warren

Rework rpi_b's bootcmd (and sub-commands) to match Tegra's bootcmd as much as possible. This will aid in a future patch which will create a common header e.g. config_distro_bootcmd.h.

While at it, enable booting from extlinux.conf using the sysboot command.

The iteration and componentization currently makes a little more sense for Tegra than RPi, but I'd still like to keep the two as similar as possible. USB and networking support is coming to the RPi in due course, and it'll all make more sense then anyway.

---
v2:
* Replace ; in the middle of echo'd text in boot scripts.
* Add missing space between commands in boot scripts.

---
 include/configs/rpi_b.h | 87 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 72 insertions(+), 15 deletions(-)
include/configs/rpi_b.h +72 -15
index 4b5a0c2..68bb2b0 100644
@@ -100,12 +100,20 @@
 		"env import -t ${loadaddr} ${filesize}; " \
 	"fi"
 
+#define ENV_DEVICE_SETTINGS \
+	"stdin=serial,lcd\0" \
+	"stdout=serial,lcd\0" \
+	"stderr=serial,lcd\0"
+
 /*
  * Memory layout for where various images get loaded by boot scripts:
  *
  * scriptaddr can be pretty much anywhere that doesn't conflict with something
  *   else. Put it low in memory to avoid conflicts.
  *
+ * pxefile_addr_r can be pretty much anywhere that doesn't conflict with
+ *   something else. Put it low in memory to avoid conflicts.
+ *
  * kernel_addr_r must be within the first 128M of RAM in order for the
  *   kernel's CONFIG_AUTO_ZRELADDR option to work. Since the kernel will
  *   decompress itself to 0x8000 after the start of RAM, kernel_addr_r
@@ -121,35 +129,84 @@
  * ramdisk_addr_r simply shouldn't overlap anything else. Choosing 33M allows
  *   for the FDT/DTB to be up to 1M, which is hopefully plenty.
  */
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	"stdin=serial\0" \
-	"stderr=serial,lcd\0" \
-	"stdout=serial,lcd\0" \
+#define ENV_MEM_LAYOUT_SETTINGS \
 	"scriptaddr=0x00000000\0" \
+	"pxefile_addr_r=0x00100000\0" \
 	"kernel_addr_r=0x01000000\0" \
 	"fdt_addr_r=0x02000000\0" \
 	"fdtfile=bcm2835-rpi-b.dtb\0" \
 	"ramdisk_addr_r=0x02100000\0" \
-	"boot_targets=mmc0\0" \
-	\
-	"script_boot=" \
-		"if fatload ${devtype} ${devnum}:1 " \
-					"${scriptaddr} boot.scr.uimg; then " \
-			"source ${scriptaddr}; " \
-		"fi;\0" \
-	\
+
+#define BOOTCMDS_MMC \
 	"mmc_boot=" \
 		"setenv devtype mmc; " \
 		"if mmc dev ${devnum}; then " \
-			"run script_boot; " \
+			"run scan_boot; " \
 		"fi\0" \
+	"bootcmd_mmc0=setenv devnum 0; run mmc_boot;\0"
+#define BOOT_TARGETS_MMC "mmc0"
+
+#define BOOTCMDS_COMMON \
+	"rootpart=1\0" \
+	\
+	"do_script_boot="                                                 \
+		"load ${devtype} ${devnum}:${rootpart} "                  \
+			"${scriptaddr} ${prefix}${script}; "              \
+		"source ${scriptaddr}\0"                                  \
+	\
+	"script_boot="                                                    \
+		"for script in ${boot_scripts}; do "                      \
+			"if test -e ${devtype} ${devnum}:${rootpart} "    \
+					"${prefix}${script}; then "       \
+				"echo Found U-Boot script "               \
+					"${prefix}${script}; "            \
+				"run do_script_boot; "                    \
+				"echo SCRIPT FAILED: continuing...; "     \
+			"fi; "                                            \
+		"done\0"                                                  \
 	\
-	"bootcmd_mmc0=setenv devnum 0; run mmc_boot\0" \
+	"do_sysboot_boot="                                                \
+		"sysboot ${devtype} ${devnum}:${rootpart} any "           \
+			"${scriptaddr} ${prefix}extlinux.conf\0"          \
+	\
+	"sysboot_boot="                                                   \
+		"if test -e ${devtype} ${devnum}:${rootpart} "            \
+				"${prefix}extlinux.conf; then "           \
+			"echo Found extlinux config "                     \
+				"${prefix}extlinux.conf; "                \
+			"run do_sysboot_boot; "                           \
+			"echo SCRIPT FAILED: continuing...; "             \
+		"fi\0"                                                    \
+	\
+	"scan_boot="                                                      \
+		"echo Scanning ${devtype} ${devnum}...; "                 \
+		"for prefix in ${boot_prefixes}; do "                     \
+			"run sysboot_boot; "                              \
+			"run script_boot; "                               \
+		"done\0"                                                  \
+	\
+	"boot_targets=" \
+		BOOT_TARGETS_MMC " " \
+		"\0" \
+	\
+	"boot_prefixes=/\0" \
+	\
+	"boot_scripts=boot.scr.uimg\0" \
+	\
+	BOOTCMDS_MMC
 
 #define CONFIG_BOOTCOMMAND \
 	"for target in ${boot_targets}; do run bootcmd_${target}; done"
 
-#define CONFIG_BOOTDELAY		2
+#define CONFIG_BOOTCOMMAND \
+	"for target in ${boot_targets}; do run bootcmd_${target}; done"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	ENV_DEVICE_SETTINGS \
+	ENV_MEM_LAYOUT_SETTINGS \
+	BOOTCMDS_COMMON
+
+#define CONFIG_BOOTDELAY 2
 
 /* Shell */
 #define CONFIG_SYS_MAXARGS		8
Signature · 1 line
1.8.3.2
#8 lore raw

PATCH v2 1/4 pxe: allow compilation when !defined(CONFIG_CMD_NET)

In reply to Stephen Warren

Hi Stephen,

Quoted 97 lines · Stephen Warren

pxe.c provides both the "pxe" command which relies on a network, and the "sysboot" command which doesn't. Fix the file to compile when network support isn't enabled. This is useful e.g. on the Raspberry Pi which has no network support yet, but will soon support the sysboot command.

---
v2: No change.

This patch doesn't appear to depend on anything much, but is needed by the rest of this series. Given the dependencies in the rest of this series, either (a) this one patch can be applied to u-boot/master, and then u-boot/arm can merge that in before the rest of the series, or (b) u-boot/master can be merged into u-boot-arm/master, then this whole series applied there.

---
 common/cmd_pxe.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
common/cmd_pxe.c +10 -0
index 29e48db..3d13268 100644
@@ -45,6 +45,7 @@ static char *from_env(const char *envvar)
 	return ret;
 }
 
+#ifdef CONFIG_CMD_NET
 /*
  * Convert an ethaddr from the environment to the format used by pxelinux
  * filenames based on mac addresses. Convert's ':' to '-', and adds "01-" to
@@ -75,6 +76,7 @@ static int format_mac_pxe(char *outbuf, size_t outbuf_len)
 
 	return 1;
 }
+#endif
 
 /*
  * Returns the directory the file specified in the bootfile env variable is
@@ -120,6 +122,7 @@ static int get_bootfile_path(const char *file_path, char *bootfile_path,
 
 static int (*do_getfile)(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr);
 
+#ifdef CONFIG_CMD_NET
 static int do_get_tftp(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
 {
 	char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
@@ -132,6 +135,7 @@ static int do_get_tftp(cmd_tbl_t *cmdtp, const char *file_path, char *file_addr)
 
 	return 1;
 }
+#endif
 
 static char *fs_argv[5];
 
@@ -249,6 +253,8 @@ static int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path, void *file_addr
 	return 1;
 }
 
+#ifdef CONFIG_CMD_NET
+
 #define PXELINUX_DIR "pxelinux.cfg/"
 
 /*
@@ -397,6 +403,7 @@ do_pxe_get(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	return 1;
 }
+#endif
 
 /*
  * Wrapper to make it easier to store the file at file_path in the location
@@ -647,6 +654,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		len += strlen(ip_str);
 	}
 
+#ifdef CONFIG_CMD_NET
 	if (label->ipappend & 0x2) {
 		int err;
 		strcpy(mac_str, " BOOTIF=");
@@ -655,6 +663,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 			mac_str[0] = '\0';
 		len += strlen(mac_str);
 	}
+#endif
 
 	if (label->append)
 		len += strlen(label->append);
@@ -1500,6 +1509,7 @@ static void handle_pxe_menu(cmd_tbl_t *cmdtp, struct pxe_menu *cfg)
 	boot_unattempted_labels(cmdtp, cfg);
 }
 
+#ifdef CONFIG_CMD_NET
 /*
  * Boots a system using a pxe file
  *

common/cmd_pxe.c U_BOOT_CMD( · line 1592

Quoted 7 lines
common/cmd_pxe.c +1 -0
@@ -1576,6 +1586,7 @@ 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"
 );
+#endif
 
 /*
  * Boots a system using a local disk syslinux/extlinux file

Applied the whole series to u-boot-arm/master, thanks!

Amicalement,

Signature · 1 line
Albert.