PTP/IEEE1588

1. Introduction

This document describes PTP related configuration and get of status information. This covers multiple PTP profiles:

  • gPTP

  • automotive gPTP

2. Generate 1PPS output

Configure the HW to generate a 1PPS on one of the PTP pins. This feature can be used for example to check that two different HWs are synchronized by checking the 1PPS and make sure that is aligned.

The 1PPS will be generated whenever the second part will increment. This will be generated regardless timestamping is enabled or not or even if there is a servo or not.

The 1PPS can be adjusted only when the local time counter is adjusted. For example when the frequency is increased or there is a jump in time. The local time counter can be adjusted only if there is a servo and that servo is in slave state. So if there is no servo then the local time will not be adjusted to any other remote GMs.

The ptp-pin that is used here is just an example and needs to be set according to the schematic of the board.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/mchp-velocitysp-ptp:ltcs/ltc"
  : ltc-index: 1
    ptp-pins:
      ptp-pin:
      - index: 4
        function: 1pps-out

3. Disable 1PPS output

This will show how to stop generating 1PPS on that PTP port.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/mchp-velocitysp-ptp:ltcs/ltc[ltc-index='1']"
  :

4. Add PTP instance with 1 port and a servo

Configure the HW to behave like a ordinary clock. In case the HW will become a follower then it would synchronize its own local time according to the grandmaster. Otherwise if the HW will become a GM then it would provide the time to the network.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    ports:
      port:
      - port-index: 25
    mchp-velocitysp-ptp:servos:
      servo:
      - servo-index: 0
        servo-type: pi
        ltc-index: 0

5. Get PTP instance

Get the PTP instance and see all the status and all the default parameters

FETCH request message:

- "/ieee1588-ptp:ptp/instances/instance[instance-index='0']"

FETCH response message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    default-ds:
      clock-identity: 00-11-22-FF-FE-33-44-00
      priority1: 246
      priority2: 248
      domain-number: 0
      instance-enable: true
      external-port-config-enable: false
      max-steps-removed: 255
      instance-type: relay
    parent-ds:
      parent-port-identity:
        clock-identity: 00-00-00-00-00-00-00-00
        port-number: 0
      grandmaster-identity: 00-11-22-FF-FE-33-44-00
      grandmaster-clock-quality:
        clock-class: ieee1588-ptp:cc-default
        clock-accuracy: mchp-velocitysp-ptp:ca-time-accurate-unknown
      grandmaster-priority1: 246
      grandmaster-priority2: 248
      ieee802-dot1as-ptp:cumulative-rate-ratio: 0
    ports:
      port:
      - port-index: 25
        port-ds:
          port-state: disabled
          mean-link-delay: '0'
          log-sync-interval: -3
          log-min-pdelay-req-interval: 0
          port-enable: true
          ieee802-dot1as-ptp:as-capable: false
          ieee802-dot1as-ptp:mean-link-delay-thresh: '52428800'
          ieee802-dot1as-ptp:neighbor-rate-ratio: 0
          ieee802-dot1as-ptp:sync-receipt-timeout: 3
          ieee802-dot1as-ptp:use-mgt-log-gptp-cap-interval: false
          ieee802-dot1as-ptp:mgt-log-gptp-cap-interval: 0
          ieee802-dot1as-ptp:use-mgt-one-step-tx-oper: false
          ieee802-dot1as-ptp:mgt-one-step-tx-oper: 0
        timestamp-correction-port-ds:
          egress-latency: '0'
          ingress-latency: '0'
        external-port-config-port-ds:
          desired-state: disabled
    mchp-velocitysp-ptp:servos:
      servo:
      - servo-index: 0
        servo-type: pi
        ltc-index: 0
        offset: '0'
        state: 0
    mchp-velocitysp-ptp:automotive:
      profile: none
      oper-log-pdelay-req-interval: 1
      oper-log-sync-interval: 0
    mchp-velocitysp-ptp:l2:
      mac-address: 00-00-00-00-00-00
      mac-address-enable: false
      vlan: 1
      vlan-enable: false

