User avatar
yv1hx
Posts: 383
Joined: Sat Jul 21, 2012 10:09 pm
Location: Now an expatriate, originally from Zulia, Venezuela
Contact: Website Skype

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Fri Oct 03, 2014 7:31 pm

Hi-Z wrote:Pretend you're in a large room with many other people. You can talk to them and them to you. During the conversations you find out that you are actually on the 33rd floor of a building and rumour has it that there may be others on the hiding out on the 50th floor but there is no way to talk to them. Suddenly (or should I say magically) an elevator appears with only two buttons ... 33 & 50. Using your super genius skills, you get in, press 50 and you are now on the 50th floor with a whole new group of people ... After talking for a bit, you find out that they want to know what time it is on the 33rd floor (This is a RTC tutorial, so I will stay relevant). Since you are the only one who can figure out how the two buttons in the elevator work, you press 33 and arrive at that floor. You check the time, return to the elevator and press 50. On the 50th, you report your results and somebody says "I wonder what time it is now on the 33rd?" ... So back to the 33rd you go, check the time and return to the 50th .... and then somebody asks "How about now?" and the cycle continues.

In this instance the elevator (level shifter) allows the conversations on one level (50th floor) to communicate with the other level (33rd floor) ... without it, they can't talk with each other.

-----------------------------------------------------

The story gets a little weird after that ... the hero (that would be you) finds out that the people of the Ground level have no potential.
+1 :D
Marco-Luis
Telecom Specialist (Now Available for Hire!)

http://www.meteoven.org
http://twitter.com/yv1hx

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 3:25 pm

Hello guys, this is my trial at getting the Waiman's Tiny RTC v1.1 to work... and it doesn't want to.

What I have now:

Code: Select all

~ $ cat /etc/modules
snd-bcm2835
i2c-bcm2708 
i2c-dev
rtc-ds1307

Code: Select all

~ $ cat /etc/modprobe.d/raspi-blacklist.conf
#blacklist spi-bcm2708
#blacklist i2c-bcm2708
As suggested by @psergiu, I also issued

Code: Select all

sudo dpkg --purge fake-hwclock
and instead of "rm /etc/rcS.d/K0?hwclock.sh" and then "cd /etc/rcS.d && ln -s ../init.d/hwclock.sh S10hwclock.sh" I did

Code: Select all

~ $ sudo mv /etc/rcS.d/K01hwclock.sh /etc/rcS.d/S10hwclock.sh
(because it was the same link, but it had a different name).

Now, if I do:

Code: Select all

~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
50 it's the EEPROM, I guess, and 68 the DS1307.
Initially I was using a 3v3 pin, but 5V are needed to detect also the DS1307.
But now I'm pretty sure it's not correct to connect a 5V pin, in regards of the comments above.

I had this error:

Code: Select all

~ $ sudo echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
-bash: /sys/class/i2c-adapter/i2c-1/new_device: Permission denied
FIX:

Code: Select all

~ $ sudo bash
root@raspberrypi:/home/pi# echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
root@raspberrypi:/home/pi# exit
exit
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
DougieLawson
Posts: 40224
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 4:29 pm

0x68 is the DS1307.

It should start working when you've run

Code: Select all

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
Test it with
hwclock -r
set it with
hwclock -w # or hwclock --systohc
reset the system clock from the RTC with
hwclock -s # or hwclock --hctosys
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 4:47 pm

Thanks. The initial problem regarding this command is that I had to run it after "sudo bash", or "sudo -s", to enter a root shell. Otherwise it gives "permission denied". With "sudo <command>" won't work.

Now I added

Code: Select all

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
hwclock -s
in /etc/rc.local and it's working great on startup.

I just want to clarify the 3.3V/5V thing...
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
DougieLawson
Posts: 40224
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 5:15 pm

dentex wrote: I just want to clarify the 3.3V/5V thing...
DS1307 needs Vcc at 5V0. If using the Adafruit #264 board you need to a) not mount the 220ohm resistors or b) snip them off.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 5:22 pm

