1.. zephyr:code-sample:: ptp
2   :name: PTP
3   :relevant-api: ptp
4
5   Enable PTP support and monitor messages and events via logging.
6
7Overview
8********
9
10The PTP sample application for Zephyr will enable PTP support.
11
12The source code for this sample application can be found at:
13:zephyr_file:`samples/net/ptp`.
14
15Requirements
16************
17
18For generic host connectivity, that can be used for debugging purposes, see
19:ref:`networking_with_native_sim` for details.
20
21Building and Running
22********************
23
24A good way to run this sample is to run this PTP application inside
25native_sim board as described in :ref:`networking_with_native_sim` or with
26embedded device like Nucleo-H743-ZI, Nucleo-H745ZI-Q, Nucleo-F767ZI or
27Nucleo-H563ZI. Note that PTP is only supported for
28boards that have an Ethernet port and which has support for collecting
29timestamps for sent and received Ethernet frames.
30
31Follow these steps to build the PTP sample application:
32
33.. zephyr-app-commands::
34   :zephyr-app: samples/net/ptp
35   :board: <board to use>
36   :goals: build
37   :compact:
38
39Setting up Linux Host
40=====================
41
42By default PTP in Zephyr will not print any PTP debug messages to console.
43One can enable debug prints by setting
44:kconfig:option:`CONFIG_PTP_LOG_LEVEL_DBG` in the config file.
45
46Get linuxptp project sources
47
48.. code-block:: console
49
50    git clone git://git.code.sf.net/p/linuxptp/code
51
52Compile the ``ptp4l`` daemon and start it like this:
53
54.. code-block:: console
55
56    sudo ./ptp4l -4 -f -i zeth -m -q -l 6 -S
57
58Compile Zephyr application.
59
60.. zephyr-app-commands::
61   :zephyr-app: samples/net/ptp
62   :board: native_sim
63   :goals: build
64   :compact:
65
66When the Zephyr image is build, you can start it like this:
67
68.. code-block:: console
69
70    build/zephyr/zephyr.exe -attach_uart
71