When looking at the response there are some fields that are usufull to check both for status but also for debugging any issues:

  1. instance-enable: make sure that this is true (which is by default) otherwise the instance will not see any frames

  2. port-enable: make sure that this is true (which is by default) otherwise the port will not send or receive any frames.

  3. mean-link-delay: this will say what is the link delay between the port and the partner. The value is represented in nanoseconds with a 16 bit sub fractional port. If this value is bigger than the mean-link-delay-thresh then the port will not be as-capable meaning that the port state is disabled

  4. port-state: this will say what is the current port state. It can be in one of the following:

    1. master: it would send out SYNC and FOLLOW_UP frames with the information that it received on the slave port, or if the DUT is a GM with its own local timer.

    2. slave: it would receive SYNC and FOLLOW_UP frames from partner with the time information.

    3. disabled: the port will be in this state, if the port is not as-capable

    4. passive: the port will be in this state if there another port on the DUT that has the same information from the master.

  5. parent-port-identity: describes the partner port that send out the ANNOUNCE frame

  6. grandmaster-identity: describes the GM of the network

6. Delete PTP instance

Delete the PTP instance that was created.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance[instance-index='0']"
  :

7. Add relay with two ports

When adding multiple ports under a PTP instance and not having a servo then the PTP instance will behave as an relay as described in 802.1AS.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    ports:
      port:
      - port-index: 25
      - port-index: 26
When operating in this mode the local time is not updated to any remove grandmasters.

8. Add relay with 2 ports and a servo

There are many cases where you want to be able to run different TSN protocols like TAS or PSFP on top of the relay. As the relay will not adjust the local time it is required to add an end node which will adjust the local time that is used by TAS.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    ports:
      port:
      - port-index: 25
      - port-index: 26
    mchp-velocitysp-ptp:servos:
      servo:
      - servo-index: 0
        servo-type: pi
        ltc-index: 1

9. Add PTP instance enabling automotive bridge profile

There are cases when the Automotive Ethernet AVB Functional and Interoperability Specification(Auto GPTP) is need. The main differences between Auto GPTP and GPTP are:

  1. Grandmaster Information and Topology: there should not be any Announce messages in the topology as there is no BMCA running because it presumes that the topology doesn’t change and it is know from start which is the GM

  2. asCpable: If the port has a link, then it presumes that the port is asCapable, in this way it improves the bring up time of the network

  3. initialLogPdelayReqInterval: there is an initial interval of the peer delay request (1 frame per second) and it is using this interval until the mean path delay is stabalized. The standard doesn’t explain what means stabalized but in implementation it means 2 consecutive mean path delays to have the same value.

  4. operLogPdelayReqInterval: the interval of peer delay requests after the link has stablized. (1 frame every 2 second).

  5. syncReceiptTimeout: In case the AED-B stops receiving Sync frames, then it should continue to send out frames with the last received information, or if the AED-B doesn’t receive at all Sync frames from beginning then it is required for AED-B to start to send own Sync frames with a fix preciseOriginTimestamp.

To be able to configure that there is not a single configuration that needs to be set but multiple ones to get the full configuration.

Here is an example for configuring an automotive bridge

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    default-ds:
      external-port-config-enable: true
    mchp-velocitysp-ptp:automotive:
      profile: bridge
    ports:
      port:
      - port-index: 25
        external-port-config-port-ds:
          desired-state: slave
      - port-index: 26
        external-port-config-port-ds:
          desired-state: master

10. Add PTP instance enabling automotive grandmaster profile

This is similar with the previous configuration with the only difference being the automotive profile and the port states.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    default-ds:
      external-port-config-enable: true
    mchp-velocitysp-ptp:automotive:
      profile: gm
    ports:
      port:
      - port-index: 25
        external-port-config-port-ds:
          desired-state: master
      - port-index: 26
        external-port-config-port-ds:
          desired-state: master

11. Allow to configure the MAC and VLAN to be used by PTP

There are configuration where is required to set a custom MAC address and add a VLAN tag.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    mchp-velocitysp-ptp:l2:
      mac-address: 00-11-22-33-44-55
      mac-address-enable: true
      vlan: 100
      vlan-enable: true
    ports:
      port:
      - port-index: 25
      - port-index: 26

12. Enable transparent clock with 1-step transmission