No it's the Waiman's RTC v1.1
We discussed in some previous posts about this: came out I could use anyway a 3v3 pin for the module's VCC, but this way the DS1307 is not detected.
Is it safe for the RPi if I use a 5V pin for the VCC?
Last edited by dentex on Tue Oct 14, 2014 6:43 pm, edited 1 time in total.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 6:41 pm

So it seems I already have an answer.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
DougieLawson
Posts: 40224
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Oct 14, 2014 7:03 pm

dentex wrote: Is it safe for the RPi if I use a 5V pin for the VCC?
http://datasheets.maximintegrated.com/en/ds/DS1307.pdf
it won't work at less than 4V5.

The RPi has 1KΩ8 resistors on the I2C pins.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Thu Oct 16, 2014 1:46 pm

Indeed, it's working really well.
---
Do you know what the EEPROM is used for? It seems connected to the optional temperature probe.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

User avatar
DougieLawson
Posts: 40224
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Thu Oct 16, 2014 4:07 pm

dentex wrote: Do you know what the EEPROM is used for? It seems connected to the optional temperature probe.
I haven't the faintest idea.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
dentex
Posts: 180
Joined: Sun May 20, 2012 7:58 am
Location: Italy
Contact: Website

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Thu Oct 16, 2014 4:15 pm

LoL!!!
I think it can be treated just as another I2C device. On some descriptions on line they say:
...the module also integrate the I2C EEPROM chip(24C32) and the DS18B20 sensor interface. The I2C EEPROM makes it possible to save the sensor data easily without spending too much microcontroller source. And the DS18B20 interface with the pull-up resistor embedded will be helpful to extend temperature monitoring feature for your project.
One of my projects with the Raspberry Pi:
--------------------------------------------------------
(Raspberry) Pi Aquarium Controller: https://github.com/dentex/piac

marcus15
Posts: 14
Joined: Sat Feb 07, 2015 11:58 pm

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Thu Feb 12, 2015 11:20 am

Hi Everyone,

You'd best read my posts at http://www.raspberrypi.org/forums/viewt ... 44&t=99141 to get an intro to what I'm going through here...

I've just upgraded my system to jessie which seems to be all systemd based. All the problems from before reappeared as systemd completely whacks the hwclock.sh functionality (check for yourself with set -x).

