mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/11] improvements for net & disk booting
@ 2011-09-25 20:54 Wolfram Sang
  2011-09-25 20:54 ` [PATCH 01/11] defaultenv: simplify scripting Wolfram Sang
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

This series starts with some patches from Marc to improve the default
environment regarding net-based booting and it adds disk-based booting as well
as a default config. Based on that, there are further patches from me, which
add the possibility to use a global serverip-variable in case the TFTP/NFS
server is not the same as the DHCP server. To make that more robust, sanity
checks are added related to the string_to_ip function.

Marc Kleine-Budde (7):
  defaultenv: simplify scripting
  defaultenv: boot: add backwards compatibility for kernel_loc=net
  defaultenv: boot: add eth0 to ip configuration
  defaultenv: boot: add serverip to static ip configuration
  defaultenv: boot: add support to boot from disk
  defaultenv: update: add support to update kernel on disk
  defaultenv: add config template

Wolfram Sang (4):
  net: string_to_ip: add sanity check for > 255
  net: getenv_ip: check return value of string_to_ip
  defaultenv: place eth0.ethaddr more visibly
  net: dhcp: introduce global serverip variable

 defaultenv/bin/_update_help |    2 +-
 defaultenv/bin/boot         |   17 ++++++++--
 defaultenv/bin/update       |   11 ++++--
 defaultenv/config           |   70 +++++++++++++++++++++++++++++++++++++++++++
 net/dhcp.c                  |    7 +++-
 net/net.c                   |    9 ++++--
 6 files changed, 103 insertions(+), 13 deletions(-)
 create mode 100644 defaultenv/config

-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/11] defaultenv: simplify scripting
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 02/11] defaultenv: boot: add backwards compatibility for kernel_loc=net Wolfram Sang
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/bin/boot   |    2 +-
 defaultenv/bin/update |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index de4fa24..c97a396 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -74,7 +74,7 @@ if [ ! -e /dev/ram0.kernel ]; then
 	addpart /dev/ram0 8M@8M(kernel)
 fi
 
-if [ x$kernel_loc = xnfs ] || [ x$kernel_loc = xtftp ]; then
+if [ x$kernel_loc = xnfs -o x$kernel_loc = xtftp ]; then
 	if [ x$ip = xdhcp ]; then
 		dhcp
 	fi
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
index 55ac10b..6fd5e4c 100644
--- a/defaultenv/bin/update
+++ b/defaultenv/bin/update
@@ -32,12 +32,12 @@ elif [ x${type} = xrootfs ]; then
 	type=root
 elif [ x${type} = xbarebox ]; then
 	image=$bareboximage
-	if [ x${image} = x ]; then
+	if [ -z ${image} ]; then
 		image=barebox.bin
 	fi
 elif [ x${type} = xbareboxenv ]; then
 	image=$bareboxenvimage
-	if [ x${image} = x ]; then
+	if [ -z ${image} ]; then
 		image=bareboxenv.bin
 	fi
 elif [ x${type} = xxload ]; then
@@ -47,7 +47,7 @@ else
 	exit 1
 fi
 
-if [ x${imagename} != x ]; then
+if [ -n ${imagename} ]; then
 	image=${imagename}
 fi
 
@@ -60,7 +60,7 @@ else
 	exit 1
 fi
 
-if [ x${mode} != xtftp ] && [ x${mode} != xxmodem ] ; then
+if [ x${mode} != xtftp -a x${mode} != xxmodem ] ; then
 	echo "unsupported mode ${mode}."
 	. /env/bin/_update_help
 	exit 1
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 02/11] defaultenv: boot: add backwards compatibility for kernel_loc=net
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
  2011-09-25 20:54 ` [PATCH 01/11] defaultenv: simplify scripting Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 03/11] defaultenv: boot: add eth0 to ip configuration Wolfram Sang
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

Since commit 9eac282024c55fc13970189d6ace61f884917538, the boot script
doesn't understand kernel_loc=net anymore. This patch adds backwards
compatibility so that the kernel is loaded from tftp as before.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/bin/boot |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index c97a396..6649c57 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -2,6 +2,10 @@
 
 . /env/config
 
