我有三个 Beaglebone Green Wireless (BBGW),它们都出现了相同的错误。系统时间正在重置。所有这些板子都曾使用过,全新的 Beaglebone Green 也出现了同样的错误。
我使用干净的图像进行所有测试Debian 9.9 IoT
。我清理了内部存储器和 uboot,并从 SD 卡运行所有内容。唯一的变化是连接到 wifi 以运行时间同步。
我的 TZ 中的正确时间是sex fev 21 12:55:52 -03 2020
UTC Fri Feb 21 15:56:06 UTC 2020
。但它显示 UTC 为 12:56。
Beaglebone 默认采用 UTC 时间。我使用 Beaglebone 绿色版(非无线)进行了测试,结果与我预期的一样。(这是否可能与硬件有关,或者与某些内部 EEPROM 配置有关?)
运行多次timedatectl
返回:
debian@beaglebone:~$ timedatectl
Local time: Fri 2020-02-21 12:53:54 UTC
Universal time: Fri 2020-02-21 12:53:54 UTC
RTC time: Fri 2020-02-21 12:53:53
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
debian@beaglebone:~$ timedatectl
Local time: Fri 2020-02-21 15:54:02 UTC
Universal time: Fri 2020-02-21 15:54:02 UTC
RTC time: Fri 2020-02-21 12:53:55
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
debian@beaglebone:~$ timedatectl
Local time: Fri 2020-02-21 12:53:56 UTC
Universal time: Fri 2020-02-21 12:53:56 UTC
RTC time: Fri 2020-02-21 12:53:55
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
hwclock --debug输出:
hwclock from util-linux 2.29.2
Using the /dev interface to the clock.
Last drift adjustment done at 1582299529 seconds after 1969
Last calibration done at 1582299529 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2020/02/21 12:56:50
Hw clock time : 2020/02/21 12:56:50 = 1582289810 seconds since 1969
Time since last adjustment is -9719 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2020-02-21 12:56:49.029564+0000
多次 hwclock 调用:
debian@beaglebone:~$ sudo hwclock
2020-02-21 13:00:52.113529+0000
debian@beaglebone:~$ sudo hwclock
2020-02-21 10:00:46.983797+0000
debian@beaglebone:~$ sudo hwclock
2020-02-21 10:00:47.934507+0000
debian@beaglebone:~$ sudo hwclock
2020-02-21 13:01:00.852430+0000
debian@beaglebone:~$ sudo hwclock
2020-02-21 13:01:01.721401+0000
时区文件:
debian@beaglebone:~$ cat /etc/timezone
Etc/UTC
我也尝试过使用--utc 和--localtime 更改 hwclock。
更多测试。我已禁用 ntp: sudo timedatectl set-ntp 0
,在使用 设置时钟后sudo timedatectl set-time '2019-10-31 16:24'
,然后我重新启用 ntp 同步 (timesyncd)。
这是结果。hwclock 的时间设置错误。在 set-ntp 0 期间,时钟设置少了 3 个小时。
debian@beaglebone:~/DebianDogePack/dogepack_installer/etc/guidedoge$ timedatectl
Local time: Fri 2020-02-21 17:27:14 UTC
Universal time: Fri 2020-02-21 17:27:14 UTC
RTC time: Thu 2019-10-31 16:25:39
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
debian@beaglebone:~/DebianDogePack/dogepack_installer/etc/guidedoge$ timedatectl
Local time: Fri 2020-02-21 14:27:08 UTC
Universal time: Fri 2020-02-21 14:27:08 UTC
RTC time: Thu 2019-10-31 16:25:39
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
debian@beaglebone:~/DebianDogePack/dogepack_installer/etc/guidedoge$ timedatectl
Local time: Fri 2020-02-21 17:27:15 UTC
Universal time: Fri 2020-02-21 17:27:15 UTC
RTC time: Thu 2019-10-31 16:25:40
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
debian@beaglebone:~/DebianDogePack/dogepack_installer/etc/guidedoge$ timedatectl
Local time: Fri 2020-02-21 14:27:10 UTC
Universal time: Fri 2020-02-21 14:27:10 UTC
RTC time: Thu 2019-10-31 16:25:41
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
debian@beaglebone:~/DebianDogePack/dogepack_installer/etc/guidedoge$ timedatectl
Local time: Fri 2020-02-21 14:27:11 UTC
Universal time: Fri 2020-02-21 14:27:11 UTC
RTC time: Thu 2019-10-31 16:25:42
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
debian@beaglebone:~/DebianDogePack/dogepack_installer/etc/guidedoge$ timedatectl
Local time: Fri 2020-02-21 17:27:19 UTC
Universal time: Fri 2020-02-21 17:27:19 UTC
RTC time: Thu 2019-10-31 16:25:43
Time zone: Etc/UTC (UTC, +0000)
Network time on: yes
NTP synchronized: no
RTC in local TZ: no
我尝试过更改我的时区。本地时间的小时误差甚至更大(3 小时误差 + 3 小时时区)。
答案1
Debian for Beaglebone 用于connman
控制 wifi 连接。当连接到 wifi 时,它使用agent on
启用connmand
,并且还具有 NTP 服务器。
connmand
尝试从网络设置时区,并尝试使用其内部 NTP 服务器设置时间。
解决方案是禁用connmand
NTP,只保留它systemd-timesyncd
。为此,请编辑connman
配置文件:
sudo nano /var/lib/connman/settings
编辑全局配置如下:
[global]
OfflineMode=false
TimeUpdates=manual
TimezoneUpdates=manual