I did not have an opinion on systemd until I started trying to get the hardware clock working with it, but suffice to say that I wish it's developers had never been born. They have broken critical legacy functionality (clocks? who needs them!) and they really don't give a f. (I'm really holding back here after a day of my time has been wasted :x )

Anyway, now that I have that out of my system, here is what you need to do to get your RTC working with raspbian jessie with this 'awesome' new broken system!

Su to root before any of this...

Create the following two files:
/lib/systemd/system/hwclock-start.service

Code: Select all

[Unit]
Description=Set time from RTC on startup
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock -s
TimeoutSec=0

[Install]
WantedBy=multi-user.target
/lib/systemd/system/hwclock-stop.service

Code: Select all

[Unit]
Description=Synchronise Hardware Clock to System Clock
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock --systohc

[Install]
WantedBy=reboot.target halt.target poweroff.target
Run the following:

Code: Select all

systemctl enable hwclock-start hwclock-stop
The device should have been created by devicetree on the new kernels (yep, no need for any echo 0x68 stuff) as long as you enable I2C and the RTC in /boot/config.txt:

Code: Select all

dtparam=i2c_arm=on
dtoverlay=ds1307-rtc
Check your current time with 'date'. If it's right, run 'hwclock -s' to force a first save.

Make sure fake-hwclock has been purged and removed (check for any remnants with 'find /etc -name \*fake\*' and 'find /etc -name \*clock\*' don't just delete stuff you find randomly or you will hurt :) - use your brain).

Nuke /etc/adjtime to reset any broken values before rebooting (it will auto recreate it).

This has solved my invalid clock issues I had as discussed in the other thread with clock dates in the year 2066. I've tested it by booting the Pi with the network cable unplugged and the ntp/ntpdate programs disabled.

I'll post back here if I learn anything more.

P.S. I hope the systemd developers never have children to pass their amazing arrogance on to!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3468
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Thu Feb 12, 2015 11:25 am

I feel your pain. Thanks for sharing, and for saving others the hassle you went through.

marcus15
Posts: 14
Joined: Sat Feb 07, 2015 11:58 pm

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Sun Feb 15, 2015 6:54 am

The saga rolls on! I had lingering doubts about why this was broken, so I did more testing.

I gave the Pi2 a few reboots (many!) and have found that about 1 in 10 reboots, few different weird behaviours including:
1. Randomly reverting to the corrupt clock (say 1 in 10 reboots) possibly due to a race condition;
2. The clock is not being set early enough in the boot sequence so the 'magical' sydtemd has kittens: the system gets stuck in a weird state where it won't even boot but you can log in. Really weird! I've also seen it record timestamps etc and then show status of something starting 45 years ago because it expects the clock to be set before it starts. How cool is that?); and
3. The init sequence never finishes, so you can login but commands like reboot don't work. A 'sync' and hard power cycle is required.

I'm now suspecting that this can all be traced back to the following change:
https://github.com/raspberrypi/linux/issues/163
"popcornmix commented on 11 Jan 2014 @maxnet So suggestion is to disable CONFIG_RTC_HCTOSYS? I have no evidence that it is required by anyone, so I could try that."

Combine that change with systemd now expecting the kernel to have set the clock from the RTC:
http://lists.freedesktop.org/archives/s ... 02526.html
http://mrpogson.com/2015/02/09/systemd- ... ur-poison/

I can confirm the latest kernel from rpi-update has this:

Code: Select all

root@quadpi:~# cat /proc/config.gz |gzip -d |grep CONFIG_RTC_HCTOSYS
# CONFIG_RTC_HCTOSYS is not set
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
I'm not sure that this can be loaded as a module or enabled by config; that was my first thought to try and address this easily.

So, in summary, someone whining about error messages on boot has got RTC support disabled and broken the 'normal' way for handing the hardware clock being set on boot.

I'm betting that the systemd hwclock stop script from above to set the clock on shutdown combined with making the kernel set the time from the RTC on boot (if it can) would make most of this go away?

I'm open to ideas, but having an unreliable clock for my logging and analysis application (which logs rainfall, temperature, off peak power switching and rainwater tank levels: all very time specific :) ) makes the Pi pretty useless, especially if repeated reboots can corrupt the clock (I presume that if it hasn't been set by the kernel or the script then writing 1/1/1970 back to it corrupts the clock registers and then they're screwed for the next reboot and clock fix).

@PhilE do you have any idea of a fix for this? There are enough people using Pis for embedded projects that aren't reliably internet connected that having a reliable working hardware clock would be a really nice thing, if not essential. Compiling up a custom kernel to fix this for every release seems... ummm... painful.

Going to see if I can make it a bit more robust with some dependencies on the start, but it's one hell of an ugly bandaid!

[Edit: I still think I'm missing something here. Ideas? Anyone? :) ]

[Edit 2: I messed with the dependencies in systemd to no avail. Disabling ntpd stopped the clock corruption. I under the 'start' section of the ntpd start script I added a hwclock -s to force the hardware clock to be set before ntpd runs. No more corruption yet. So yeah, the kernel really should be setting the time during boot :) More testing to come...]

marcus15
Posts: 14
Joined: Sat Feb 07, 2015 11:58 pm

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Feb 17, 2015 11:05 am

Some happy news... after 50+ reboots it's working without a hitch.

In summary, for those who dare to try and get this working after me:
1. Use the systemd scripts I posted (try your luck), you may or may not need the start script but the stop script will set the clock if ntpd doesn't set it at some point;
2. Don't bother with hwlock.sh (it's broken and runs too late due to init.d script ordering i.e. after ntpd, which is what wipes the rtc); and
3. Edit /etc/init.d/ntp and add hwclock -s as shown:

Code: Select all

case $1 in
        start)
                hwclock -s
                log_daemon_msg "Starting NTP server" "ntpd"
Stuff that should really be fixed:
a. Allow the rtc_ds1307 devicetree module to take a parameter to tell it to use the ds3231 configuration (yes there are minor register differences and the ds3231 does allow you to read the temperature from its calibration module); and
b. RPi foundation / kernel maintainers: Really really really really really really really think about adding CONFIG_RTC_HCTOSYS back into the kernel so this hacking isn't required. As it stands an ntp upgrade might bugger this up and make the system unbootable (as I have seen).

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3468
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Tue Feb 17, 2015 11:22 am

a. Allow the rtc_ds1307 devicetree module to take a parameter to tell it to use the ds3231 configuration (yes there are minor register differences and the ds3231 does allow you to read the temperature from its calibration module); and
This could be done in a few ways, some more clunky than others. I'll have a think about it.
b. RPi foundation / kernel maintainers: Really really really really really really really think about adding CONFIG_RTC_HCTOSYS back into the kernel so this hacking isn't required. As it stands an ntp upgrade might bugger this up and make the system unbootable (as I have seen).
If you raise an issue against the raspberrypi/linux repo, this will be assessed and tracked in the usual way.

satchuck
Posts: 2
Joined: Wed Feb 18, 2015 6:01 pm

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Wed Feb 18, 2015 6:22 pm

Thanks for all the problem solving and describing what happened. It makes following along so much easier.
Could you frame the rtc difficulties as a security issue? Would that help it get bumped up the change request queue? It seems to work in government. Just a thought.
Chuck

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Wed Feb 18, 2015 6:35 pm

satchuck wrote:Just a thought.
Chuck
...not a good one. Do you think they can be hoodwinked into thinking its a security issue? Things don't work like that :roll:
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3468
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Wed Feb 18, 2015 6:51 pm

Step one is to get it into the queue - that does make a difference.

@marcus15 There is now a generic i2c-rtc overlay - see here: https://github.com/raspberrypi/linux/pull/838

marcus15
Posts: 14
Joined: Sat Feb 07, 2015 11:58 pm

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Sat Feb 21, 2015 4:21 am

@PhilE you're a legend! :)

Code: Select all

[    4.419868] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0
I'll look at raising this as an issue soon but currently playing with a USB GPS (bare board) with the PPS line routed to the RPi GPIO. A custom build of ntpd was required with --enable-all-clocks (the debian package maintainers disable debug and 'all useful features!'). It also seems to have to run as root (not great) for pps even when I chmod 777'd /dev/pps0. Good results though:

Code: Select all

root@quadpi:~# ntpq -c lpeers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
oPPS(0)          .PPS.            0 l   12   16  377    0.000    0.001   0.004
*SHM(0)          .GPS.            0 l   12   16  377    0.000  -122.76  17.457
[snip]
That's some pretty awesome timing accuracy :)

Is there a 'how to lodge a request for dummies' thread around putting in a ticket for the CONFIG_RTC_HCTOSYS option?

Thanks again!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3468
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Sat Feb 21, 2015 7:23 am

