Skip to content

Commit

Permalink
Merge branch 'for-next/net'
Browse files Browse the repository at this point in the history
  • Loading branch information
saschahauer committed Jan 5, 2018
2 parents 052d1c9 + 8201a94 commit 3dbe78a
Show file tree
Hide file tree
Showing 33 changed files with 884 additions and 778 deletions.
2 changes: 1 addition & 1 deletion Documentation/user/automount.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
40 changes: 9 additions & 31 deletions Documentation/user/booting-linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::<linuxdevname>:`` for a static IP setup
and ``ip=dhcp`` for a dynamic DHCP setup. ``<linuxdevname>`` is a configurable value.
set ``nv.dev.<ethdev>.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::
Expand Down Expand Up @@ -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
Expand Down
101 changes: 96 additions & 5 deletions Documentation/user/networking.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _networking:

Networking
==========

Expand All @@ -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 | |
+===================+==============+====================================================+
| <devname>.mode | enum | "dhcp": DHCP is used to get IP address and netmask |
| | | "static": Static IP setup described by variables |
| | | below |
| | | "disabled": Interface unused |
+-------------------+--------------+----------------------------------------------------+
| <devname>.ipaddr | ipv4 address | The IP address when using static configuration |
+-------------------+--------------+----------------------------------------------------+
| <devname>.netmask | ipv4 address | The netmask when using static configuration |
+-------------------+--------------+----------------------------------------------------+
| <devname>.gateway | ipv4 address | Alias for global.net.gateway. For |
| | | compatibility, do not use. |
+-------------------+--------------+----------------------------------------------------+
| <devname>.serverip| ipv4 address | Alias for global.net.server. For |
| | | compatibility, do not use. |
+-------------------+--------------+----------------------------------------------------+
| <devname>.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_devinfo>` command:
Expand All @@ -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:

Expand All @@ -30,9 +74,56 @@ The configuration can be changed on the command line with:
The :ref:`dhcp command <command_dhcp>` 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 <command_ifup>`.
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.<devname>.mode
nv.dev.<devname>.ipaddr
nv.dev.<devname>.netmask
nv.dev.<devname>.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 <command_ifup>`:

.. 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
-------------------
Expand Down
10 changes: 0 additions & 10 deletions arch/arm/boards/afi-gf/defaultenv-gf/init/automount

This file was deleted.

18 changes: 0 additions & 18 deletions arch/arm/boards/afi-gf/defaultenv-gf/network/eth1

This file was deleted.

1 change: 0 additions & 1 deletion arch/arm/boards/technexion-pico-hobbit/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
obj-y += board.o
lwl-y += lowlevel.o
bbenv-y += defaultenv-pico-hobbit
2 changes: 0 additions & 2 deletions arch/arm/boards/technexion-pico-hobbit/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions arch/arm/boards/zii-imx6q-rdu2/defaultenv-rdu2/init/automount

This file was deleted.

18 changes: 0 additions & 18 deletions arch/arm/boards/zii-imx6q-rdu2/defaultenv-rdu2/network/eth1

This file was deleted.

10 changes: 9 additions & 1 deletion arch/arm/mach-omap/xload.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,20 @@ static void *am33xx_net_boot(void)
IPaddr_t ip;
char *file;
char ip4_str[sizeof("255.255.255.255")];
struct eth_device *edev;

am33xx_register_ethaddr(0, 0);

memset(&dhcp_param, 0, sizeof(struct dhcp_req_param));
dhcp_param.vendor_id = "am335x barebox-mlo";
err = dhcp(20, &dhcp_param);

edev = eth_get_byname("eth0");
if (!edev) {
printf("eth0 not found\n");
return NULL;
}

err = dhcp(edev, &dhcp_param);
if (err) {
printf("dhcp failed\n");
return NULL;
Expand Down
10 changes: 10 additions & 0 deletions commands/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,16 @@ config CMD_TFTP
Options:
-p push to TFTP server

config CMD_IP_ROUTE_GET
tristate
prompt "ip-route-get"
default y
help
The ip-route-get command is used to retrieve the network interface
which is used to reach the specified IP address. Information can
be shown on the command line or alternatively a variable is set to
the result.

# end Network commands
endmenu

Expand Down
2 changes: 1 addition & 1 deletion commands/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ obj-$(CONFIG_CMD_MSLEEP) += msleep.o
obj-$(CONFIG_CMD_RESET) += reset.o
obj-$(CONFIG_CMD_POWEROFF) += poweroff.o
obj-$(CONFIG_CMD_GO) += go.o
obj-$(CONFIG_NET) += net.o
obj-$(CONFIG_CMD_PARTITION) += partition.o
obj-$(CONFIG_CMD_LS) += ls.o
obj-$(CONFIG_CMD_CD) += cd.o
Expand Down Expand Up @@ -123,3 +122,4 @@ obj-$(CONFIG_CMD_SPD_DECODE) += spd_decode.o
obj-$(CONFIG_CMD_MMC_EXTCSD) += mmc_extcsd.o
obj-$(CONFIG_CMD_NAND_BITFLIP) += nand-bitflip.o
obj-$(CONFIG_CMD_SEED) += seed.o
obj-$(CONFIG_CMD_IP_ROUTE_GET) += ip-route-get.o
Loading

0 comments on commit 3dbe78a

Please sign in to comment.