The Raspberry Pi doesn't come with a realtime clock; if you want to run a standalone (no network) pi with the proper time automatically set on boot you need a real time clock (rtc).
There are a several rtc chips available, most run on the i2c serial bus and many are made by Dallas Semiconductor (ds1307, ds1339, ds3231).
I've wired up a ds3231 to the pi's i2c bus #1, and I can set the time on it and set the system time from the clock using the hwclock
command.
How do I configure raspbian to do this on boot? I have removed the fake-hwclock package, but this only results in the system time being set to January 1969 on boot, which tells me hwclock -s
was never run.
In a crude attempt to make this work, I placed the hwclock -s
command in /etc/rc.local, but I'd like to use a more proper method.
I see there's an /etc/init.d/hwclock.sh script which is supposed to sync the system time from the rtc, but it bails if udev is configured. This implies udev should handle the sync from rtc->system clock, but it is not configured to do so.
What's the proper way to have the system time set from an rtc at boot on a raspberry pi running raspbian?