【開機自動從網絡獲取日期和時間】
在電腦linux虛擬機上交叉編譯ntpdate。
參考資料:https://blog.csdn.net/ZLK1214/article/details/120262773
cd ~/Downloads
wget https://downloads.nwtime.org/ntp/ntp-4.2.8p18.tar.gz
tar xf ntp-4.2.8p18.tar.gz
cd ntp-4.2.8p18
export PATH=$PATH:/home/oct1158/Downloads/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-linux-gnueabihf/bin
./configure --host=arm-none-linux-gnueabihf --with-yielding-select=yes --with-openssl-incdir=/home/oct1158/Downloads/openssl-1.1.1w/_install/usr/local/include --with-openssl-libdir=/home/oct1158/Downloads/openssl-1.1.1w/_install/usr/local/lib
make
make install DESTDIR=$(pwd)/_install
cd _install
sudo chown -R root:root usr
tar czf ntp-4.2.8p18-binary.tar.gz usr
cp ntp-4.2.8p18-binary.tar.gz /var/www/html/oct1158
fedora42編譯ntp-4.2.8p18時,提示configure: error: could not locate pthread_detach()。
解決方案:
修改configure文件,找到第23134行的pthread_detach(NULL),改成pthread_detach(0)。
sntp/configure的第13735行也要做同樣的修改。
板子上:
mount /dev/mmcblk1p2 /mnt
cd /mnt
wget https://192.168.2.140/oct1158/ntp-4.2.8p18-binary.tar.gz --no-check-certificate
(板子上自己編譯的busybox的wget是支持https的,但幸狐的buildroot根文件系統的wget不支持https)
tar xzf ntp-4.2.8p18-binary.tar.gz -C /
(板子上自己編譯的busybox的tar是支持gzip壓縮格式的,但幸狐的buildroot根文件系統的tar不支持gzip格式)
cd ~
umount /dev/mmcblk1p2
測試命令:
[root@luckfox-rv1106 ~]# ntpdate cn.pool.ntp.org
20 Jun 06:05:55 ntpdate[595]: step time server 84.16.73.33 offset -28799.489413 sec
[root@luckfox-rv1106 ~]# date
Fri Jun 20 06:05:59 UTC 2025
[root@luckfox-rv1106 ~]#
可將/usr/local/sbin/ntpdate cn.pool.ntp.org加入/etc/init.d/rcS,開機自動校對時間。