Here is a guide for adding the realtimeclock module to the rpi-3.12.y.tar.gz - or even later versions:
The links are to be copied manually - sorry for that - that's how this page works..
--------------------------------------- CUT HERE ----------------
#!/bin/bash
clear
CURRENT_KERNEL="$(uname -a|awk '{print $3}')"
GET_THIS_KERNEL="`echo ${CURRENT_KERNEL}|cut -d '.' -f-2`.y"
echo "----------------------------------------------"
echo " SCRIPT TO UPGRADING THE REALTIME CLOCK MODULE"
echo "----------------------------------------------"
echo ""
echo " Preparing to install the realtime clock module (this will take about 15 min).."
echo ""
echo " Module: rtc-pcf2127a.ko"
echo " Homepage: http://afterthoughtsoftware.co..."
echo " Your kernel: ${CURRENT_KERNEL:-error}"
echo ""
echo " INFO: This module will be included in Kernel 3.11.1-2"
echo " (info from blog on homepage listed above)"
echo ""
echo " Press enter to continue or CTRL+C to exit this script.."
read -n 1 dummy
echo "---------------------------------------------------------------------------------"
echo " `date` Starting script"
echo "---------------------------------------------------------------------------------"
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 01 - Adding dynamic temporary iptables to allow updates"
echo "---------------------------------------------------------------------------------"
echo " iptables -I OUTPUT 1 -o eth0 -j ACCEPT"
/sbin/iptables -I OUTPUT 1 -o eth0 -j ACCEPT
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 02 - Installing build-essentials..."
echo "---------------------------------------------------------------------------------"
echo ""
# This will install:
#--------------------------------------------------------------------------------------------
# ca-certificates cmake cmake-data emacsen-common i2c-tools libarchive12 libcurl3
# libcurl3-gnutls libnettle4 librtmp0 libssh2-1 libxml2 libxmlrpc-core-c3 sgml-base xml-core
#--------------------------------------------------------------------------------------------
apt-get update && apt-get dist-upgrade -y && apt-get install -y build-essential gcc make cmake i2c-tools
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Cant update repo and install the build essentials.."
echo ""
exit
fi
#
if [ -d ./devel ]; then
echo ""
echo "### INFO - Found an existing ./devel directory - deleting it.."
rm -Rf ./devel
fi
#
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 03 - Creating ./devel directory & downloading the kernel source+rtc patch.."
echo "---------------------------------------------------------------------------------"
mkdir devel && cd devel && wget https://github.com/raspberrypi...{GET_THIS_KERNEL}.tar.gz && wget https://github.com/afterthough...
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Cant get the kernel souce and realtimeclock patch.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 04 - Extracting the kernel tar.gz.."
echo "---------------------------------------------------------------------------------"
tar xzf rpi-${GET_THIS_KERNEL}.tar.gz && cd linux-rpi-${GET_THIS_KERNEL}/
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Cant get the kernel souce and realtimeclock patch.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 05 - Patching the kernel with the realtime patch"
echo "---------------------------------------------------------------------------------"
SUW=`pwd`
patch -p1 < ../fd5ff2d88f470ed70ff58393eee61110b181816a.patch
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Patching of the kernel failed.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 06 - Extracting current kernel compile options from /proc/config.gz.."
echo "---------------------------------------------------------------------------------"
/bin/zcat /proc/config.gz > .config
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Extract of the /proc/config.gz failed.."
echo ""
exit
fi
#
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 07 - Making a new .config from the original .config of the running kernel.. "
echo "---------------------------------------------------------------------------------"
echo m | make oldconfig
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Make oldconfig failed.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 08 - Enabling build of the RTC_DRV_PCF2127A module in the .config file.."
echo "---------------------------------------------------------------------------------"
sed -i 's/# CONFIG_RTC_DRV_PCF2127A is not set/CONFIG_RTC_DRV_PCF2127A=m/g' .config
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Altering of the CONFIG_RTC_DRV_PCF2127A to =m failed in .config gile failed.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 09 - Getting the Module.symvers file.."
echo "---------------------------------------------------------------------------------"
wget https://github.com/raspberrypi...
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Wget of the Module.symvers failed.."
echo ""
exit
fi
#
# Delete the old module (rename it) if it already exist..
#
if [ -f /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/rtc-pcf2127a.ko ]; then
echo
"### WARNING - Found an old rtc-pcf2127a.ko in /lib/modules/$(uname
-a|awk '{print $3}')/kernel/drivers/rtc/ - saving it as .old"
mv
/lib/modules/$(uname -a|awk '{print
$3}')/kernel/drivers/rtc/rtc-pcf2127a.ko /lib/modules/$(uname -a|awk
'{print $3}')/kernel/drivers/rtc/rtc-pcf2127a.ko.org
fi
#
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 10 - Compile modules_prepare.."
echo "---------------------------------------------------------------------------------"
make modules_prepare
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Make modules_prepare failed.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 11 - Compile the modules.."
echo "---------------------------------------------------------------------------------"
cd drivers/rtc && make -C ${SUW} M=`pwd`
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Make -C ${SUW} M=`pwd` failed.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 12 - Copying rtc-pcf2127a.ko module to /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/"
echo "---------------------------------------------------------------------------------"
cp rtc-pcf2127a.ko /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/
if [ $? -ne 0 ]; then
echo ""
echo "### ERROR - Copy of the module rtc-pcf2127a.ko to /lib/modules/$(uname -a|awk '{print $3}')/kernel/drivers/rtc/ failed.."
echo ""
exit
fi
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 13 - Deleting ./devel directory.."
echo "---------------------------------------------------------------------------------"
rm -Rf ./devel
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 14 - Running depmod.."
echo "---------------------------------------------------------------------------------"
depmod
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 15 - Removing dynamic iptables rule again.."
echo "---------------------------------------------------------------------------------"
echo "/sbin/iptables -D OUTPUT -o eth0 -j ACCEPT"
/sbin/iptables -D OUTPUT -o eth0 -j ACCEPT
echo ""
echo "---------------------------------------------------------------------------------"
echo " STEP 16 - The manual step.."
echo "---------------------------------------------------------------------------------"
echo " Now - You must add this to /etc/rc.local to ensure the module loads..: "
echo ' Add the following to /etc/rc.local before exit 0
# Referring to http://www.raspberrypi-spy.co....
# to get the RasPi board version:
REV=$(cat /proc/cpuinfo|grep Revision)
# Extract revision
REV=${REV##*: }
# Make it readable as hex
REV=0x$REV
# Convert hex to dec
REV=$((REV))
if [ $REV -lt 4 ]
then
echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-0/new_device
echo setting rtc to i2c-0
else
echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
echo setting rtc to i2c-1
fi
( sleep 2; hwclock -s ) &
'
echo "---------------------------------------------------------------------------------"
echo " `date` end of script"
echo "---------------------------------------------------------------------------------"