+if [ x$kernel_loc = xnet ]; then
+	kernel_loc=tftp
+fi
+
 if [ x$1 = xnand ]; then
 	rootfs_loc=nand
 	kernel_loc=nand
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 03/11] defaultenv: boot: add eth0 to ip configuration
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
  2011-09-25 20:54 ` [PATCH 01/11] defaultenv: simplify scripting Wolfram Sang
  2011-09-25 20:54 ` [PATCH 02/11] defaultenv: boot: add backwards compatibility for kernel_loc=net Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 04/11] defaultenv: boot: add serverip to static " Wolfram Sang
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

When passing a fixed IP to the kernel set it explicit to eth0. Otherwise
on systems with more than one interface dhcp might be used.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/bin/boot |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index 6649c57..3514961 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -25,7 +25,7 @@ if [ x$ip = xdhcp ]; then
 elif [ x$ip = xnone ]; then
 	bootargs="$bootargs ip=none"
 else
-	bootargs="$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask:::"
+	bootargs="$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask::eth0:"
 fi
 
 
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 04/11] defaultenv: boot: add serverip to static ip configuration
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (2 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 03/11] defaultenv: boot: add eth0 to ip configuration Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 05/11] defaultenv: boot: add support to boot from disk Wolfram Sang
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

If a (different) server is supplied to the "nfsroot" parameter, the kernel
will choose that one.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/bin/boot |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index 3514961..4284308 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -25,7 +25,7 @@ if [ x$ip = xdhcp ]; then
 elif [ x$ip = xnone ]; then
 	bootargs="$bootargs ip=none"
 else
-	bootargs="$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask::eth0:"
+	bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
 fi
 
 
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 05/11] defaultenv: boot: add support to boot from disk
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (3 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 04/11] defaultenv: boot: add serverip to static " Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 06/11] defaultenv: update: add support to update kernel on disk Wolfram Sang
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/bin/boot |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index 4284308..652ae0c 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -18,6 +18,9 @@ elif [ x$1 = xnfs ]; then
 elif [ x$1 = xtftp ]; then
 	rootfs_loc=net
 	kernel_loc=tftp
+elif [ x$1 = xdisk ]; then
+	rootfs_loc=disk
+	kernel_loc=disk
 fi
 
 if [ x$ip = xdhcp ]; then
@@ -31,6 +34,8 @@ fi
 
 if [ x$rootfs_loc = xnet ]; then
 	bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
+elif [ x$rootfs_loc = xdisk ]; then
+	bootargs="$bootargs root=/dev/$rootfs_part_linux_dev rootfstype=$rootfs_type noinitrd rootwait"
 elif [ x$rootfs_loc = xinitrd ]; then
 	bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
 else
@@ -100,8 +105,10 @@ elif [ x$kernel_loc = xnor ]; then
 	kdev="/dev/nor0.kernel"
 elif [ x$kernel_loc = xnand ]; then
 	kdev="/dev/nand0.kernel.bb"
+elif [ x$kernel_loc = xdisk ]; then
+	kdev="/dev/$kernel_part"
 else
-	echo "error: set kernel_loc to one of 'nfs', 'tftp', 'nand' or 'nor'"
+	echo "error: set kernel_loc to one of 'tftp', 'nfs', 'nand', 'nor' or 'disk'"
 	exit 1
 fi
 
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 06/11] defaultenv: update: add support to update kernel on disk
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (4 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 05/11] defaultenv: boot: add support to boot from disk Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 07/11] defaultenv: add config template Wolfram Sang
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/bin/_update_help |    2 +-
 defaultenv/bin/update       |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help
index 98096da..92d6772 100644
--- a/defaultenv/bin/_update_help
+++ b/defaultenv/bin/_update_help
@@ -7,7 +7,7 @@ echo "options"
 echo " -c     to check the crc32 for the image and flashed one"
 echo ""
 echo "default mode is tftp"
-echo "type update -t kernel -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update kernel into flash"
+echo "type update -t kernel -d <nor|nand|disk> [-m tftp|xmodem] [-f imagename] to update kernel into flash"
 echo "type update -t rootfs -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update rootfs into flash"
 echo "type update -t barebox -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update barebox into flash"
 echo "type update -t bareboxenv -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update bareboxenv into flash"
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
index 6fd5e4c..39e7591 100644
--- a/defaultenv/bin/update
+++ b/defaultenv/bin/update
@@ -27,6 +27,7 @@ done
 
 if [ x${type} = xkernel ]; then
 	image=$kernelimage
