找回密码
 立即注册

QQ登录

只需一步,快速开始

打印 上一主题 下一主题
开启左侧

[NUC980] Precision Time Protocol (PTP): Synchronizing Time on NUC980

[复制链接]
跳转到指定楼层
楼主
1. Introduction

In many industrial automation, power grid, and telecommunications applications, standard NTP (Network Time Protocol) is insufficient because it only offers millisecond-level accuracy. IEEE 1588, also known as the Precision Time Protocol (PTP), provides a solution by using hardware timestamping to achieve microsecond or even nanosecond-level synchronization across a local area network.

While IEEE 1588V1 was the original standard, IEEE 1588V2 (PTPv2) improved precision and reduced network overhead. The Nuvoton NUC980 series features built-in hardware support for PTP, making it an excellent choice for time-sensitive networking tasks.


2. Buildroot and Kernel Configuration

To enable PTP support, you must configure both the Linux kernel (to interface with the hardware clock) and the Buildroot target packages (to provide the user-space tools).

Step A: Linux Kernel Settings

Navigate to your kernel configuration: $ make linux-menuconfig

Enable the following paths to ensure the driver generates the /dev/ptp0 interface:

  • Networking support → Networking options →

  • Timestamping in PHY devices

  • Device Drivers →

  • PTP clock support → <*> PTP clock support


Step B: Buildroot Tool Selection

Navigate to your Buildroot configuration: $ make menuconfig

Select the necessary networking utilities:

  • Target packages → Networking applications →

  • ethtool (Used for verifying hardware support)

  • Target packages → Networking applications →

  • linuxptp (Provides ptp4l and phc2sys)


Run make to build the images.


3. Hardware Setup

Connect two NUC980 boards directly using an Ethernet cable.

Important: Ensure that both boards have unique MAC addresses. You can set this in your bootloader (U-Boot) or via the ifconfig command before starting the PTP service to avoid network conflicts.


4. Step-by-Step SynchronizationBoard A: The Grand Master

Board A will act as the reference time source for the network. We will run ptp4l using the Layer-2 Ethernet transport (-2).


# ptp4l -i eth0 -2 -m



  • Behavior: The board will initially search for a master. Once it timeouts, it will assume the Grand Master role.


Board B: The Client (Slave)

Board B will synchronize its Hardware Clock to Board A.


# ptp4l -i eth0 -2 -s -m



  • -s: Forces the node into Slave mode.

  • -m: Prints logs to the console so you can see the offset calculations.


Step 5: Synchronizing the System Clock

By default, ptp4l only synchronizes the PTP Hardware Clock (PHC) on the Ethernet chip. To update the actual Linux system time (the clock you see when typing date), you must use phc2sys to bridge the two.

Run ptp4l in the background, then execute:


# ptp4l -i eth0 -2 -s &# phc2sys -s /dev/ptp0 -c CLOCK_REALTIME -w -m -R 0.2



  • -s /dev/ptp0: Defines the source (the hardware clock).

  • -c CLOCK_REALTIME: Defines the destination (the Linux system clock).

  • -w: Waits for ptp4l to be synchronized before starting.

  • -R 0.2: (Optional) Sets the update rate to 0.2 Hz, meaning the system clock will update once every 5 seconds. Default is 1 Hz.

  • -m: (Optional) Remove this to disable console output once you verify it is working.



Conclusion

By leveraging the NUC980’s hardware timestamping and the linuxptp stack, you can achieve highly accurate synchronization with very little CPU overhead. This setup ensures that your distributed logs, sensor data, and control signals remain perfectly aligned across your network.









分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 顶 踩
牛卧堂
回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies |上传

本版积分规则

新唐MCU