1. ntp简介
ntp用于时间同步,分为服务器和客户端两部分。在arm开发板上的一般为客户端。本文主要介绍客户端的移植以及配置。
2. 移植过程
2.1 下载ntp源代码
以下为官方下载网站
https://downloads.nwtime.org/ntp/4.2.8/ |
2.2 配置
./configure --prefix=/mydir --host=arm-none-linux-gnueabi CC=arm-linux-gnueabihf-gcc --with-yielding-select=yes |
2.3 编译和安装
执行 make && make install 便可以完成编译和安装。
此过程如果没有错误,可以在/mydir目录下找到生成的文件。
将/mydir/bin目录下的ntpdate拷贝到开发板即可。
2.4 运行
执行如下命令,可以同步时间
./ntpdate 52.231.114.183 |
蓝色部分是ntp服务器的地址,也可以更换成其他的。有一部分免费的ntp 服务器可以使用,但是比较容易失败。
3. 免费的ntp 服务器汇总
名称 | 说明 |
国家授时中心NTP服务器 | ntp.ntsc.ac.cn |
中国NTP快速授时服务 | cn.ntp.org.cn |
教育网 | edu.ntp.org.cn |