+	disk_part=$kernel_part
 elif [ x${type} = xrootfs ]; then
 	image=$rootfsimage
 	type=root
@@ -55,6 +56,8 @@ if [ x${device_type} = xnand ]; then
 	part=/dev/nand0.${type}.bb
 elif [ x${device_type} = xnor ]; then
 	part=/dev/nor0.${type}
+elif [ x${device_type} = xdisk ]; then
+	part=/dev/${disk_part}
 else
 	. /env/bin/_update_help
 	exit 1
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 07/11] defaultenv: add config template
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (5 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 06/11] defaultenv: update: add support to update kernel on disk Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 08/11] net: string_to_ip: add sanity check for > 255 Wolfram Sang
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

From: Marc Kleine-Budde <mkl@pengutronix.de>

This patch add a config template to the defaultenv.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/config |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 defaultenv/config

diff --git a/defaultenv/config b/defaultenv/config
new file mode 100644
index 0000000..c2fe6ce
--- /dev/null
+++ b/defaultenv/config
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+machine=FIXME
+#user=
+
+# use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
+ip=dhcp
+
+# or set your networking parameters here
+#eth0.ipaddr=a.b.c.d
+#eth0.netmask=a.b.c.d
+#eth0.serverip=a.b.c.d
+#eth0.gateway=a.b.c.d
+#eth0.ethaddr=de:ad:be:ef:00:00
+
+# can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
+kernel_loc=tftp
+# can be either 'net', 'nand', 'nor', 'disk' or 'initrd'
+rootfs_loc=net
+
+# for flash based rootfs: 'jffs2' or 'ubifs'
+# in case of disk any regular filesystem like 'ext2', 'ext3', 'reiserfs'
+rootfs_type=ubifs
+# where is the rootfs in case of 'rootfs_loc=disk' (linux name)
+rootfs_part_linux_dev=mmcblk0p4
+rootfsimage=rootfs-${machine}.$rootfs_type
+
+# where is the kernel image in case of 'kernel_loc=disk'
+kernel_part=disk0.2
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+kernelimage_type=zimage
+kernelimage=zImage-$machine
+#kernelimage_type=uimage
+#kernelimage=uImage-$machine
+#kernelimage_type=raw
+#kernelimage=Image-$machine
+#kernelimage_type=raw_lzo
+#kernelimage=Image-$machine.lzo
+
+bareboximage=barebox-${machine}.bin
+bareboxenvimage=barebox-${machine}.bin
+
+if [ -n $user ]; then
+	bareboximage="$user"-"$bareboximage"
+	bareboxenvimage="$user"-"$bareboxenvimage"
+	kernelimage="$user"-"$kernelimage"
+	rootfsimage="$user"-"$rootfsimage"
+	nfsroot="/home/$user/nfsroot/$machine"
+else
+	nfsroot="/path/to/nfs/root"
+fi
+
+autoboot_timeout=3
+
+bootargs="console=ttyFIXME,115200"
+
+nor_parts="256k(barebox)ro,128k(bareboxenv),3M(kernel),-(root)"
+rootfs_mtdblock_nor=3
+
+nand_parts="256k(barebox)ro,128k(bareboxenv),3M(kernel),-(root)"
+nand_device="FIXME"
+rootfs_mtdblock_nand=7
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 08/11] net: string_to_ip: add sanity check for > 255
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (6 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 07/11] defaultenv: add config template Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 09/11] net: getenv_ip: check return value of string_to_ip Wolfram Sang
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 net/net.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/net.c b/net/net.c
index f1ab667..3578118 100644
--- a/net/net.c
+++ b/net/net.c
@@ -113,8 +113,10 @@ int string_to_ip(const char *s, IPaddr_t *ip)
 			return -EINVAL;
 
 		val = simple_strtoul(s, &e, 10);