There are configuration where is required to set the HW as transparent clock using 1-step timestamping. The only supported transparent clock is P2P-TC.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    default-ds:
      instance-type: p2p-tc
    ports:
      port:
      - port-index: 25
        port-ds:
          ieee802-dot1as-ptp:use-mgt-one-step-tx-oper: true
          ieee802-dot1as-ptp:mgt-one-step-tx-oper: 1
      - port-index: 26
        port-ds:
          ieee802-dot1as-ptp:use-mgt-one-step-tx-oper: true
          ieee802-dot1as-ptp:mgt-one-step-tx-oper: 1

13. How to do the calibration of the device

To be able to precisely synchronize the device is required to calculate the what are the latencies on the device. To be able to do this the following setup is required:

                +---------+
                | Oscillo |
     +----------+ scope   +-----------+
     |          |         |           |
1PPS |          +---------+           | 1PPS
     |                                |
     |                                |
+----+----+                      +----+----+
|         |     Ethernet         |         |
|   DUT   +----------------------+  Master |
|         |                      |         |
+---------+                      +---------+

Where:

  • DUT: is the device that needs to be calibrated

  • Master: is a device that was already calibrated and it would be have the of the GM in the configuration

  • Oscilloscope: It is a oscilloscope that has 1PPS from each of the devices.

The purpose of the oscilloscope is to compare the 1PPS signals that come from the devices and once they are aligned it means that the 2 devices are synchronized and calibrated.

First step to calibrate the devices is to enable PTP on the DUT and make it to synchronized to the master.

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    ports:
      port:
      - port-index: 25
    mchp-velocitysp-ptp:servos:
      servo:
      - servo-index: 0
        servo-type: pi
        ltc-index: 0

Then it is required to enable the 1PPs output on the DUT:

iPATCH request message:

- ? "/ieee1588-ptp:ptp/mchp-velocitysp-ptp:ltcs/ltc"
  : ltc-index: 0
    ptp-pins:
      ptp-pin:
      - index: 4
        function: 1pps-out

Once the offset leaf under the servo has an value of +/- few nanoseconds then we can start to adjust the ingress/egress latencies.

First it is required to have the correct mean-link-delay. To be able to calculate this we need to look at the current mean-link-delaay and then add this value to both ingress-latency and egress-latency leafs. You need to take also in consideration the length of the cable, for each 1m length the cable introduces a 4ns delay.

Once the mean-link-delay has the expected value, we can focus on the 1PPS signals to make them align. To align them we need to look at the oscilloscope and measure what is the current difference between them. If the difference is for example 10ns then we need to subtract 5ns from ingress-latency and add 5ns to egress latency or the other way around. This depends on the 1PPS signal that comes from the slave, if it is before or if it is after the 1PPS from the master. If the 1PPS signal from the slave is after the 1PPS from the master, then we add the value to ingress and subtract from egress, if the 1PPS signal from the slave is before the 1PPS from slave, then we add the value to egress and subtract from ingress.

To update the ingress-latency and egress-latency the following request can be used:

iPATCH request message:

- ? "/ieee1588-ptp:ptp/instances/instance"
  : instance-index: 0
    ports:
      port:
      - port-index: 25
        timestamp-correction-port-ds:
          egress-latency: '65536'
          ingress-latency: '65536'

The values that are set here, are nanoseconds with 16 bit subfractional part. Meaning for example a value of 65536 means 1ns.

These measurements needs do be done for each of the ports and for each of the speed that the port supports.

Once the values are obtained, these values can be set in the board configuration file, such that are persistent. For example it can be like this:

  timestamp:
    calibrations:
      - idx: 0
        calibration:  # profile 0
          - type: SPEED_10MBIT
            rx: 10000
            tx: 10000
          - type: SPEED_100MBIT
            rx: 2000
            tx: 2000
          - type: SPEED_1000MBIT
            rx: 1000
            tx: 1500
          - type: SPEED_2500MBIT
            rx: 100
            tx: 110
          - type: SPEED_10000MBIT
            rx: 10
            tx: 15

      - idx: 1
        calibration:  # profile 1
          - type: SPEED_10MBIT
            rx: 19000
            tx: 1024
          - type: SPEED_100MBIT
            rx: 10000
            tx: 1024
          - type: SPEED_1000MBIT
            rx: 14000
            tx: 1024

The values of the ingress-latency correspond to the rx and the egress-latency correspond to tx. The values type for rx and `tx`is nanosecond, meaning that the latencies need to be shifted to right by 16 before they are set.