From 78425235a7dc69233d21477ebb9a42d996948176 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 7 Jun 2016 16:26:00 +0200 Subject: net: update network docs The network configuration has changed in the previous patches. Update the documentation accordingly. Signed-off-by: Sascha Hauer --- Documentation/user/booting-linux.rst | 40 ++++---------- Documentation/user/networking.rst | 101 +++++++++++++++++++++++++++++++++-- 2 files changed, 105 insertions(+), 36 deletions(-) (limited to 'Documentation/user') diff --git a/Documentation/user/booting-linux.rst b/Documentation/user/booting-linux.rst index 66f64ece08..b5e4320ef6 100644 --- a/Documentation/user/booting-linux.rst +++ b/Documentation/user/booting-linux.rst @@ -232,43 +232,20 @@ Network boot With the following steps, barebox can start the kernel and root filesystem over the network, a standard development case. -Configure network: edit ``/env/network/eth0``. For a standard DHCP setup -the following is enough: - -.. code-block:: sh - - #!/bin/sh - - ip=dhcp - serverip=192.168.23.45 - -The optional setting ``serverip`` specifies the IP address of your TFTP and NFS -server, and is only necessary if it differs from the server IP offered by the -DHCP server (i.e., the field ``siaddr`` in the DHCP ACK Reply). - -A static IP setup can look like this: - -.. code-block:: sh - - #!/bin/sh - - ip=static - ipaddr=192.168.2.10 - netmask=255.255.0.0 - gateway=192.168.2.1 - serverip=192.168.2.1 +See :ref:`networking` for informations how to configure your network interfaces. Note that barebox will pass the same IP settings to the kernel, i.e. it passes -``ip=$ipaddr:$serverip:$gateway:$netmask::eth0:`` for a static IP setup and -``ip=dhcp`` for a dynamic DHCP setup. +``ip=$ipaddr:$serverip:$gateway:$netmask:::`` for a static IP setup +and ``ip=dhcp`` for a dynamic DHCP setup. ```` is a configurable value. +set ``nv.dev..linuxdevname`` to the name the device has in Linux. By default, barebox uses the variables ``global.user`` and ``global.hostname`` to retrieve its kernel image over TFTP, which makes it possible to use multiple boards for multiple users with one single server. -You can adjust those variables in ``/env/config``:: +You can adjust those variables using nvvars with these commands:: - global.user=sha - global.hostname=efikasb + nv user=sha + nv hostname=efikasb Copy the kernel (and devicetree if needed) to the root directory of your TFTP server, and name them accordingly; for example:: @@ -311,7 +288,8 @@ If the preconfigured paths or names are not suitable, they can be adjusted in fi nfsroot="/home/${global.user}/nfsroot/${global.hostname}" - bootargs-ip + ip_route_get -b ${global.net.server} global.linux.bootargs.dyn.ip + global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" ``boot net`` will then retrieve the kernel (and also the device tree and diff --git a/Documentation/user/networking.rst b/Documentation/user/networking.rst index 8afb433837..5822165281 100644 --- a/Documentation/user/networking.rst +++ b/Documentation/user/networking.rst @@ -1,3 +1,5 @@ +.. _networking: + Networking ========== @@ -7,6 +9,49 @@ barebox has IPv4 networking support. Several protocols such as :ref:`DHCP Network configuration --------------------- +Lowlevel network device configuration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Network devices are configured with a set of device specific variables: + ++-------------------+--------------+----------------------------------------------------+ +| name | type | | ++===================+==============+====================================================+ +| .mode | enum | "dhcp": DHCP is used to get IP address and netmask | +| | | "static": Static IP setup described by variables | +| | | below | +| | | "disabled": Interface unused | ++-------------------+--------------+----------------------------------------------------+ +| .ipaddr | ipv4 address | The IP address when using static configuration | ++-------------------+--------------+----------------------------------------------------+ +| .netmask | ipv4 address | The netmask when using static configuration | ++-------------------+--------------+----------------------------------------------------+ +| .gateway | ipv4 address | Alias for global.net.gateway. For | +| | | compatibility, do not use. | ++-------------------+--------------+----------------------------------------------------+ +| .serverip| ipv4 address | Alias for global.net.server. For | +| | | compatibility, do not use. | ++-------------------+--------------+----------------------------------------------------+ +| .ethaddr | MAC address | The MAC address of this device | ++-------------------+--------------+----------------------------------------------------+ + +Additionally there are some more variables that are not specific to a +device: + ++------------------------------+--------------+------------------------------------------------+ +| name | type | | ++==============================+==============+================================================+ +| global.net.gateway | ipv4 host | The network gateway used when a host is not in | +| | | any directly visible subnet. May be set | +| | | automatically by DHCP. | ++------------------------------+--------------+------------------------------------------------+ +| global.net.server | ipv4 host | The default server address. If unspecified, may| +| | | be set by DHCP | ++------------------------------+--------------+------------------------------------------------+ +| global.net.nameserver | ipv4 address | The DNS server used for resolving host names. | +| | | May be set by DHCP | ++------------------------------+--------------+------------------------------------------------+ + The first step for networking is configuring the network device. The network device is usually ``eth0``. The current configuration can be viewed with the :ref:`devinfo ` command: @@ -16,10 +61,9 @@ device is usually ``eth0``. The current configuration can be viewed with the barebox:/ devinfo eth0 Parameters: ethaddr: 00:1c:49:01:03:4b - gateway: 192.168.23.1 ipaddr: 192.168.23.197 netmask: 255.255.0.0 - serverip: 192.168.23.1 + [...] The configuration can be changed on the command line with: @@ -30,9 +74,56 @@ The configuration can be changed on the command line with: The :ref:`dhcp command ` will change the settings based on the answer from the DHCP server. -This low-level configuration of the network interface is often not necessary. Normally -the network settings should be edited in ``/env/network/eth0``, then the network interface -can be brought up using the :ref:`ifup command `. +To make the network device settings persistent across reboots there is a nonvolatile +variable (nvvar) for each of the varariables above. The network device specific variables +are: + +.. code-block:: sh + + nv.dev..mode + nv.dev..ipaddr + nv.dev..netmask + nv.dev..ethaddr + +The others are: + +.. code-block:: sh + + nv.net.gateway + nv.net.server + nv.net.nameserver + +A typical simple network setting is to use DHCP. Provided the network interface is eth0 +then this would configure the network device for DHCP: + +.. code-block:: sh + + nv dev.eth0.mode=dhcp + +(In fact DHCP is the default, so the above is not necessary) + +A static setup would look like: + +.. code-block:: sh + + nv dev.eth0.mode=static + nv dev.eth0.ipaddr=192.168.0.17 + nv dev.eth0.netmask=255.255.0.0 + nv net.server=192.168.0.1 + +The settings can be activated with the :ref:`ifup command `: + +.. code-block:: sh + + ifup eth0 + +or: + +.. code-block:: sh + + ifup -a + +'ifup -a' will activate all ethernet interfaces, also the ones on USB. Network filesystems ------------------- -- cgit v1.2.3 From acc3a3ef900ad92ccca57aeb5f7e446f8bd4745d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 24 Nov 2017 08:44:24 +0100 Subject: net: environment: update automounts Instead of using "ifup ethx" use "ifup -a" which works with all network interfaces. Also replace "$ethx.serverip" with "$global.net.server". This makes the automount independent of the actual network interface. Remove all board specific /env/init/automount files which were only there to use eth1 instead of the previously hardcoded eth0. Signed-off-by: Sascha Hauer --- Documentation/user/automount.rst | 2 +- arch/arm/boards/afi-gf/defaultenv-gf/init/automount | 10 ---------- arch/arm/boards/technexion-pico-hobbit/Makefile | 1 - arch/arm/boards/technexion-pico-hobbit/board.c | 2 -- .../defaultenv-pico-hobbit/init/automount | 11 ----------- .../zii-imx6q-rdu2/defaultenv-rdu2/init/automount | 17 ----------------- defaultenv/defaultenv-2-base/init/automount | 4 ++-- 7 files changed, 3 insertions(+), 44 deletions(-) delete mode 100644 arch/arm/boards/afi-gf/defaultenv-gf/init/automount delete mode 100644 arch/arm/boards/technexion-pico-hobbit/defaultenv-pico-hobbit/init/automount delete mode 100644 arch/arm/boards/zii-imx6q-rdu2/defaultenv-rdu2/init/automount (limited to 'Documentation/user') diff --git a/Documentation/user/automount.rst b/Documentation/user/automount.rst index a5e4313576..7de8261354 100644 --- a/Documentation/user/automount.rst +++ b/Documentation/user/automount.rst @@ -13,7 +13,7 @@ Typical usage is for accessing the TFTP server. To set up an automount for a TFTP server, the following is required:: mkdir -p /mnt/tftp - automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp' + automount /mnt/tftp 'ifup -a && mount -t tftp $global.net.server /mnt/tftp' This creates an automountpoint on ``/mnt/tftp``. Whenever this directory is accessed, the command ``ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp`` is executed. diff --git a/arch/arm/boards/afi-gf/defaultenv-gf/init/automount b/arch/arm/boards/afi-gf/defaultenv-gf/init/automount deleted file mode 100644 index 560bdb7975..0000000000 --- a/arch/arm/boards/afi-gf/defaultenv-gf/init/automount +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# automount tftp server based on $eth1.serverip - -mkdir -p /mnt/tftp -automount /mnt/tftp 'ifup eth1 && mount -t tftp $eth1.serverip /mnt/tftp' - -# eth0 is on the mezzanine board -mkdir -p /mnt/tftp-eth0 -automount /mnt/tftp-eth0 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp' diff --git a/arch/arm/boards/technexion-pico-hobbit/Makefile b/arch/arm/boards/technexion-pico-hobbit/Makefile index 02e17035a0..01c7a259e9 100644 --- a/arch/arm/boards/technexion-pico-hobbit/Makefile +++ b/arch/arm/boards/technexion-pico-hobbit/Makefile @@ -1,3 +1,2 @@ obj-y += board.o lwl-y += lowlevel.o -bbenv-y += defaultenv-pico-hobbit diff --git a/arch/arm/boards/technexion-pico-hobbit/board.c b/arch/arm/boards/technexion-pico-hobbit/board.c index d3109fc390..f52f827f46 100644 --- a/arch/arm/boards/technexion-pico-hobbit/board.c +++ b/arch/arm/boards/technexion-pico-hobbit/board.c @@ -56,8 +56,6 @@ static int pico_hobbit_device_init(void) barebox_set_hostname("pico-hobbit"); - defaultenv_append_directory(defaultenv_pico_hobbit); - return 0; } device_initcall(pico_hobbit_device_init); diff --git a/arch/arm/boards/technexion-pico-hobbit/defaultenv-pico-hobbit/init/automount b/arch/arm/boards/technexion-pico-hobbit/defaultenv-pico-hobbit/init/automount deleted file mode 100644 index fdcfa36045..0000000000 --- a/arch/arm/boards/technexion-pico-hobbit/defaultenv-pico-hobbit/init/automount +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# automount tftp server based on $eth1.serverip - -mkdir -p /mnt/tftp -automount /mnt/tftp 'ifup eth1 && mount -t tftp $eth1.serverip /mnt/tftp' - -# automount nfs server's nfsroot - -mkdir -p /mnt/nfs -automount /mnt/nfs 'ifup eth1 && mount -t nfs ${eth1.serverip}:/home/${global.user}/nfsroot/${global.hostname} /mnt/nfs' diff --git a/arch/arm/boards/zii-imx6q-rdu2/defaultenv-rdu2/init/automount b/arch/arm/boards/zii-imx6q-rdu2/defaultenv-rdu2/init/automount deleted file mode 100644 index 6c04eb48a1..0000000000 --- a/arch/arm/boards/zii-imx6q-rdu2/defaultenv-rdu2/init/automount +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# automount tftp server based on $eth0.serverip - -mkdir -p /mnt/tftp -automount /mnt/tftp 'ifup eth1 && mount -t tftp $eth1.serverip /mnt/tftp' - -# automount nfs server's nfsroot - -mkdir -p /mnt/nfs -automount /mnt/nfs 'ifup eth1 && mount -t nfs ${eth1.serverip}:/home/${global.user}/nfsroot/${global.hostname} /mnt/nfs' - - -# FAT on usb disk example - -#mkdir -p /mnt/fat -#automount -d /mnt/fat 'usb && [ -e /dev/disk0.0 ] && mount /dev/disk0.0 /mnt/fat' diff --git a/defaultenv/defaultenv-2-base/init/automount b/defaultenv/defaultenv-2-base/init/automount index 959b2c148e..5e0cb4d938 100644 --- a/defaultenv/defaultenv-2-base/init/automount +++ b/defaultenv/defaultenv-2-base/init/automount @@ -3,12 +3,12 @@ # automount tftp server based on $eth0.serverip mkdir -p /mnt/tftp -automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp' +automount /mnt/tftp 'ifup -a && mount -t tftp $global.net.server /mnt/tftp' # automount nfs server's nfsroot mkdir -p /mnt/nfs -automount /mnt/nfs 'ifup eth0 && mount -t nfs ${eth0.serverip}:/home/${global.user}/nfsroot/${global.hostname} /mnt/nfs' +automount /mnt/nfs 'ifup -a && mount -t nfs ${global.net.server}:/home/${global.user}/nfsroot/${global.hostname} /mnt/nfs' # FAT on usb disk example -- cgit v1.2.3