-		addr <<= 8;
-		addr |= (val & 0xFF);
+		if (val > 255)
+			return -EINVAL;
+
+		addr = (addr << 8) | val;
 
 		if (*e != '.' && i != 3)
 			return -EINVAL;
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 09/11] net: getenv_ip: check return value of string_to_ip
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (7 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 08/11] net: string_to_ip: add sanity check for > 255 Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 10/11] defaultenv: place eth0.ethaddr more visibly Wolfram Sang
  2011-09-25 20:54 ` [PATCH 11/11] net: dhcp: introduce global serverip variable Wolfram Sang
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

Return 0 if we encounter an error.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 net/net.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/net.c b/net/net.c
index 3578118..8416861 100644
--- a/net/net.c
+++ b/net/net.c
@@ -136,7 +136,8 @@ IPaddr_t getenv_ip(const char *name)
 	if (!var)
 		return 0;
 
-	string_to_ip(var, &ip);
+	if (string_to_ip(var, &ip))
+		return 0;
 
 	return ip;
 }
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 10/11] defaultenv: place eth0.ethaddr more visibly
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (8 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 09/11] net: getenv_ip: check return value of string_to_ip Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-25 20:54 ` [PATCH 11/11] net: dhcp: introduce global serverip variable Wolfram Sang
  10 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

The config file looks like you just need to set ethaddr when you do
static IP. This is misleading, so put the setting to a more prominent
place.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/config |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/defaultenv/config b/defaultenv/config
index c2fe6ce..0aaead5 100644
--- a/defaultenv/config
+++ b/defaultenv/config
@@ -3,6 +3,9 @@
 machine=FIXME
 #user=
 
+# Enter MAC address here if not retrieved automatically
+#eth0.ethaddr=de:ad:be:ef:00:00
+
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
@@ -12,7 +15,6 @@ ip=dhcp
 #eth0.netmask=a.b.c.d
 #eth0.serverip=a.b.c.d
 #eth0.gateway=a.b.c.d
-#eth0.ethaddr=de:ad:be:ef:00:00
 
 # can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
 kernel_loc=tftp
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 11/11] net: dhcp: introduce global serverip variable
  2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
                   ` (9 preceding siblings ...)
  2011-09-25 20:54 ` [PATCH 10/11] defaultenv: place eth0.ethaddr more visibly Wolfram Sang
@ 2011-09-25 20:54 ` Wolfram Sang
  2011-09-26  9:57   ` Sascha Hauer
  10 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2011-09-25 20:54 UTC (permalink / raw)
  To: barebox

Sometimes, the TFTP/NFS server is different from the DHCP server. To handle
such situations, a global 'serverip' variable is introduced. If present and set
with a valid IP address, it will be used instead of the address returned by the
DHCP server.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 defaultenv/config |    3 ++-
 net/dhcp.c        |    7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/defaultenv/config b/defaultenv/config
index 0aaead5..235deca 100644
--- a/defaultenv/config
+++ b/defaultenv/config
@@ -9,11 +9,12 @@ machine=FIXME
 # use 'dhcp' to do dhcp in barebox and in kernel
 # use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
+# IP of the TFTP/NFS-server. If empty (or invalid), DHCP server will be used
+#serverip=a.b.c.d
 
 # or set your networking parameters here
 #eth0.ipaddr=a.b.c.d
 #eth0.netmask=a.b.c.d
-#eth0.serverip=a.b.c.d
 #eth0.gateway=a.b.c.d
 
 # can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
diff --git a/net/dhcp.c b/net/dhcp.c
index d1781bc..899c873 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -113,8 +113,11 @@ static void bootp_copy_net_params(struct bootp *bp)
 	tmp_ip = net_read_ip(&bp->bp_yiaddr);
 	net_set_ip(tmp_ip);
 
-	tmp_ip = net_read_ip(&bp->bp_siaddr);
-	if (tmp_ip != 0)
+	tmp_ip = getenv_ip("serverip");
+	if (!tmp_ip)
+		tmp_ip = net_read_ip(&bp->bp_siaddr);
+
+	if (tmp_ip)
 		net_set_serverip(tmp_ip);
 
 	if (strlen(bp->bp_file) > 0)
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 11/11] net: dhcp: introduce global serverip variable
  2011-09-25 20:54 ` [PATCH 11/11] net: dhcp: introduce global serverip variable Wolfram Sang
@ 2011-09-26  9:57   ` Sascha Hauer
  0 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2011-09-26  9:57 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: barebox

