samples/net/gptp/README.html · samples/net/gptp/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Networking · Time-Sensitive Networking

gPTP

OpenAVNU·linuxptp grandmaster와 hardware·software timestamp, multiport TSN을 구성합니다.

Official pathsamples/net/gptp/README.html
Source filesamples/net/gptp/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

Phase discontinuity, PDelay·AsCapable·Grandmaster 전환과 13개 build·daemon·output block을 보존합니다.

Standard

IEEE 802.1AS gPTP

Daemons

OpenAVNU · ptp4l

Ports

Single · Multiport

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 7DB322F19F75A59AC9D98EF48D91F9B28A1D999737374B494139BFCD7765B023
.. zephyr:code-sample:: gptp
   :name: gPTP
   :relevant-api: gptp ptp_time

   Enable gPTP support and monitor functionality using net-shell.

Overview
********

The gPTP sample application for Zephyr will enable gPTP support, registers
gPTP phase discontinuity callback, enable traffic class support (TX multi
queues) and setup VLANs (if enabled). The net-shell is also enabled so that
user can monitor gPTP functionality.

The source code for this sample application can be found at:
:zephyr_file:`samples/net/gptp`.

Requirements
************

For generic host connectivity, that can be used for debugging purposes, see
:ref:`networking_with_native_sim` for details.

Building and Running
********************

A good way to run this sample is to run this gPTP application inside
native_sim board as described in :ref:`networking_with_native_sim` or with
embedded device like NXP FRDM-K64F, Nucleo-H743-ZI, Nucleo-H745ZI-Q,
Nucleo-F767ZI or Atmel SAM-E70 Xplained. Note that gPTP is only supported for
boards that have an Ethernet port and which has support for collecting
timestamps for sent and received Ethernet frames.

Follow these steps to build the gPTP sample application:

.. zephyr-app-commands::
   :zephyr-app: samples/net/gptp
   :board: <board to use>
   :goals: build
   :compact:

The net-shell command "**net gptp**" will print out general gPTP information.
For port 1, the command "**net gptp 1**" will print detailed information about
port 1 statistics etc. Note that executing the shell command could affect
the timing of the sent or received gPTP packets and the grandmaster might
mark the device as non AS capable and disable it.

Setting up Linux Host
=====================

If you need VLAN support in your network, then the
:zephyr_file:`samples/net/vlan/vlan-setup-linux.sh` provides a script that can be
executed on the Linux host. It creates two VLANs on the Linux host and creates
routes to Zephyr. If you are using native_sim board, then
the ``net-setup.sh`` will create VLAN setup automatically with this command:

.. code-block:: console

   ./net-setup.sh -c zeth-vlan.conf

The OpenAVNU repository at https://github.com/AVnu contains gPTP
daemon that can be run in Linux host and which can act as a grandmaster for
the IEEE 801.1AS network. Note that OpenAVNU will not work with
native_sim board as that board only supports software timestamping and
OpenAVNU only supports hardware timestamping. See instructions at the end
of this chapter how to run linuxptp daemon with native_sim board.

Get OpenAvnu/gPTP project sources

.. code-block:: console

    git clone [email protected]:AVnu/gptp.git

After downloading the source code, compile it like this in Linux:

.. code-block:: console

    mkdir build
    cd build
    cmake ..
    make
    cp ../gptp_cfg.ini .

Edit the :file:`gptp_cfg.ini` file and set the neighborPropDelayThresh to 10000
as the default value 800 is too low if you run the gPTP in FRDM-K64F.

Then execute the daemon with correct network interface and the configuration
file.

.. code-block:: console

    sudo ./gptp enp0s25 -F gptp_cfg.ini

Note that here the example network interface **enp0s25** is the name of the
network interface that is connected to your Zephyr device.

If everything is configured correctly, you should see following kind of
messages from gptp:

.. code-block:: console

    INFO     : GPTP [13:01:14:837] gPTP starting
    INFO     : GPTP [13:01:14:838] priority1 = 248
    INFO     : GPTP [13:01:14:838] announceReceiptTimeout: 3
    INFO     : GPTP [13:01:14:838] syncReceiptTimeout: 3
    INFO     : GPTP [13:01:14:838] LINKSPEED_100MB - PHY delay
			TX: 1044 | RX: 2133
    INFO     : GPTP [13:01:14:838] LINKSPEED_1G - PHY delay
			TX: 184 | RX: 382
    INFO     : GPTP [13:01:14:838] neighborPropDelayThresh: 10000
    INFO     : GPTP [13:01:14:838] syncReceiptThreshold: 8
    ERROR    : GPTP [13:01:14:838] Using clock device: /dev/ptp0
    STATUS   : GPTP [13:01:14:838] Starting PDelay
    STATUS   : GPTP [13:01:14:838] Link Speed: 1000000 kb/sec
    STATUS   : GPTP [13:01:14:871] AsCapable: Enabled
    STATUS   : GPTP [13:01:16:497] New Grandmaster "3C:97:0E:FF:FE:23:F2:32" (previous "00:00:00:00:00:00:00:00")
    STATUS   : GPTP [13:01:16:497] Switching to Master