I'm not sure, but it's really easy. Just go to the github repo: (https://github.com/raspberrypi/linux), find the issues section, and create a new issue.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3468
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Fri Mar 06, 2015 9:00 am

@marcus15 I started looking at the CONFIG_HCTOSYS option and found this section in Kconfig:
The driver for this RTC device must be loaded before late_initcall functions run, so it must usually be statically linked.
Looking at the boot sequence, and just thinking about the fact that the RTC driver relies on the I2C driver module being loaded, makes me think that CONFIG_HCTOSYS is not going to work on a Pi, and that modifying the distribution scripts as you have done yourself is the right solution.


xpamamadeus
Posts: 3
Joined: Thu Mar 26, 2015 10:21 am

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Wed Oct 14, 2015 7:14 am

marcus15 wrote:Hi Everyone,

You'd best read my posts at http://www.raspberrypi.org/forums/viewt ... 44&t=99141 to get an intro to what I'm going through here...

I've just upgraded my system to jessie which seems to be all systemd based. All the problems from before reappeared as systemd completely whacks the hwclock.sh functionality (check for yourself with set -x).

I did not have an opinion on systemd until I started trying to get the hardware clock working with it, but suffice to say that I wish it's developers had never been born. They have broken critical legacy functionality (clocks? who needs them!) and they really don't give a f. (I'm really holding back here after a day of my time has been wasted :x )

Anyway, now that I have that out of my system, here is what you need to do to get your RTC working with raspbian jessie with this 'awesome' new broken system!

Su to root before any of this...

Create the following two files:
/lib/systemd/system/hwclock-start.service

Code: Select all

[Unit]
Description=Set time from RTC on startup
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock -s
TimeoutSec=0

[Install]
WantedBy=multi-user.target
/lib/systemd/system/hwclock-stop.service

Code: Select all

[Unit]
Description=Synchronise Hardware Clock to System Clock
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/sbin/hwclock --systohc

[Install]
WantedBy=reboot.target halt.target poweroff.target
Run the following:

Code: Select all

systemctl enable hwclock-start hwclock-stop
The device should have been created by devicetree on the new kernels (yep, no need for any echo 0x68 stuff) as long as you enable I2C and the RTC in /boot/config.txt:

Code: Select all

dtparam=i2c_arm=on
dtoverlay=ds1307-rtc
Check your current time with 'date'. If it's right, run 'hwclock -s' to force a first save.

Make sure fake-hwclock has been purged and removed (check for any remnants with 'find /etc -name \*fake\*' and 'find /etc -name \*clock\*' don't just delete stuff you find randomly or you will hurt :) - use your brain).

Nuke /etc/adjtime to reset any broken values before rebooting (it will auto recreate it).

This has solved my invalid clock issues I had as discussed in the other thread with clock dates in the year 2066. I've tested it by booting the Pi with the network cable unplugged and the ntp/ntpdate programs disabled.

I'll post back here if I learn anything more.

P.S. I hope the systemd developers never have children to pass their amazing arrogance on to!
Hi.
RTC with jessie its much easier than that.(But your version with services its ok)
With fresh installed jessie we need only 3 things.
1 Add dtoverlay= with right config for your RTC
2 then sudo apt-get remove --purge fake-hwclock
3 timedatectl set-ntp true
After reboot u can check status with "timedatectl status"
This way u stay with systemd standard procedure.
jessie work like archlinux now with systemd
Hope i help someone with this.

User avatar
jojopi
Posts: 3354
Joined: Tue Oct 11, 2011 8:38 pm

Re: Tutorial: Add a Real Time Clock to the Raspberry Pi

Wed Oct 14, 2015 11:35 am

xpamamadeus wrote:3 timedatectl set-ntp true
Booting with no network, that gives me:

Code: Select all

pi@tau:~$ timedatectl status
      Local time: Wed 2015-10-14 09:12:15 UTC
  Universal time: Wed 2015-10-14 09:12:15 UTC
        RTC time: Wed 2015-10-14 09:16:37
systemd-timesyncd includes its own fake-hwclock-like functionality to stop time going backwards on future boots. It is this that has been used to set the system clock, not the RTC. Worse still, if ntpd is also enabled, as it normally is:

Code: Select all

pi@tau:~$ timedatectl status
      Local time: Wed 2015-10-14 09:12:58 UTC
  Universal time: Wed 2015-10-14 09:12:58 UTC
        RTC time: Wed 2015-10-14 09:12:58
Now between them the two daemons have guessed what time it is, and then written that incorrect time back to the RTC!

Return to “Interfacing (DSI, CSI, I2C, etc.)”