On Sun, Sep 25, 2011 at 10:54:14PM +0200, Wolfram Sang wrote:
> Sometimes, the TFTP/NFS server is different from the DHCP server. To handle
> such situations, a global 'serverip' variable is introduced. If present and set
> with a valid IP address, it will be used instead of the address returned by the
> DHCP server.

Just had some offline discussion with Wolfram. We came to agree that
it's not a good idea to introduce a global 'serverip' variable in C
code. That said we have problems in this area. We currently use
eth0.serverip for several ips which should be really different ones.
In case of dhcp eth0.serverip is set to the ip the dhcp server
returns which is then used as tftp server and rootnfs server. This
does not match setups where you don't have control over the dhcp
server.

So we really should have tftp_serverip, rootfs_serverip and the ip
returned from the dhcp server. Throw multiple ethernet devices into
the mix and things even get more complicated. We need to do something
about it but I feel that we should do a more complete solution instead
of a quick hack to solve the problem. I have no good idea what to do
though :(

Sascha

> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
>  defaultenv/config |    3 ++-
>  net/dhcp.c        |    7 +++++--
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/defaultenv/config b/defaultenv/config
> index 0aaead5..235deca 100644
> --- a/defaultenv/config
> +++ b/defaultenv/config
> @@ -9,11 +9,12 @@ machine=FIXME
>  # use 'dhcp' to do dhcp in barebox and in kernel
>  # use 'none' if you want to skip kernel ip autoconfiguration
>  ip=dhcp
> +# IP of the TFTP/NFS-server. If empty (or invalid), DHCP server will be used
> +#serverip=a.b.c.d
>  
>  # or set your networking parameters here
>  #eth0.ipaddr=a.b.c.d
>  #eth0.netmask=a.b.c.d
> -#eth0.serverip=a.b.c.d
>  #eth0.gateway=a.b.c.d
>  
>  # can be either 'tftp', 'nfs', 'nand', 'nor' or 'disk'
> diff --git a/net/dhcp.c b/net/dhcp.c
> index d1781bc..899c873 100644
> --- a/net/dhcp.c
> +++ b/net/dhcp.c
> @@ -113,8 +113,11 @@ static void bootp_copy_net_params(struct bootp *bp)
>  	tmp_ip = net_read_ip(&bp->bp_yiaddr);
>  	net_set_ip(tmp_ip);
>  
> -	tmp_ip = net_read_ip(&bp->bp_siaddr);
> -	if (tmp_ip != 0)
> +	tmp_ip = getenv_ip("serverip");
> +	if (!tmp_ip)
> +		tmp_ip = net_read_ip(&bp->bp_siaddr);
> +
> +	if (tmp_ip)
>  		net_set_serverip(tmp_ip);
>  
>  	if (strlen(bp->bp_file) > 0)
> -- 
> 1.7.5.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-09-26  9:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-25 20:54 [PATCH 00/11] improvements for net & disk booting Wolfram Sang
2011-09-25 20:54 ` [PATCH 01/11] defaultenv: simplify scripting Wolfram Sang
2011-09-25 20:54 ` [PATCH 02/11] defaultenv: boot: add backwards compatibility for kernel_loc=net Wolfram Sang
2011-09-25 20:54 ` [PATCH 03/11] defaultenv: boot: add eth0 to ip configuration Wolfram Sang
2011-09-25 20:54 ` [PATCH 04/11] defaultenv: boot: add serverip to static " Wolfram Sang
2011-09-25 20:54 ` [PATCH 05/11] defaultenv: boot: add support to boot from disk Wolfram Sang
2011-09-25 20:54 ` [PATCH 06/11] defaultenv: update: add support to update kernel on disk Wolfram Sang
2011-09-25 20:54 ` [PATCH 07/11] defaultenv: add config template Wolfram Sang
2011-09-25 20:54 ` [PATCH 08/11] net: string_to_ip: add sanity check for > 255 Wolfram Sang
2011-09-25 20:54 ` [PATCH 09/11] net: getenv_ip: check return value of string_to_ip Wolfram Sang
2011-09-25 20:54 ` [PATCH 10/11] defaultenv: place eth0.ethaddr more visibly Wolfram Sang
2011-09-25 20:54 ` [PATCH 11/11] net: dhcp: introduce global serverip variable Wolfram Sang
2011-09-26  9:57   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox