Skip to content

Commit 59161ce

Browse files
finikorgAnas Nashif
authored andcommitted
net: doc: Add Ethernet over USB basic documentation
Add basic documentation about Ethernet over USB and describe prj_netusb.conf configuration file. Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent fddcfa7 commit 59161ce

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

doc/subsystems/networking/networking.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ operation of the stacks and how they were implemented.
1919
net-app-api.rst
2020
buffers.rst
2121
qemu_setup.rst
22+
usbnet_setup.rst
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
.. _usb_device_networking_setup:
2+
3+
USB Device Networking
4+
#####################
5+
6+
This page describes how to set up networking between a Linux host
7+
and a Zephyr application running on USB supported devices.
8+
9+
The board is connected to Linux host using USB cable
10+
and provides an Ethernet interface to the host.
11+
The :ref:`echo-server-sample` application from the Zephyr source
12+
distribution is run on supported board. The board is connected to a
13+
Linux host using a USB cable providing an Ethernet interface to the host.
14+
15+
Basic Setup
16+
***********
17+
18+
To communicate with the Zephyr application over a newly created Ethernet
19+
interface, we need to assign IP addresses and set up a routing table for
20+
the Linux host.
21+
After plugging a USB cable from the board to the Linux host, the
22+
``cdc_ether`` driver registers a new Ethernet device with a provided MAC
23+
address.
24+
25+
You can check that network device is created and MAC address assigned by
26+
running dmesg from the Linux host.
27+
28+
.. code-block:: console
29+
30+
cdc_ether 1-2.7:1.0 eth0: register 'cdc_ether' at usb-0000:00:01.2-2.7, CDC Ethernet Device, 00:00:5e:00:53:01
31+
32+
We need to set it up and assign IP addresses as explained in the following
33+
section.
34+
35+
Choosing IP addresses
36+
=====================
37+
38+
To establish network connection to the board we need to choose IP address
39+
for the interface on the Linux host.
40+
41+
It make sense to choose addresses in the same subnet we have in Zephyr
42+
application. IP addresses usually set in the project configuration files
43+
and may be checked also from the shell with following commands. Connect
44+
a serial console program (such as puTTY) to the board, and enter this
45+
command to the Zephyr shell:
46+
47+
.. code-block:: console
48+
49+
shell> net iface
50+
51+
Interface 0xa800e580 (Ethernet)
52+
===============================
53+
Link addr : 00:00:5E:00:53:00
54+
MTU : 1500
55+
IPv6 unicast addresses (max 2):
56+
fe80::200:5eff:fe00:5300 autoconf preferred infinite
57+
2001:db8::1 manual preferred infinite
58+
...
59+
IPv4 unicast addresses (max 1):
60+
192.0.2.1 manual preferred infinite
61+
62+
This command shows that one IPv4 address and two IPv6 addresses have
63+
been assigned to the board. We can use either IPv4 or IPv6 for network
64+
connection depending on the board network configuration.
65+
66+
Next step is to assign IP addresses to the new Linux host interface, in
67+
the following steps ``enx00005e005301`` is the name of the interface on my
68+
Linux system.
69+
70+
Setting IPv4 address and routing
71+
================================
72+
73+
.. code-block:: console
74+
75+
# ip address add dev enx00005e005301 192.0.2.2
76+
# ip link set enx00005e005301 up
77+
# ip route add 192.0.2.0/24 dev enx00005e005301
78+
79+
Setting IPv6 address and routing
80+
================================
81+
82+
.. code-block:: console
83+
84+
# ip address add dev enx00005e005301 2001:db8::2
85+
# ip link set enx00005e005301 up
86+
# ip -6 route add 2001:db8::/64 dev enx00005e005301
87+
88+
Testing connection
89+
******************
90+
91+
From the host we can test the connection by pinging Zephyr IP address of
92+
the board with:
93+
94+
.. code-block:: console
95+
96+
$ ping 192.0.2.1
97+
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
98+
64 bytes from 192.0.2.1: icmp_seq=1 ttl=64 time=2.30 ms
99+
64 bytes from 192.0.2.1: icmp_seq=2 ttl=64 time=1.43 ms
100+
64 bytes from 192.0.2.1: icmp_seq=3 ttl=64 time=2.45 ms
101+
...

samples/net/echo_server/README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ echo-server directory:
6060
- :file:`prj_sam_e70_xplained.conf`
6161
Use this for Atmel SMART SAM E70 Xplained board with ethernet.
6262

63+
- :file:`prj_netusb.conf`
64+
Use this for Ethernet over USB setup with supported boards. The setup is
65+
described in :ref:`usb_device_networking_setup`.
66+
6367
Build echo-server sample application like this:
6468

6569
.. zephyr-app-commands::

0 commit comments

Comments
 (0)