If Zephyr syncs properly with gptp daemon, then this is printed:

.. code-block:: console

    STATUS   : GPTP [13:01:25:965] AsCapable: Enabled

By default gPTP in Zephyr will not print any gPTP debug messages to console.
One can enable debug prints by setting
:kconfig:option:`CONFIG_NET_GPTP_LOG_LEVEL_DBG` in the config file.

For native_sim board, use ``linuxptp`` project as that supports
software timestamping.

Get linuxptp project sources

.. code-block:: console

    git clone git://git.code.sf.net/p/linuxptp/code

Compile the ``ptp4l`` daemon and start it like this:

.. code-block:: console

    sudo ./ptp4l -2 -f gPTP-zephyr.cfg -i zeth -m -q -l 6 -S

Use the ``default.cfg`` as a base, copy it to ``gPTP-zephyr.cfg``, and modify
it according to your needs.


Multiport Setup
===============

If you set :kconfig:option:`CONFIG_NET_GPTP_NUM_PORTS` larger than 1, then gPTP sample
will create multiple TSN ports. This configuration is currently only supported
in native_sim board.

You need to enable the ports in the net-tools. If the number of ports is set
to 2, then give following commands to create the network interfaces in host
side:

.. code-block:: console

    sudo ./net-setup.sh -c zeth0-gptp.conf -i zeth0 start
    sudo ./net-setup.sh -c zeth1-gptp.conf -i zeth1 start

After that you can start ptp4l daemon for both interfaces. Please use two
terminals when starting ptp4l daemon. Note that you must use ptp4l as OpenAVNU
does not work with software clock available in native_sim.

.. code-block:: console

    cd <ptp4l directory>
    sudo ./ptp4l -2 -f gPTP-zephyr.cfg -m -q -l 6 -S -i zeth0
    sudo ./ptp4l -2 -f gPTP-zephyr.cfg -m -q -l 6 -S -i zeth1

Compile Zephyr application.

.. zephyr-app-commands::
   :zephyr-app: samples/net/gptp
   :board: native_sim
   :goals: build
   :compact:

When the Zephyr image is build, you can start it like this:

.. code-block:: console

    build/zephyr/zephyr.exe -attach_uart

Part 3

한국어 전문 번역

개요

Zephyr용 gPTP sample application은 gPTP 지원을 활성화하고 gPTP phase discontinuity callback을 등록합니다. 또한 traffic class 지원인 TX multi-queue를 활성화하고, VLAN이 활성화되어 있으면 VLAN을 설정합니다.

사용자가 gPTP 기능을 관찰할 수 있도록 net-shell도 활성화합니다.

Sample application source code는 samples/net/gptp에 있습니다.

요구 사항

Debug에 사용할 수 있는 일반적인 host 연결 방법은 native_sim board networking을 참고하십시오.

Build와 실행

이 sample은 native_sim board 안에서 실행하거나 NXP FRDM-K64F, Nucleo-H743-ZI, Nucleo-H745ZI-Q, Nucleo-F767ZI, Atmel SAM-E70 Xplained 같은 embedded device에서 실행하는 것이 좋습니다.

gPTP는 Ethernet port가 있고 송수신 Ethernet frame의 timestamp를 수집할 수 있는 board에서만 지원됩니다.

다음 단계로 gPTP sample application을 build합니다.

west build -b <board to use> samples/net/gptp

Net-shell 명령 net gptp는 일반 gPTP 정보를 표시합니다. Port 1의 통계 등 자세한 정보는 net gptp 1로 표시합니다.

Shell 명령 실행 자체가 gPTP packet의 송수신 timing에 영향을 줄 수 있습니다. 이 경우 grandmaster가 device를 AS capable이 아닌 것으로 표시하고 비활성화할 수 있습니다.

Linux host 설정

Network에서 VLAN 지원이 필요하다면 samples/net/vlan/vlan-setup-linux.sh를 Linux host에서 실행할 수 있습니다. 이 script는 host에 VLAN 두 개와 Zephyr로 향하는 route를 만듭니다.

native_sim board를 사용한다면 net-setup.sh가 다음 명령으로 VLAN을 자동 구성합니다.

./net-setup.sh -c zeth-vlan.conf

OpenAVNU repository에는 Linux host에서 실행해 IEEE 801.1AS network의 grandmaster 역할을 할 수 있는 gPTP daemon이 있습니다. 801.1AS는 원문 표기이며 일반적으로 알려진 표준 명칭은 IEEE 802.1AS입니다.

OpenAVNU는 hardware timestamp만 지원하지만 native_sim board는 software timestamp만 지원하므로 둘을 함께 사용할 수 없습니다. Native_sim에서는 뒤에서 설명하는 linuxptp daemon을 사용합니다.

OpenAVNU/gPTP project source를 내려받습니다.

git clone [email protected]:AVnu/gptp.git

Source를 내려받은 뒤 Linux에서 compile하고 configuration file을 build directory로 복사합니다.

mkdir build
cd build
cmake ..
make
cp ../gptp_cfg.ini .

FRDM-K64F에서 gPTP를 실행할 때 기본값 800은 너무 낮으므로 gptp_cfg.ini에서 neighborPropDelayThresh를 10000으로 설정합니다.

올바른 network interface와 configuration file을 지정해 daemon을 실행합니다.

sudo ./gptp enp0s25 -F gptp_cfg.ini

여기서 enp0s25는 Zephyr device에 연결된 network interface의 예제 이름입니다.

모든 설정이 올바르면 gPTP에서 다음과 같은 message가 나타납니다. PDelay가 시작되고 port가 AsCapable 상태가 된 뒤 새 Grandmaster를 선택하고 Master로 전환합니다.

INFO     : GPTP [13:01:14:837] gPTP starting
INFO     : GPTP [13:01:14:838] priority1 = 248
INFO     : GPTP [13:01:14:838] announceReceiptTimeout: 3
INFO     : GPTP [13:01:14:838] syncReceiptTimeout: 3
INFO     : GPTP [13:01:14:838] LINKSPEED_100MB - PHY delay
                    TX: 1044 | RX: 2133
INFO     : GPTP [13:01:14:838] LINKSPEED_1G - PHY delay
                    TX: 184 | RX: 382
INFO     : GPTP [13:01:14:838] neighborPropDelayThresh: 10000
INFO     : GPTP [13:01:14:838] syncReceiptThreshold: 8
ERROR    : GPTP [13:01:14:838] Using clock device: /dev/ptp0
STATUS   : GPTP [13:01:14:838] Starting PDelay
STATUS   : GPTP [13:01:14:838] Link Speed: 1000000 kb/sec
STATUS   : GPTP [13:01:14:871] AsCapable: Enabled
STATUS   : GPTP [13:01:16:497] New Grandmaster "3C:97:0E:FF:FE:23:F2:32" (previous "00:00:00:00:00:00:00:00")
STATUS   : GPTP [13:01:16:497] Switching to Master

Zephyr가 gPTP daemon과 올바르게 동기화되면 다음 message가 출력됩니다.

STATUS   : GPTP [13:01:25:965] AsCapable: Enabled

기본적으로 Zephyr의 gPTP는 console에 debug message를 출력하지 않습니다. Configuration file에서 CONFIG_NET_GPTP_LOG_LEVEL_DBG를 설정하면 debug 출력을 활성화할 수 있습니다.

Software timestamp를 지원하는 native_sim board에서는 linuxptp project를 사용합니다. 먼저 source를 내려받습니다.

git clone git://git.code.sf.net/p/linuxptp/code

ptp4l daemon을 compile한 뒤 다음과 같이 시작합니다.

sudo ./ptp4l -2 -f gPTP-zephyr.cfg -i zeth -m -q -l 6 -S

default.cfg를 기반으로 gPTP-zephyr.cfg를 만들고 필요한 설정을 수정합니다.

Multiport 설정

CONFIG_NET_GPTP_NUM_PORTS를 1보다 크게 설정하면 gPTP sample이 여러 TSN port를 생성합니다. 이 configuration은 현재 native_sim board에서만 지원됩니다.

Net-tools에서 port를 활성화해야 합니다. Port 수가 2라면 host 쪽 network interface를 만드는 다음 명령을 실행합니다.

sudo ./net-setup.sh -c zeth0-gptp.conf -i zeth0 start
sudo ./net-setup.sh -c zeth1-gptp.conf -i zeth1 start

그다음 interface마다 ptp4l daemon을 시작합니다. 두 terminal을 사용해야 하며, native_sim의 software clock에서는 OpenAVNU가 동작하지 않으므로 반드시 ptp4l을 사용합니다.

cd <ptp4l directory>
sudo ./ptp4l -2 -f gPTP-zephyr.cfg -m -q -l 6 -S -i zeth0
sudo ./ptp4l -2 -f gPTP-zephyr.cfg -m -q -l 6 -S -i zeth1

Native_sim용 Zephyr application을 compile합니다.

west build -b native_sim samples/net/gptp

Zephyr image가 build되면 UART를 연결해 다음과 같이 시작합니다.

build/zephyr/zephyr.exe -attach_uart

Source

출처

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