--- etc/init.d/hwclock.sh 2014/01/07 03:04:06 1.1 +++ etc/init.d/hwclock.sh 2014/01/07 03:12:31 @@ -38,6 +38,28 @@ HCTOSYS_DEVICE=rtc0 # potential inconsistency at startup. unset TZ +init_rtc_device() { + [-e /dev/rtc0 ] && return 0; + + #load i2c and RTC kernel modules + modprobe i2c-dev + modprobe rtc-ds1307 + + #iterate over every i2c bus as we're supporting Raspberry Pi rev. 1 and 2 + #(different I2C busses on GPIO header!) + for bus in $(ls -d /sys/bus/i2c/devices/i2c-*) + do + echo ds1307 0x68 >> $bus/new_device; + if [ -e /dev/rtc0 ] + then + log_action_msg "RTC found on bus `cat $bus/name`" + break # RTC found, bail out of the loop + else + echo 0x68 >> $bus/delete_device + fi + done +} + hwclocksh() { [ ! -x /sbin/hwclock ] && return 0 @@ -61,9 +83,11 @@ hwclocksh() printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime fi - if [ -d /run/udev ] || [ -d /dev/.udev ]; then - return 0 - fi + init_rtc_device + # Raspberry Pi doesn't have udev detactableRTC + #if [ -d /run/udev ] || [ -d /dev/.udev ]; then + # return 0 + #fi if [ "$HWCLOCKACCESS" != no ]; then log_action_msg "Setting the system clock" --- etc/modprobe.d/raspi-blacklist.conf 2014/01/07 03:17:04 1.1 +++ etc/modprobe.d/raspi-blacklist.conf 2014/01/07 03:17:53 @@ -1,4 +1,4 @@ # blacklist spi and i2c by default (many users don't need them) blacklist spi-bcm2708 -blacklist i2c-bcm2708 +#blacklist i2c-bcm2708 // for RTC --- /dev/null 1969-12-31 16:00:06.660000000 -0800 +++ etc/cron.hourly/sync-hwclock 2014-01-06 19:52:00.537478011 -0800 @@ -0,0 +1,8 @@ +#!/bin/sh +# +# Simple cron script - update and synchronize hardware clock to NTP +# only if NTP is available. + +if ntptrace >/dev/null 2>&1; then + hwclock -w +fi