I'm converting an NTP server (GPS controled) from a rpi zero with SPI ethernet (10Mb/s) running raspbian lite to a nanopi neo3 with DietPi. I want to use the onboard 1GBps, as that will reduce the local LAN NTP delay from 2msec to 0.5msec from my tests.
The first step of this process is to get the RTC DS3231 (I2C) to work with DietPi.
I was successful in the I2C connection and
Code: Select all
sudo i2cdetect -y 0
From my searches around the forums I then need to execute the following in order to create the new device:
Code: Select all
sudo echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
After this the new hardware clock is available as it can be tested by:
Code: Select all
sudo hwclock -r -f /dev/rtc1
Questions:
1) Is this enough to have the DS3231 become the true and only hardware clock of the system?
2) After reboot this is all lost. On the pi I would edit the rc.local file but that file is not present in my installation and even if I create it and add the following
Code: Select all
sudo echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
hwclock -s
So, what is the proper way to run the two command above at boot time on dietpi?
BTW I'm using DietPi v7.0.2.
Thanks a million!!!
Enzo
[SOLVED]
/lib/udev/hwclock-set became:
Code: Select all
#!/bin/sh
# Reset the System Clock to UTC if the hardware clock from which it
# was copied by the kernel was in localtime.
dev=$1
if [ -e /run/systemd/system ] ; then
# exit 0
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
fi
#if [ -e /run/udev/hwclock-set ]; then
# exit 0
#fi
.
.
.
HCTOSYS_DEVICE=rtc1
In order to have the system time set from the DS3231 at boot add the following line to /etc/rc.local
Code: Select all
sudo hwclock -s -f /dev/rtc1
Check it with: sudo systemctl status rc.local.service
restart it with sudo systemctl restart rc.local.service