1. 下載 ntp-4.2.8p8.tar.gz(注:ntpdate依賴openssl,需現編譯openssl)
2. 解壓
tar -zxf ntp-4.2.8p8.tar.gz
cd ntp-4.2.8p8
3. 在ntpd/ntp_loopfilter.c文件末尾增加"MOD_NANO"宏定義
#ifndef MOD_NANO
#define MOD_NANO 0x2000
#endif
4. 生成makefile文件
./configure --prefix=/usr/local/arm/ntp --host=arm-hisiv100nptl-linux CC=arm-hisiv100nptl-linux-gcc --with-yielding-select=yes --enable-openssl LIBS=-L/usr/local/arm/ssl/lib CPPFLAGS=-I/usr/local/arm/ssl/include --exec-prefix=/usr/local/arm/ntp
說明:prefix爲安裝目錄,host爲目標板交叉編譯工具鏈, --enable-openssl:ntpdate依賴openssl,CPPFLAGS:openssl頭文件,LIBS:openssl庫
5. 編譯並安裝
make
sudo make install
6. 編譯好的工具位於安裝目錄的bin文件夾中,拷貝需要的工具到arm板的/usr/sbin目錄中
遇到問題彙總:
1. 執行ntpdate ntp_server_IP,報錯:
no server suitable for synchronization found
原因:選擇的ntp時間服務器不合適,被服務器拒絕
解決方案: 選擇公開的ntp時間服務器,如us.ntp.org.cn