1、ntp源码包:ntp-dev-4.3.91.tar.gz(可下载地址:http://www.ntp.org/downloads.html)
2、交叉编译工具:arm-linux-gnueabihf-gcc     解压ntp源码包到指定目录 tar -zxvf ntp-dev-4.3.91.tar.gz

进入刚解压目录,并配置cd ntp-dev-4.3.91,在ntpd/ntp_loopfilter.c中增加下面的宏定义
#ifndef MOD_NANO
#define MOD_NANO  0x2000
#endif
./configure --prefix=$PWD/install --exec-prefix=$PWD/install --host=arm-none-linux-gnueabi CC=arm-none-linux-gnueabi-gcc


出现错误:
checking for pthread_kill_other_threads_np... no
checking for LinuxThreads implementation... no
checking for LinuxThreads consistency... no
checking if pthread_create() works... yes
checking if select yields when using pthreads... cross
configure: error: crossing compiling: use --with-yielding-select=yes|no|manual

执行命令:satellite@ubuntu:~/share/ntp-dev-4.3.91$ ./configure --prefix=$PWD/install --exec-prefix=$PWD/install --host=arm-none-linux-gnueabi CC=arm-none-linux-gnueabi-gcc --with-yielding-select=yes
    此次,在安装目录下成功生成了Makefile文件。

编译并安装  make
出现错误:
ntp_loopfilter.c: In function 'local_clock':
ntp_loopfilter.c:760: error: 'MOD_NANO' undeclared (first use in this function)
ntp_loopfilter.c:760: error: (Each undeclared identifier is reported only once
ntp_loopfilter.c:760: error: for each function it appears in.)

在ntpd/ntp_loopfilter.c中增加下面的宏定义 #ifndef MOD_NANO
#define MOD_NANO  0x2000
#endif

make  install

4、安装完之后在安装目录下install文件夹会有三个文件夹产生ls
bin  libexec  sbin  share

bin目录中的命令文件有如下: ls bin
calc_tickadj  ntpd  ntpdate  ntpdc  ntp-keygen  ntpq  ntptime  ntptrace  ntp-wait  sntp  tickadj  update-leap


5、把bin目录下的需要的命令文件拷贝到开发板的/bin目录下,或者全部拷贝过去
ntp客户端需要用到的命令有ntpdate,ntp服务器需要用到的命令有ntpd

6、ntp客户端

拷贝ntpdate命令到开发板之后执行以下命令 ntpdate  time.buptnet.edu.cn(或者ntpdate  202.112.10.60)
说明:time.buptnet.edu.cn是北京时间的NTP服务器(IP:202.112.10.60)
提示:Jan 01:19:17 ntpdate[2179]: no server suitable for synchronization found

出现以下问题: ntpdate time.buptnet.edu.cn

ntpdate:error while loading shared libraries: libcap.so.2: cannot open shared object file:
no such file or directory

则解决办法:在安装交叉编译工具的目录arm-linux-gnueabihf/usr/lib中有文件libcap.so.2和libattr.so.1直接拷贝到开发板/lib目录下

拷贝完以上两个文件即可完成时间同步 ntpdate 0.pool.ntp.org
step time server 110.75.186.248 offset 1460632666.423442 sec
 date
Thu Apr 14 20:49:19 CST 2016
从网络上获取到的系统时间写入硬件时钟中,则使用命令 hwclock -w

每次开机设备自动同步时间,可在启动脚本中加入命令行:ntpdate 0.pool.ntp.org

或者上位机发给ARM,ARM获取后传入系统时间 date -s "2018-10-31 11:20:35"

7,ntp服务器 (因为用不着,所以暂时没有测试)
ntp服务器的开发板和ntp客户端的系统的网络要正常连接

在要做服务器的开发板上编辑文件/etc/ntp.conf
   执行命令: vi  /etc/ntp.conf
#restrict default nomodify notrap noquery
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server  127.127.1.0        # local clock
fudge   127.127.1.0  stratum 5
driftfile /var/lib/ntp/drift
broadcastdelay   0.008
keys                     /etc/ntp/keys

开启ntp服务器 ntpd  -c /etc/ntp.conf

ntp服务器开启后五到十几分钟才能在客户端系统中执行以下命令,否则时间同步会失败

ntpdate  192.168.1.X  (192.168.1.X修改成你的服务器的IP地址)

arm交叉编译ntpdate与服务器进行时间同步相关推荐

  1. linux ntpdate交叉编译,arm交叉编译ntpdate与服务器进行时间同步

    1.ntp源码包:ntp-dev-4.3.91.tar.gz(可下载地址:http://www.ntp.org/downloads.html) 2.交叉编译工具:arm-linux-gnueabihf ...

  2. Linux使用ntpdate和ntpd进行时间同步

    生产环境关联主机间常要求时间一致,若有NTP时间同步服务器,可配置各主机与时间同步服务器同步时间. 1.使用ntpdate进行时间同步 安装ntp客户端: yum install ntpdate 同步 ...

  3. 配置NTP服务器进行时间同步

    配置NTP服务器进行时间同步 在集群部署服务的时候如果集群的时间各部相同会导致业务上的问题,所以可以找一个机器,作为时间服务器,所有的机器与这台集群时间进行定时的同步 时间服务器搭建ntp服务 检测n ...

  4. DZ先生怪谈国标28181之利用crontab为linux服务器做时间同步

    1. 自述 关于时间同步,必须一个作为服务端(server)端,一个作为Client端.关于server端,上章DZ先生已经教了WIN7做NTP服务器的方法:https://blog.csdn.net ...

  5. mDNS实现之Bonjour与Avahi(一)——win/linux/arm交叉编译

    0.Part2:mDNS实现之Bonjour与Avahi(二)--win/linux/arm交叉编译_平凡之路-CSDN博客1.BonjourBonjour - Apple Developer● 源码 ...

  6. CentOS系统中如何搭建NTP时间服务器(时间同步)

    CentOS系统中如何搭建NTP时间服务器(时间同步) CentOS系统中如何搭建NTP时间服务器(时间同步) 本文由:安徽京准公司提供,转载需通过授权@ 网络时间协议(NTP)用来同步网络上不同主机 ...

  7. 时间同步服务器:时间同步的三种方式

    一.时间同步服务器简述 时间同步服务器,顾名思义就是来同步时间的.在集群中同步时间有着十分重要的作用,负载均衡集群或高可用集群如果时间不一致,在服务器之间的数据误差就会很大,寻找数据便会成为一件棘手的 ...

  8. linux ntpdate 更新时间,Linux时间同步:ntpd,ntpdate

    ntpd VS ntpdate 两者有个比较实质性的差异是,ntpd在实际同步时间时是一点点的校准过来时间的,最终把时间慢慢的校正对.而ntpdate不会考虑其他程序是否会阵痛,直接调整时间.一个是校 ...

  9. Ubuntu12.04下arm交叉编译环境的建立

    http://blog.csdn.net/heyangya2009/article/details/5424376 备注:ubuntu12.04+Android+Real6410 在主机上用来编译其他 ...

最新文章

  1. 节约能源,做个合格的环保主义者,不要做网络灾民
  2. C语言交换两个数的值与形参与实参理解
  3. boost::overloaded_function用法的测试程序
  4. java单元格合并多列_ElementUI表格列相同值自动合并单元格( 多列 )
  5. 点餐系统的设计(一)
  6. 这两年亚马逊创业都是一个非常火热的话题
  7. NSURLErrorDomain 对照
  8. 【AI手机三国杀】三星Bixby闯入战场,AI功能集成颠覆人机交互
  9. 一款免费的网络时间校准小程序
  10. Git 基础(七)—— 远程仓库(GitHub)
  11. Linux三剑客--grep
  12. 润乾报表如何固定表头
  13. 电离层对高分辨率星载SAR成像的影响1——电离层的相关定义
  14. 锐取电视墙服务器型号,锐取录播系统 CL4000系列多媒体录播一体机--投影时代产品专区...
  15. Python -- 关于函数的学习(五) — 传递任意数量的实参
  16. 反思腾讯:大数据与AI时代的危与机
  17. bt磁力种子与php文件,视频 | BT 种子和磁力链接是如何工作的?
  18. Dissect Certificate
  19. C#冷门系列之Lazy
  20. KITTI下使用SGBM立体匹配算法获得深度图

热门文章

  1. 咸鱼软件应用—Cura3D切片
  2. 百度地图api周边搜索功能,用单选按钮切换搜索类型
  3. 配置GeeM2传奇登陆器详细图文教程
  4. 【数据库基础笔记】3、约束和隔离
  5. 学习突围3 - 关于精力
  6. 深入浅出——MVP模式
  7. Qlikview---变量
  8. 软件开发者的终极梦想:揭秘谷歌编程面试
  9. 怎样开发微信小程序(最初的页面)
  10. 吉他入门乐理知识精髓篇