Audio clock synchronization via PTP on IMX8MP

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello Matej,

Thank you for reaching out with your question about synchronizing the audio clock with the Ethernet clock using PTP on the iMX8MP. It sounds like you’ve made significant progress, and I’d be happy to help you further.

To achieve synchronization using phc2sys, both clocks need to be recognized by the system as PTP hardware clocks. Here are some steps and considerations to help you proceed:

  1. Device Tree Configuration: Your device tree setup seems mostly correct. Ensure that the custom audio clock is defined with the appropriate properties. Using a “fixed-factor-clock” is suitable if the clock is derived from a parent clock with a fixed relationship.

  2. Clock Driver: Your custom clock driver should ensure that the clock is registered with the kernel’s clock framework. If the driver isn’t loading, check the following:

    • Ensure the compatible string in the device tree matches the one expected by the driver.
    • Verify that the driver is compiled and included in the kernel image.
    • Check dmesg logs for any errors or messages related to the driver loading process.
  3. Exposing Clocks to /dev/: Typically, only network interface clocks are exposed as PTP hardware clocks under /dev/ptp*. For a custom clock, you might need to explore kernel support for exposing it as a PTP clock. This could involve more advanced driver development, potentially using existing PTP clock drivers as a reference.

  4. Using phc2sys: Once your clocks are correctly exposed, you can use phc2sys to synchronize them. The command you attempted (phc2sys -s /dev/ptp0 -c /dev/custom_audio_clock -w) is correct in format, but it requires both clocks to be visible under /dev/.

  5. Troubleshooting: If the custom clock is not visible, revisit the driver and device tree configuration. Ensure that the clock is properly registered and that there are no errors during boot or module loading. You might also need to consult the Linux kernel documentation on clock and PTP support for more advanced configurations.

By ensuring that your custom clock is properly registered and exposed, you should be able to achieve the desired synchronization with the Ethernet clock using PTP.

I hope this helps, and I wish you success in your project!

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

https://community.nxp.com/t5/Layerscape/phc2sys-Waiting-for-ptp4l/m-p/1433168.