polygaryd
Posts: 6
Joined: Sun Jan 29, 2017 5:02 am

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 10, 2020 1:07 am

I followed all those steps and timesyncd is loaded enabled but inactive even after restarting it. Ntp was/still is active even after running the commands you posted to stop it and disable it. It gives no errors when entering the stop ntp* command but fails when trying to disable it. Saying no such file or directory. It also says unable to locate the package ntpd when purging it.

polygaryd
Posts: 6
Joined: Sun Jan 29, 2017 5:02 am

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 10, 2020 1:13 am

I changed the purge command from ntpd to ntp and it got rid of it without error. I was able to restart timesyncd and now it says active and has updated the time (in military time tho) without me doing anything else. Must have been a typo in your last command?

I also turned my firewall on my router back on so we will see what happens next time i boot up the pi. Hopefully it syncs the time as its supposed to now that i know its working in the pi itself.

beta-tester
Posts: 1354
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 10, 2020 5:53 am

polygaryd wrote:
Fri Jan 10, 2020 1:13 am
I changed the purge command from ntpd to ntp and it got rid of it without error. I was able to restart timesyncd and now it says active and has updated the time (in military time tho) without me doing anything else. Must have been a typo in your last command?
yes, it is possible. i haven't ntp services installed, so i assumed that it will be named ntpd... but as you said, it seems to be simply named ntp only.
polygaryd wrote:
Fri Jan 10, 2020 1:07 am
It gives no errors when entering the stop ntp* command but fails when trying to disable it. Saying no such file or directory.
and yes you are right, disabling the sevices requires the exact service name. a wildcard * is not allowed there. i didn't know that.

... thank you for feedback.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

rpi-pps0
Posts: 4
Joined: Sun Nov 10, 2019 7:56 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 24, 2020 3:28 am

From this thread:
[FIXED]: RPi as high precise NTP Server with GPS/PPS dev

@beta-tester: Some time ago you asked for a plot comparing userspace PPS discipline with kernel PPS discipline.

This is a plot of three ntpd disciplines:
First third: Network sync to a ethernet-connected Stratum 1 kernel PPS source
Middle third: Local sync to a user PPS source
Last third: Local sync to a kernel (hard) PPS source

The discontinuities in the plot are system reboots.
local-offset.png
local-offset.png (21.76 KiB) Viewed 542 times

beta-tester
Posts: 1354
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 24, 2020 1:22 pm

rpi-pps0 wrote:
Fri Jan 24, 2020 3:28 am
From this thread:
[FIXED]: RPi as high precise NTP Server with GPS/PPS dev

@beta-tester: Some time ago you asked for a plot comparing userspace PPS discipline with kernel PPS discipline.

This is a plot of three ntpd disciplines:
First third: Network sync to a ethernet-connected Stratum 1 kernel PPS source
Middle third: Local sync to a user PPS source
Last third: Local sync to a kernel (hard) PPS source
@rpi-pps0 thank you... very interesting... now i start thinking to recompile my kerne with enabling kernel PPS... but i have to recompile the kernel every time a new kernel update is coming... :|
maybe we can ask the RPi kernel maintainer to enable the option out of the box...

do you know, if there is a downside for none PPS users, when that option is enabled by default?
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

rpi-pps0
Posts: 4
Joined: Sun Nov 10, 2019 7:56 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 24, 2020 5:58 pm

To enable hard PPS you have to disable dynticks.

The Raspbian distro maintainers are not going to do that because it increases power consumption.

Also, high-accuracy time servers are a very small slice of the Raspbian device ecosystem.

Consequencly, you're probably going to a have to get used to compiling kernels. : )
beta-tester wrote:
Fri Jan 24, 2020 1:22 pm
@rpi-pps0 thank you... very interesting... now i start thinking to recompile my kerne with enabling kernel PPS... but i have to recompile the kernel every time a new kernel update is coming... :|
maybe we can ask the RPi kernel maintainer to enable the option out of the box...

do you know, if there is a downside for none PPS users, when that option is enabled by default?

beta-tester
Posts: 1354
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Fri Jan 24, 2020 10:20 pm

@rpi-pps0 could you please post again the necessary changes of the config for the kernel with hard kernel PPS... i can't find your post anymore.
thank you.
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

rpi-pps0
Posts: 4
Joined: Sun Nov 10, 2019 7:56 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Jan 25, 2020 3:15 am

This is the patch I use.
It's against kernel 4.19.97, though it should work with other kernels. Patch will just complain about offsets.
It will affect both the PI3 and PI4 kernels.
Note: This config turns off kernel preemption. I found this helps a bit with transient loads on the server disturbing the discipline.

Code: Select all

--- arch/arm/configs/bcm2709_defconfig  2020-01-24 23:52:25.289619698 +0000
+++ arch/arm/configs/bcm2709_defconfig.kpps 2020-01-24 23:55:42.418432360 +0000
@@ -3,9 +3,9 @@ CONFIG_LOCALVERSION="-v7"
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_GENERIC_IRQ_DEBUGFS=y
-CONFIG_NO_HZ=y
+# CONFIG_NO_HZ is not set
 CONFIG_HIGH_RES_TIMERS=y
