connectivity/networking/usbnet_setup.html · connectivity/networking/usbnet_setup.rst 공식 원문 ↗

Zephyr 3.7.0 · Connectivity · USB Ethernet

USB Device Networking

USB device가 제공하는 CDC Ethernet interface에 IPv4·IPv6 address와 route를 설정해 Linux host와 통신합니다.

Official pathconnectivity/networking/usbnet_setup.html
Source fileconnectivity/networking/usbnet_setup.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

cdc_ether 등록 확인, board address 조회, host IPv4·IPv6 route 구성과 ping 검증 절차입니다.

Device

USB · cdc_ether

Addressing

IPv4 · IPv6 · Route

Test

Host → Zephyr ping

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 D4F0F023E09FC728C115A1BA1FA55CF8209DFA7C63AFD9824B1A0B95E43D88FB
.. _usb_device_networking_setup:

USB Device Networking
#####################

.. contents::
    :local:
    :depth: 2

This page describes how to set up networking between a Linux host
and a Zephyr application running on USB supported devices.

The board is connected to Linux host using USB cable
and provides an Ethernet interface to the host.
The :zephyr:code-sample:`sockets-echo-server` application from the Zephyr source
distribution is run on supported board.  The board is connected to a
Linux host using a USB cable providing an Ethernet interface to the host.

Basic Setup
***********

To communicate with the Zephyr application over a newly created Ethernet
interface, we need to assign IP addresses and set up a routing table for
the Linux host.
After plugging a USB cable from the board to the Linux host, the
``cdc_ether`` driver registers a new Ethernet device with a provided MAC
address.

You can check that network device is created and MAC address assigned by
running dmesg from the Linux host.

.. code-block:: console

   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

We need to set it up and assign IP addresses as explained in the following
section.

Choosing IP addresses
=====================

To establish network connection to the board we need to choose IP address
for the interface on the Linux host.

It make sense to choose addresses in the same subnet we have in Zephyr
application. IP addresses usually set in the project configuration files
and may be checked also from the shell with following commands. Connect
a serial console program (such as puTTY) to the board, and enter this
command to the Zephyr shell:

.. code-block:: console

   shell> net iface

   Interface 0xa800e580 (Ethernet)
   ===============================
   Link addr : 00:00:5E:00:53:00
   MTU       : 1500
   IPv6 unicast addresses (max 2):
           fe80::200:5eff:fe00:5300 autoconf preferred infinite
           2001:db8::1 manual preferred infinite
   ...
   IPv4 unicast addresses (max 1):
           192.0.2.1 manual preferred infinite

This command shows that one IPv4 address and two IPv6 addresses have
been assigned to the board. We can use either IPv4 or IPv6 for network
connection depending on the board network configuration.

Next step is to assign IP addresses to the new Linux host interface, in
the following steps ``enx00005e005301`` is the name of the interface on my
Linux system.

Setting IPv4 address and routing
================================

.. code-block:: console

   # ip address add dev enx00005e005301 192.0.2.2
   # ip link set enx00005e005301 up
   # ip route add 192.0.2.0/24 dev enx00005e005301

Setting IPv6 address and routing
================================

.. code-block:: console

   # ip address add dev enx00005e005301 2001:db8::2
   # ip link set enx00005e005301 up
   # ip -6 route add 2001:db8::/64 dev enx00005e005301

Testing connection
******************

From the host we can test the connection by pinging Zephyr IP address of
the board with:

.. code-block:: console

   $ ping 192.0.2.1
   PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
   64 bytes from 192.0.2.1: icmp_seq=1 ttl=64 time=2.30 ms
   64 bytes from 192.0.2.1: icmp_seq=2 ttl=64 time=1.43 ms
   64 bytes from 192.0.2.1: icmp_seq=3 ttl=64 time=2.45 ms
   ...

Part 3

한국어 전문 번역

USB Device Networking

이 문서는 Linux host와 USB를 지원하는 device에서 실행하는 Zephyr application 사이에 networking을 설정하는 방법을 설명합니다.

Board를 USB cable로 Linux host에 연결하면 host에 Ethernet interface를 제공합니다. 지원 board에서 Zephyr sockets echo server sample을 실행해 이 interface로 통신합니다.

기본 설정

새 Ethernet interface를 통해 Zephyr application과 통신하려면 Linux host에 IP address를 할당하고 routing table을 설정해야 합니다.

Board USB cable을 Linux host에 연결하면 cdc_ether driver가 제공된 MAC address로 새 Ethernet device를 등록합니다.

Linux host의 dmesg에서 network device 생성과 MAC address 할당을 확인할 수 있습니다.

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

IP address 선택

Board와 network connection을 만들려면 Linux host interface에 사용할 IP address를 정해야 합니다. Zephyr application과 같은 subnet을 선택하는 것이 합리적입니다.

IP address는 보통 project configuration file에 설정하며 shell에서도 확인할 수 있습니다. PuTTY 같은 serial console을 board에 연결하고 Zephyr shell에서 다음 명령을 실행합니다.

shell> net iface

Interface 0xa800e580 (Ethernet)
===============================
Link addr : 00:00:5E:00:53:00
MTU       : 1500
IPv6 unicast addresses (max 2):
        fe80::200:5eff:fe00:5300 autoconf preferred infinite
        2001:db8::1 manual preferred infinite
...
IPv4 unicast addresses (max 1):
        192.0.2.1 manual preferred infinite

출력은 board에 IPv4 address 하나와 IPv6 address 두 개가 할당됐음을 보여 줍니다. Board network configuration에 따라 IPv4 또는 IPv6를 사용할 수 있습니다.

다음 절의 enx00005e005301은 예제 Linux system에서 새 USB Ethernet interface에 붙은 이름입니다.

IPv4 address와 routing 설정

Host interface에 192.0.2.2를 할당하고 up 상태로 만든 뒤 192.0.2.0/24 route를 추가합니다.

# ip address add dev enx00005e005301 192.0.2.2
# ip link set enx00005e005301 up
# ip route add 192.0.2.0/24 dev enx00005e005301

IPv6 address와 routing 설정

Host interface에 2001:db8::2를 할당하고 up 상태로 만든 뒤 2001:db8::/64 IPv6 route를 추가합니다.

# ip address add dev enx00005e005301 2001:db8::2
# ip link set enx00005e005301 up
# ip -6 route add 2001:db8::/64 dev enx00005e005301

Connection 시험

Host에서 board의 Zephyr IPv4 address 192.0.2.1로 ping을 보내 connection을 확인합니다.

$ ping 192.0.2.1
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
64 bytes from 192.0.2.1: icmp_seq=1 ttl=64 time=2.30 ms
64 bytes from 192.0.2.1: icmp_seq=2 ttl=64 time=1.43 ms
64 bytes from 192.0.2.1: icmp_seq=3 ttl=64 time=2.45 ms
...

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.