cancel
Showing results for 
Search instead for 
Did you mean: 

How do I enable LinuxPTP PPS Output?

CodeRunner
Associate II

I know that to get PPS output on the Ethernet PPS Pin PG8 that the device tree has to configure the pin for AF11. I also believe that PPS has to be enabled somehow? ​On some embedded Linux systems there is a /sys/class/ptp/ptp0/pps_enable variable to enable the PPS output with PTP but I am not seeing it. I also see PPS code such as the dwmac5_flex_pps_config function in the stmmac Ethernet driver. What tells OpenSTLinux to enable PPS? Is there a variable that needs to be set using setvar at boot? I have utilized the LinuxPTP recipe and can run ptp4l in OpenSTLinux. If we can get it working on the STM32MP1 we desire to use the PTP PPS signal synchronized to a PTP master. We are using the STM32MP157C-DK2 for evaluation.

3 REPLIES 3
AntonioST
ST Employee

In Linux v4.19 the support for ptp on stmmac ethernet controller is still not complete.

With next LTS kernel v5.4 the situation will be far better. This kernel will be part of next openSTlinux release.

In mean-time, to use LinuxPTP you need to apply a set of patches.

One relevant clock is disabled, so you need to enable it in the devicetree of TF-A. In TF-A code execute

sed -i s/CLK_ETH_DISABLED/CLK_ETH_PLL4P/ fdts/stm32mp157c-ed1.dts fdts/stm32mp157a-dk1.dts

then recompile and install it. At Linux prompt you can verify that the clock is enabled with

grep ethptp_k /sys/kernel/debug/clk/clk_summary

Then, in the devicetree of Linux kernel you need to enable the pin PG8 on AF11, as you already mention (here I'm quickly adding it in arch/arm/boot/dts/stm32mp157-pinctrl.dtsi)

        pinmux = <STM32_PINMUX('G', 5, AF11)>, /* ETH_RGMII_CLK125 */
+                <STM32_PINMUX('G', 8, AF11)>, /* ETH_PPS_OUT */
                 <STM32_PINMUX('G', 4, AF11)>, /* ETH_RGMII_GTX_CLK */

and you also need to add the clock in the ethernet node (here I quickly add it in arch/arm/boot/dts/stm32mp157c.dtsi)

        clock-names = "stmmaceth",
                      "mac-clk-tx",
                      "mac-clk-rx",
+                     "ptp_ref",
                      "ethstp";
        clocks = <&rcc ETHMAC>,
                 <&rcc ETHTX>,
                 <&rcc ETHRX>,
+                <&rcc ETHPTP_K>,
                 <&rcc ETHSTP>;

Finally, you need to add the following patches to the kernel

and recompile

With this setup you can now run on the board as slave

ptp4l -m -i eth0 -s

and on another computer as master (both in the same subnet)

ptp4l -m -i eth0

You can also control the output on PG8 through /sys/class/ptp/ptp0/period

CodeRunner
Associate II

Thanks! Your detailed instructions are greatly appreciated.

YZHU.1
Associate II

We are now using new stm32mp1 kernel v5.4(en.FLASH-stm32mp1-openstlinux-5-4-dunfell-mp1-20-06-24 ) and have some difficulties to make PTP PPS working on 157C DK2 kit. Wwe need more specific instructions:

  1. is it still necessary to add those 4 patches you mentioned above on kernel v5.4?
  2. is it still necessarily to enable clock CLK_ETH_PLL4P in the devicetree of TF-A and recompile and install on kernel v5.4?
  3. what should I see when send command "grep ethptp_k /sys/kernel/debug/clk/clk_summary" ?

This what I saw in my DK2, I guess th clock is obviously not enabled:

 ethptp_k               0    0    0      0     0   0 50000

4. what should I send to  device "/sys/class/ptp/ptp0/period" to control PG8 as PPS ? such as "echo 1 > /sys/class/ptp/ptp0/period" ?