For an AVB system, we need a clock master ("PTP Grandmaster") and PTP clients. These master and client roles could be freely negotiated within the PTP framework, but in our case, it makes sense to fix these roles. The PTP partners will communicate over IEEE 1588 (OSI level 2) messages.
PTP client operation
Under linux, the ptp4l daemon takes care of this communication, will negatiate master and slave roles, and will adjust the NIC hardware clocks (CLOCK_TAI) of the clients. The time standard of this is the TAI international atomic clock timebase.
The command ptp4l -i eth0 -2 -s starts the PTP daemon as slave for the network device eth0 using the IEEE 1588 communication protocol.
In order to adjust the system clocks (CLOCK_REALTIME), the phc2sys daemon is used.
It will synchronize the kernel time (measured in the Unix/POSIX time standard) to the hardware clocks.
Unix time is directly related to UTC time base).
Due to leap seconds, UTC is currently exactly 37 seconds behind TAI.
The command phc2sys -w -c CLOCK_REALTIME -s eth0 adjusts the kernel clock CLOCK_REALTIME to the hardware clock of network interface eth0. It waits for ptp4l before doing anything. Additional settings are in /etc/linuxptp/ptp4l.conf.
PTP master operation
In order to adjust the AVB system to world time, the PTP clock will have to be synchronized to, e.g., NTP at one point in the system.
The chrony daemon chronyd can be used as an NTP client (or server). It will adjust the system's CLOCK_REALTIME to a pool of NTP servers given in the config file /etc/chrony/chrony.conf.
In order to adjust hardware time to kernel time, the command phc2sys -w -s CLOCK_REALTIME -c enp7s0 can be used.
With this, the hardware clock of the network interface enp7s0 will be adjusted to the kernel clock using a memory block shared with NTP.
The command ptp4l -i enp7s0 -f /etc/linuxptp/ptp4l.conf will start the PTP daemon to communicate the hardware timer over the network. The config file /etc/linuxptp/ptp4l.conf must contain a few important settings, i.e., serverOnly 1, network_transport L2, utc_offset 37.
Testing
The command phc_ctl enp7s0 cmp reports the offset of the hardware clock of the network interface enp7s0 relative to CLOCK_REALTIME. This should be very close to -37000000000ns.