-CONFIG_PREEMPT_VOLUNTARY=y
+CONFIG_PREEMPT_NONE=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
 CONFIG_TASKSTATS=y
@@ -35,6 +35,8 @@ CONFIG_ARCH_BCM2835=y
 # CONFIG_CACHE_L2X0 is not set
 CONFIG_SMP=y
 CONFIG_VMSPLIT_2G=y
+CONFIG_HZ_1000=y
+CONFIG_HZ=1000
 # CONFIG_CPU_SW_DOMAIN_PAN is not set
 CONFIG_UACCESS_WITH_MEMCPY=y
 CONFIG_SECCOMP=y
@@ -687,6 +689,7 @@ CONFIG_SPI_GPIO=m
 CONFIG_SPI_SPIDEV=m
 CONFIG_SPI_SLAVE=y
 CONFIG_PPS=m
+CONFIG_NTP_PPS=y
 CONFIG_PPS_CLIENT_LDISC=m
 CONFIG_PPS_CLIENT_GPIO=m
 CONFIG_PINCTRL_MCP23S08=m
--- arch/arm/configs/bcm2711_defconfig  2020-01-24 23:52:25.290619722 +0000
+++ arch/arm/configs/bcm2711_defconfig.kpps 2020-01-24 23:55:42.428432606 +0000
@@ -3,9 +3,9 @@ CONFIG_LOCALVERSION="-v7l"
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_GENERIC_IRQ_DEBUGFS=y
-CONFIG_NO_HZ=y
+# CONFIG_NO_HZ is not set
 CONFIG_HIGH_RES_TIMERS=y
-CONFIG_PREEMPT_VOLUNTARY=y
+CONFIG_PREEMPT_NONE=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
 CONFIG_TASKSTATS=y
@@ -40,6 +40,8 @@ CONFIG_PCIEPORTBUS=y
 CONFIG_PCI_MSI=y
 CONFIG_PCIE_BRCMSTB=y
 CONFIG_SMP=y
+CONFIG_HZ_1000=y
+CONFIG_HZ=1000
 CONFIG_HIGHMEM=y
 CONFIG_UACCESS_WITH_MEMCPY=y
 CONFIG_SECCOMP=y
@@ -698,6 +700,7 @@ CONFIG_SPI_GPIO=m
 CONFIG_SPI_SPIDEV=m
 CONFIG_SPI_SLAVE=y
 CONFIG_PPS=m
+CONFIG_NTP_PPS=y
 CONFIG_PPS_CLIENT_LDISC=m
 CONFIG_PPS_CLIENT_GPIO=m
 CONFIG_PINCTRL_MCP23S08=m
beta-tester wrote:
Fri Jan 24, 2020 10:20 pm
@rpi-pps0 could you please post again the necessary changes of the config for the kernel with hard kernel PPS... i can't find your post anymore.
thank you.

beta-tester
Posts: 1354
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Raspberry Pi 3B+ Unable to sync to correct time

Mon Jan 27, 2020 9:56 pm

@rpi-pss0, do you know if it is enough to re-compile only the kernel "zImage"...

Code: Select all

RELEASE=raspberrypi-kernel_1.20200114-1
git clone --depth 1 --branch $RELEASE https://github.com/raspberrypi/linux
cd linux
KERNEL=kernel7l
make bcm2711_defconfig
...
make -j4 zImage
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
because i used the same release as the original kernel is,
or is it necessary to re-compile everything inclusive modules and overlays...

Code: Select all

...
make -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
{ I only give negative feedback }
RPi B (256MB), B (512MB), B+, ZeroW; 2B; 3B, 3B+; 4B (4GB)

rpi-pps0
Posts: 4
Joined: Sun Nov 10, 2019 7:56 pm

Re: Raspberry Pi 3B+ Unable to sync to correct time

Sat Feb 01, 2020 3:00 am

@beta-tester:
I can't say for sure that it will work unless you recompile the modules.
The issue is that, while no configuration flags are set to M, even non-module flags can affect which code is incorporated into modules, so the only way to be certain that everything is consistent without examining kernel code is to build everything with the same configuration.
That said, you can build the image, put it on your device and see if it works or not.
If it doesn't work, or doesn't boot, you can do the full rebuild and modify the sdcard on a dev machine.

I highly recommend doing a cross compile on an intel linux machine instead of running the build on an rpi!

Just looking at the relative loops-per-jiffy of the machines:

Code: Select all

$ dmesg|grep lpj
[    0.139553] Calibrating delay loop (skipped), value calculated using timer frequency.. 7008.00 BogoMIPS (lpj=3504000)
[    0.000752] Calibrating delay loop (skipped), value calculated using timer frequency.. 108.00 BogoMIPS (lpj=54000)
You can see, on a recent intel chip, the difference in ops/sec is quite substantial, over 64x.

The easiest way to do this is to build the kernel on the dev machine, tar-gzip the source tree after the build, scp tarball to the rpi, extract it, then run the install commands on the rpi.
beta-tester wrote:
Mon Jan 27, 2020 9:56 pm
@rpi-pss0, do you know if it is enough to re-compile only the kernel "zImage"...

Return to “Troubleshooting”