Forked from maage/rtc-ds3231-ubuntu-19.10-rpi4.txt
Last active
June 27, 2021 05:05
-
-
Save Crowdedlight/507f874c34b8e3193e2b4e216d3bd75b to your computer and use it in GitHub Desktop.
High Accuracy Pi RTC (DS3231) installation in Ubuntu 19.10 in Raspberry Pi 4 Model B Rev 1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Base instructions are here: | |
http://wiki.seeedstudio.com/High_Accuracy_Pi_RTC-DS3231/ | |
But I've diverted my setup procedure somewhat because Ubuntu boot setup is different than Raspbian and setup does some things not needed. | |
To use RTC early in the boot add "fixrtc" to kernel boot command line. Correct file is "/boot/firmware/nobtcmd.txt". | |
This is implemented in "/usr/share/initramfs-tools/scripts/local-premount/fixrtc". | |
To add the at at device tree, add "dtoverlay=i2c-rtc,ds3231" to "/boot/firmware/usercfg.txt". | |
Uninstall possible "fake-hwclock". | |
There should not be need for configuring any kernel modules or udev/systemd and other initscript changes. | |
If changes work correctly you should see correct time at start of the boot when looking messages "journalctl -b0". If not, date is "Apr 11" (mine was 2019-04-11T16:28:37.384186+0000). | |
There should be no (minimal) change in time when your time server starts. | |
Some lower level debugging helpers, install i2c-tools. You should get UU at location 68 in i2cdetect. | |
$ ls -l /dev/i2c* | |
crw-rw---- 1 root i2c 89, 1 Jan 19 20:47 /dev/i2c-1 | |
$ sudo i2cdetect -y 1 | |
0 1 2 3 4 5 6 7 8 9 a b c d e f | |
00: -- -- -- -- -- -- -- -- -- -- -- -- -- | |
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- | |
70: -- -- -- -- -- -- -- -- | |
Syslog says: | |
kernel: hctosys: unable to open rtc device (rtc0) | |
kernel: rtc-ds1307 1-0068: registered as rtc0 | |
The module manages many models: modinfo rtc-ds1307 | |
$ sudo hwclock -v | |
hwclock from util-linux 2.34 | |
System Time: 1579463067.337580 | |
Trying to open: /dev/rtc0 | |
Using the rtc interface to the clock. | |
Assuming hardware clock is kept in UTC time. | |
Waiting for clock tick... | |
ioctl(4, RTC_UIE_ON, 0): Invalid argument | |
Waiting in loop for time from /dev/rtc0 to change | |
...got clock tick | |
Time read from Hardware Clock: 2020/01/19 19:44:28 | |
Hw clock time : 2020/01/19 19:44:28 = 1579463068 seconds since 1969 | |
Time since last adjustment is 1579463068 seconds | |
Calculated Hardware Clock drift is 0.000000 seconds | |
2020-01-19 21:44:27.819024+02:00 | |
If you use systemd-timesyncd, | |
$ timedatectl status | |
Local time: Sun 2020-01-19 21:45:54 EET | |
Universal time: Sun 2020-01-19 19:45:54 UTC | |
RTC time: Sun 2020-01-19 19:45:54 | |
Time zone: Europe/Helsinki (EET, +0200) | |
System clock synchronized: yes | |
NTP service: inactive | |
RTC in local TZ: no | |
If you use chrony, add to /etc/chrony/chrony.conf: | |
# This directive enables kernel synchronisation (every 11 minutes) of the | |
# real-time clock. Note that it can’t be used along with the 'rtcfile' directive. | |
rtcsync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also check https://github.com/rgl/rtc-i2c-ds3231-rpi in conjunction with above (for future visitors)