明远智睿技术论坛

 找回密码
 立即注册
搜索
查看: 2901|回复: 0
打印 上一主题 下一主题

NTP网络时钟编译与移植

[复制链接]

56

主题

60

帖子

644

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
644
跳转到指定楼层
楼主
发表于 2020-4-3 15:32:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
主机平台: UBUNTU14.04
硬件平台:明远智睿MY-IMX6UL-EK140
内核版本 :linux-4.1.15
交叉编译链:
arm-poky-linux-gnueabi(gcc version 7.3.0 )
版本:
ntp-4.2.8p14.tar.gz

1.下载ntp源码包
http://www.ntp.org/downloads.html

2.在虚拟机中进行解压
$ tar xzf ntp-4.2.8p14.tar.gz

3.修改ntp配置
$ cd ntp-4.2.8p14
$ vi ntpd/ntp_loopfilter.c  //增加宏定义
    #ifndef MOD_NANO
    #define MOD_NANO  0x2000
    #endif


4.配置
配置交叉编译工具:
$ source /home/myzr/my-work/03_toolchain/fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-neon-toolchain-4.9.88-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
配置configure文件:
./configure --prefix=$PWD/install --exec-prefix=$PWD/install --host=arm-poky-linux-gnueabi  --with-yielding-select=yes


5.编译安装
$ make
$ make install



6.打包执行文件
$ cd install/bin/
$ tar cjf ntp_bin.tar.bz2 *


7.移植到开发板中
把打包好的ntp_bin.tar.bz2复制到开发板中,并解压到开发板的bin目录:
$ tar jxvf ntp_bin.tar.bz2 -C /bin/


8.测试
# ntpdate 0.pool.ntp.org
可能会提示缺少库libcrypto.so.1.0.2
把交叉编译工具当中的库复制到开发板中,库路径:~/my-work/03_toolchain/fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa7hf-neon-toolchain-4.9.88-2.0.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/lib/libcrypto.so.1.0.2
重新输入命令同步时间:
# ntpdate 0.pool.ntp.org
可看到:
3 Apr 06:27:57 ntpdate[440]: step time server 120.25.115.20 offset +48352479.963239 sec
查看系统时间:
# date
Fri Apr  3 06:29:05 UTC 2020












































回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|明远智睿  

GMT+8, 2024-4-20 14:58 , Processed in 0.074761 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表