Project

General

Profile

LinuxPTP: 1PPS output is running at 0.1Hz

Added by V J about 6 years ago

Hi
We have started implementing PTP on the MitySOM-5CSX board.
The first step is to get software timestamping to work, then hardware timestamping (since the Eth phy KSZ9031RNX does not seem to support PTP we are a bit unsure how well hardware timestamping will work.)

Our steps:
1: Compiling and installing linuxptp (http://linuxptp.sourceforge.net)
2: In Qsys I have enabled “Enable EMAC1 precision Time Protocol (PTP) FPGA interface”
- Connecting emac_ptp_ref_clock to h2f_user0_clk (100 MHz)
- Routed out the ptp_pps_o signal to a spare IO pin on the development board.

After running:

hwstamp_ctl -i eth0 -r 1 -t 1

the ptp_pps_o signal starts to toggle, but at 1/10 of expected speed, i.e. 0.1Hz.

We suspect that the PTP engine is using an incorrect clock, and that we need to update the device tree to get correct frequency source. How can we do that?

We are running Krogoth with 4.1.22-ltsi-rt.
BR
Vidar

picture719-1.png (55.4 KB) picture719-1.png PTP connections

Replies (6)

RE: LinuxPTP: 1PPS output is running at 0.1Hz - Added by Alexander Block about 6 years ago

Vidar,

If you look through your boot log do you see either of the following debug printouts?

PTP rate #

or
PTP uses main clock

According to the stmmac driver device tree documentation ( Documentation / devicetree / bindings / net / stmmac.txt) you would need to specify the PTP reference clock node, clk_ptp_ref, in your device tree.

Alex

RE: LinuxPTP: 1PPS output is running at 0.1Hz - Added by V J about 6 years ago

Hi Alex

In /var/log/boot there are no PTP debug messages.
Looking into stmmac_main.c, these PTP messages are printed from function stmmac_init_ptp using "netdev_dbg". I am not sure if these debug prints are enabled on my system?

In /var/log/messages I have these PTP and PPS messages:

pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti giometti@linux.it
PTP clock support registered
...
socfpga-dwmac ff702000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
socfpga-dwmac ff702000.ethernet eth0: registered PTP clock

I have gone through the kernel .config and most of the pps and ptp options are enabled.

According to some info “out there” the 4.1.22 kernel needs patches for ptp, so I have upgraded the kernel to
socfpga-4.9.76-ltsi-RT, and recompiled linuxPTP.

I have changed the emac_ptp_ref_clock to use the external 100MHz clock coming from the FPGA (100 MHz).
This is the same clock I use to clock my dmas and pios in qsys.

I had problems identifying the various clocks in the device tree files so I have defined a 100MHz clock in socfpga.dtsi (not sure if this is the right way to do it),
and updated the clocks for the gmac1:

   clk_100m: clk_100m {
      compatible = "fixed-clock";
      #clock-cells = <0>;
      clock-frequency = <100000000>;   /* 100.00 MHz */
      clock-output-names = "clk_100m-clk";
   }; //end clk_100m (clk_100m)               
   //} 

   ...

      gmac1: ethernet@ff702000 {
         compatible = "altr,socfpga-stmmac", "snps,dwmac-3.70a", "snps,dwmac";
         altr,sysmgr-syscon = <&sysmgr 0x60 2>;
         reg = <0xff702000 0x2000>;
         interrupts = <0 120 4>;
         interrupt-names = "macirq";
         mac-address = [00 00 00 00 00 00];/* Filled in by U-Boot */
         clocks = <&emac1_clk &clk_100m> ;               
         clock-names = "stmmaceth", "clk_ptp_ref"; 
         resets = <&rst EMAC1_RESET>;
         reset-names = "stmmaceth";
         snps,multicast-filter-bins = <256>;
         snps,perfect-filter-entries = <128>;
         tx-fifo-depth = <4096>;
         rx-fifo-depth = <4096>;
         status = "disabled";
      };

PPS output:
- has now changed from 0.1Hz to 0.25Hz
- the PPS signal is not locked to emac_ptp_ref_clock (which is connected to the 100MHz clock from the FPGA)

BR
Vidar

RE: LinuxPTP: 1PPS output is running at 0.1Hz - Added by V J about 6 years ago

Hi
I changed to use netdev_info (instead of netdev_dbg) logging in stmmac_main.c and then I get:

socfpga-dwmac ff702000.ethernet eth0: PTP rate 100000000
in /var/log/messages.

I then updated Qsys to use a 20MHz clock, and changed my clk_100 definition in socfpga.dtsi to 20MHz:
/var/log/messages then reports:

socfpga-dwmac ff702000.ethernet eth0: PTP rate 20000000

However, the PPS is still 0.25Hz so I think I am missing some key parameters.

BR
Vidar

RE: LinuxPTP: 1PPS output is running at 0.1Hz - Added by Daniel Vincelette about 6 years ago

Hi Vidar,

As a quick test can you output the clock you are using to a pin and verify its frequency on a scope?

Dan

RE: LinuxPTP: 1PPS output is running at 0.1Hz - Added by V J about 6 years ago

Hi Dan

All clocks have been checked on a scope and are running at expected frequencies.
My HPS clock is 100MHz, and the two clocks I have tested as a PTP reference runs at 100MHz (first test) and 20MHz (second test).

When I run:

phc_ctl /dev/ptp0 freq 100000 set 0.0 wait 10.0 get
I get:
phc_ctl[1398.606]: adjusted clock frequency offset to 100000.000000ppb
phc_ctl[1398.617]: set clock time to 0.000000000 or Thu Jan  1 01:00:00 1970
phc_ctl[1408.618]: process slept for 10.000000 seconds
phc_ctl[1408.619]: clock time is 2.503022080 or Thu Jan  1 01:00:02 1970
I.e 2.5 secs instead of 10 secs. It is the same result for both 20MHz and 100MHz PTP ref clock.

BR
Vidar

RE: LinuxPTP: 1PPS output is running at 0.1Hz - Added by V J almost 6 years ago

Theses issues are related to the stmmac driver.
See user forum: https://sourceforge.net/p/linuxptp/mailman/linuxptp-users/ for details.

Vidar

    (1-6/6)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)