moryoav
Posts: 13
Joined: Tue Jul 08, 2014 8:44 am

[SOLVED] Adding a driver for RasClock [RTC]

Wed Jul 09, 2014 8:33 am

I recently bought an RTC module, and read the instructions here:
http://afterthoughtsoftware.com/products/rasclock

the error I get when I try "hwclock -w" is "Cannot access the hardware clock via any known method.".

I didn't overwrite the kernel as the instructions say here, this does not seem like a wise thing to do, because I do want to stay with the latest and most updated version.

Code: Select all

wget http://afterthoughtsoftware.com/files/linux-image-3.6.11-atsw-rtc_1.1_armhf.deb
dpkg -i linux-image-3.6.11-atsw-rtc_1.1_armhf.deb
cp /boot/vmlinuz-3.6.11-atsw-rtc+ /boot/kernel.img
I notice that in lib\modules\3.12.22+\kernel\drivers\rtc there's already a file called "rtc-pcf2127.ko". So I thought I could just load the existing driver.
So to etc/modules I added:

Code: Select all

i2c-bcm2708
rtc-pcf2127a
And also tried another variation with:

Code: Select all

i2c-bcm2708
rtc-pcf2127
and added the following to etc/rc.local (I have a rev.2 pi)

Code: Select all

echo pcf2127a 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
( sleep 2; hwclock -s ) &
And I get the error mentioned above
I try "hwclock -w" and get "Cannot access the hardware clock via any known method.".
When I try --debug it tells me "/dev/rtc failed: No such file or directory". It indeed does not exist.

I've wasted days on this thing, read everything online. I'm just somewhat of a newbie and I'm not sure how to solve this thing.

Any assistance would be greatly appreciated.

Yoav.
Last edited by moryoav on Thu Jul 10, 2014 11:48 am, edited 1 time in total.

DirkS
Posts: 9898
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Adding a driver for RasClock [RTC]

Wed Jul 09, 2014 5:23 pm

You'll need root rights. Try 'sudo hwclock'.

HTH
Dirk.

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Adding a driver for RasClock [RTC]

Wed Jul 09, 2014 10:22 pm

I tried to use these instructions to compile a module for the pcf2127a (using the latest rpi-3.12.y), and it crashed the pi (no errors, just froze) as soon as I modprobed the module.

Code: Select all

sudo apt-get update
sudo apt-get –y dist-upgrade
sudo apt-get -y install build-essential gcc make cmake i2c-tools
mkdir devel
cd devel
wget https://github.com/raspberrypi/linux/archive/rpi-3.6.y.tar.gz
wget https://github.com/afterthoughtsoftware/linux/commit/fd5ff2d88f470ed70ff58393eee61110b181816a.patch
tar xzf rpi-3.6.y.tar.gz
cd linux-rpi-3.6.y/
SUW=`pwd`
patch -p1 < ../fd5ff2d88f470ed70ff58393eee61110b181816a.patch
zcat /proc/config.gz > .config
echo m | make oldconfig
wget https://github.com/raspberrypi/firmware/raw/master/extra/Module.symvers
make modules_prepare
cd drivers/rtc
make -C $SUW M=`pwd`
sudo cp rtc-pcf2127a.ko /lib/modules/3.6.11+/kernel/drivers/rtc/
sudo depmod
This is the patch:

Code: Select all

From fd5ff2d88f470ed70ff58393eee61110b181816a Mon Sep 17 00:00:00 2001
From: Andy Duller <[email protected]>
Date: Thu, 8 Nov 2012 15:38:57 +0000
Subject: [PATCH] RTC: Added I2C driver for NXP/Philips PCF2127A device from
 Eckelmann AG.

---
 arch/arm/configs/bcmrpi_defconfig |   1 +
 drivers/rtc/Kconfig               |  11 ++
 drivers/rtc/Makefile              |   1 +
 drivers/rtc/rtc-pcf2127a.c        | 307 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 320 insertions(+)
 create mode 100644 drivers/rtc/rtc-pcf2127a.c

diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig
index b4a3da1..1902263 100644
--- a/arch/arm/configs/bcmrpi_defconfig
+++ b/arch/arm/configs/bcmrpi_defconfig
@@ -784,6 +784,7 @@ CONFIG_RTC_DRV_ISL12022=m
 CONFIG_RTC_DRV_X1205=m
 CONFIG_RTC_DRV_PCF8563=m
 CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_PCF2127A=m
 CONFIG_RTC_DRV_M41T80=m
 CONFIG_RTC_DRV_BQ32K=m
 CONFIG_RTC_DRV_S35390A=m
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 53eb4e5..201c519 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -271,6 +271,17 @@ config RTC_DRV_PCF8583
          This driver can also be built as a module. If so, the module
          will be called rtc-pcf8583.

+config RTC_DRV_PCF2127A
+       tristate "Philips PCF2127A (only I2C)"
+       help
+         If you say yes here you get support for the Philips PCF2127A
+         RTC. This driver implements only the i2c-interface to the chip.
+         It may work with pcf2127, but is tested only against
+         the pcf2127a.
+
+         This driver can also be built as a module. If so, the module
+         will be called rtc-pcf2127a.
+
 config RTC_DRV_M41T80
        tristate "ST M41T62/65/M41T80/81/82/83/84/85/87"
        help
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 6e69823..7100c5b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -74,6 +74,7 @@ obj-$(CONFIG_RTC_DRV_PCAP)    += rtc-pcap.o
 obj-$(CONFIG_RTC_DRV_PCF8563)  += rtc-pcf8563.o
 obj-$(CONFIG_RTC_DRV_PCF8583)  += rtc-pcf8583.o
 obj-$(CONFIG_RTC_DRV_PCF2123)  += rtc-pcf2123.o
+obj-$(CONFIG_RTC_DRV_PCF2127A)  += rtc-pcf2127a.o
 obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
 obj-$(CONFIG_RTC_DRV_PL030)    += rtc-pl030.o
 obj-$(CONFIG_RTC_DRV_PL031)    += rtc-pl031.o
diff --git a/drivers/rtc/rtc-pcf2127a.c b/drivers/rtc/rtc-pcf2127a.c
new file mode 100644
index 0000000..53ddf31
--- /dev/null
+++ b/drivers/rtc/rtc-pcf2127a.c
@@ -0,0 +1,307 @@
+/*
+ * Driver the the NXP/Philips PCF2127A RTC (only I2C)
+ *
+ * Copyright (c) 2011 ECKELMANN AG.
+ *
+ * Authors:    Matthias Wolf  <[email protected]>
+ *             Torsten Mehnert <[email protected]>
+ *
+ * RTC-Datasheet: http://www.nxp.com/documents/data_sheet/PCF2127A.pdf
+ *
+ * NOTE: This driver only implements the i2c-interface to the RTC.
+ * This driver is based on rtc-pcf8363 from Alessandro Zummo.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/i2c.h>
+#include <linux/bcd.h>
+#include <linux/rtc.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+
+/* PCF2127A Registers */
+#define PCF2127A_REG_CTL1              0x00 /* Control 1 */
+#define PCF2127A_REG_CTL2              0x01 /* Control 2 */
+#define PCF2127A_REG_CTL3              0x02 /* Control 3 */
+
+#define PCF2127A_REG_SC                        0x03 /* second value    */
+#define PCF2127A_REG_MN                        0x04 /* minute value    */
+#define PCF2127A_REG_HR                        0x05 /* hour value      */
+#define PCF2127A_REG_DM                        0x06 /* day value       */
+#define PCF2127A_REG_DW                        0x07 /* weekday value   */
+#define PCF2127A_REG_MO                        0x08 /* month value     */
+#define PCF2127A_REG_YR                        0x09 /* year value      */
+
+#define PCF2127A_REG_SC_ALARM          0x0A /* second alarm            */
+#define PCF2127A_REG_MN_ALARM          0x0B /* minute alarm            */
+#define PCF2127A_REG_HR_ALARM          0x0C /* hour alarm              */
+#define PCF2127A_REG_DM_ALARM          0x0D /* day alarm               */
+#define PCF2127A_REG_DW_ALARM          0x0E /* weekday alarm           */
+
+#define PCF2127A_REG_CLKO              0x0F /* clock out       */
+#define PCF2127A_REG_WD_TMRC           0x10 /* watchdog timer control  */
+#define PCF2127A_REG_WD_TMVAL          0x11 /* watchdog timer value    */
+
+#define PCF2127A_REG_TSCTL             0x12 /* timestamp control       */
+#define PCF2127A_REG_SC_TS             0x13 /* second timestamp        */
+#define PCF2127A_REG_MN_TS             0x14 /* minute timestamp        */
+#define PCF2127A_REG_HR_TS             0x15 /* hour timestamp          */
+#define PCF2127A_REG_DM_TS             0x16 /* day timestamp           */
+#define PCF2127A_REG_MO_TS             0x17 /* month timestamp         */
+#define PCF2127A_REG_YR_TS             0x18 /* year timestamp          */
+#define PCF2127A_REG_AGI_OFF           0x19 /* aging offset            */
+#define PCF2127A_REG_RAM_MSB           0x1A /* RAM address MSB         */
+#define PCF2127A_REG_RAM_LSB           0x1B /* RAM address LSB         */
+#define PCF2127A_REG_RAM_WCMD          0x1C /* RAM write command       */
+#define PCF2127A_REG_RAM_RCMD          0x1D /* RAM read command        */
+
+/* Bits in PCF2127A_REG_CTL1 */
+#define PCF2127A_BIT_SI                        0x01 /* second interrupt        */
+#define PCF2127A_BIT_MI                        0x02 /* minute interrupt        */
+#define PCF2127A_BIT_H_24_12           0x04 /* 12/24 hour mode         */
+#define PCF2127A_BIT_POR_OVRD          0x08 /* POR override            */
+#define PCF2127A_BIT_TSF1              0x10 /* timestamp flag 1        */
+#define PCF2127A_BIT_STOP              0x20 /* stop bit                */
+#define PCF2127A_BIT_EXTTEST           0x80 /* external clock test mode*/
+
+/* Bits in PCF2127A_REG_CTL2 */
+#define PCF2127A_BIT_CDTIE             0x01 /* countdown timer flag    */
+#define PCF2127A_BIT_AIE               0x02 /* alarm interrupt enable  */
+#define PCF2127A_BIT_TSIE              0x04 /* timestamp int. enable   */
+#define PCF2127A_BIT_CDTF              0x08 /* countdown timer flag    */
+#define PCF2127A_BIT_AF                        0x10 /* alarm flag              */
+#define PCF2127A_BIT_TSF2              0x20 /* timestamp flag 2        */
+#define PCF2127A_BIT_WDTF              0x40 /* watchdog timer flag     */
+#define PCF2127A_BIT_MSF               0x80 /* minute/second flag      */
+
+/* Bits in PCF2127A_REG_CTL3 */
+#define PCF2127A_BIT_BLIE              0x01 /* battery low Interrupt enable */
+#define PCF2127A_BIT_BIE               0x02 /* battery Switch int. enable */
+#define PCF2127A_BIT_BLF               0x04 /* battery low flag        */
+#define PCF2127A_BIT_BF                        0x08 /* battery switch flag     */
+#define PCF2127A_BIT_BTSE              0x10 /* battery timestamp enable */
+#define PCF2127A_BIT_BLDOFF            0x20 /* battery low detection off */
+#define PCF2127A_BIT_BSM               0x40 /* battery switch mode     */
+#define PCF2127A_BIT_BSOFF             0x80 /* battery switch off      */
+
+static struct i2c_driver pcf2127a_driver;
+
+/*
+ * In the routines that deal directly with the pcf2127a hardware, we use
+ * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
+ */
+static
+int pcf2127a_get_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+       unsigned char buf[10] = { PCF2127A_REG_CTL1 };
+
+       /*
+       * Note: We can't use i2c_transfer to send/recv multiple i2c_msg's
+       * to/from pcf2127a at once. The reason is that the pcf2127a doesn't
+       * handle (repeated START)-Conditions correctly.
+       *
+       * PCF2127A Manual, Section 9.2.2 START and STOP conditions:
+       * "Remark: For the PCF2127A a repeated START is not allowed. Therefore
+       * a STOP has to be released before the next START."
+       */
+
+       /* setup read ptr */
+       if (!i2c_master_send(client, buf, 1)) {
+               dev_err(&client->dev, "%s: write error\n", __func__);
+               return -EIO;
+       }
+
+       /* read status + date */
+       if (!i2c_master_recv(client, buf, 10)) {
+               dev_err(&client->dev, "%s: read error\n", __func__);
+               return -EIO;
+       }
+
+       if (buf[PCF2127A_REG_CTL3] & PCF2127A_BIT_BLF)
+               dev_info(&client->dev,
+                       "low battery detected, date/time is not reliable.\n");
+
+#ifdef DEBUG
+       unsigned char bf_buf[2];
+       if (buf[PCF2127A_REG_CTL3] & PCF2127A_BIT_BF) {
+               dev_info(&client->dev,
+                       "battery switch-over detected - reset BF flag.\n");
+
+               bf_buf[0] = PCF2127A_REG_CTL3;
+               bf_buf[1] = buf[PCF2127A_REG_CTL3] & ~PCF2127A_BIT_BF;
+               if (!i2c_master_send(client, bf_buf, 2)) {
+                               dev_err(&client->dev,
+                                       "%s: write error\n", __func__);
+                               return -EIO;
+                       }
+               }
+#endif
+
+       dev_dbg(&client->dev,
+               "%s: raw data is ctl1=%02x, ctl2=%02x, ctl3=%02x, sec=%02x, "
+               "min=%02x, hour=%02x, day=%02x, wday=%02x, month=%02x, "
+               "year=%02x\n",
+               __func__,
+               buf[0], buf[1], buf[2], buf[3],
+               buf[4], buf[5], buf[6], buf[7],
+               buf[8], buf[9]);
+
+       tm->tm_sec = bcd2bin(buf[PCF2127A_REG_SC] & 0x7F);
+       tm->tm_min = bcd2bin(buf[PCF2127A_REG_MN] & 0x7F);
+       tm->tm_hour = bcd2bin(buf[PCF2127A_REG_HR] & 0x3F); /* rtc hr 0-23 */
+       tm->tm_mday = bcd2bin(buf[PCF2127A_REG_DM] & 0x3F);
+       tm->tm_wday = buf[PCF2127A_REG_DW] & 0x07;
+       tm->tm_mon = bcd2bin(buf[PCF2127A_REG_MO] & 0x1F) - 1; /* rtc m 1-12 */
+       tm->tm_year = bcd2bin(buf[PCF2127A_REG_YR]);
+
+       if (tm->tm_year < 70)
+               tm->tm_year += 100;     /* assume we are in 1970...2069 */
+
+       /*
+        * the clock can give out invalid datetime, but we cannot return
+        * -EINVAL otherwise hwclock will refuse to set the time on bootup.
+        */
+       if (rtc_valid_tm(tm) < 0)
+               dev_err(&client->dev, "retrieved date/time is not valid.\n");
+
+       return 0;
+}
+
+static
+int pcf2127a_set_datetime(struct i2c_client *client, struct rtc_time *tm)
+{
+       int i, err;
+       unsigned char msgdata[2];       /* send data*/
+       unsigned char buf[10];          /* Index 0 - 9 */
+
+       /* hours, minutes and seconds */
+       buf[PCF2127A_REG_SC] = bin2bcd(tm->tm_sec);
+       buf[PCF2127A_REG_MN] = bin2bcd(tm->tm_min);
+       buf[PCF2127A_REG_HR] = bin2bcd(tm->tm_hour);
+
+       /* day of month */
+       buf[PCF2127A_REG_DM] = bin2bcd(tm->tm_mday);
+
+       /* weekday */
+       buf[PCF2127A_REG_DW] = tm->tm_wday & 0x07;
+
+       /* month, 1 - 12 */
+       buf[PCF2127A_REG_MO] = bin2bcd(tm->tm_mon + 1);
+
+       /* year */
+       buf[PCF2127A_REG_YR] = bin2bcd(tm->tm_year % 100);
+
+       /* write register's data */
+       for (i = 0; i < 7; i++) {
+               msgdata[0] = PCF2127A_REG_SC + i;
+               msgdata[1] = buf[PCF2127A_REG_SC + i];
+               err = i2c_master_send(client, msgdata, sizeof(msgdata));
+               if (err != sizeof(msgdata)) {
+                       dev_err(&client->dev,
+                               "%s: err=%d addr=%02x, data=%02x\n",
+                               __func__, err, msgdata[0], msgdata[1]);
+                       return -EIO;
+               }
+       }
+       return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static int pcf2127a_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+       return pcf2127a_get_datetime(to_i2c_client(dev), tm);
+}
+
+static int pcf2127a_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+       return pcf2127a_set_datetime(to_i2c_client(dev), tm);
+}
+
+static const struct rtc_class_ops pcf2127a_rtc_ops = {
+       .read_time      = pcf2127a_rtc_read_time,
+       .set_time       = pcf2127a_rtc_set_time,
+};
+
+/*---------------------------------------------------------------------------*/
+
+static int pcf2127a_probe(struct i2c_client *client,
+                               const struct i2c_device_id *id)
+{
+       struct rtc_device *pcf2127a_device;
+
+       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+               return -ENODEV;
+
+       dev_info(&client->dev, "chip found\n");
+
+       pcf2127a_device = rtc_device_register(pcf2127a_driver.driver.name,
+                               &client->dev, &pcf2127a_rtc_ops, THIS_MODULE);
+
+       if (IS_ERR(pcf2127a_device))
+               return PTR_ERR(pcf2127a_device);
+
+       i2c_set_clientdata(client, pcf2127a_device);
+
+       return 0;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static int pcf2127a_remove(struct i2c_client *client)
+{
+       struct rtc_device *pcf2127a_device = i2c_get_clientdata(client);
+
+       if (pcf2127a_device)
+               rtc_device_unregister(pcf2127a_device);
+
+       return 0;
+}
+
+static const struct i2c_device_id pcf2127a_id[] = {
+       /*
+        * This driver should also work with the pcf2127, but
+        * I can't prove it.
+        */
+       { "pcf2127a", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, pcf2127a_id);
+
+static struct i2c_driver pcf2127a_driver = {
+       .driver         = {
+               .name   = "rtc-pcf2127a",
+       },
+       .probe          = pcf2127a_probe,
+       .remove         = pcf2127a_remove,
+       .id_table       = pcf2127a_id,
+};
+
+static int __init pcf2127a_init(void)
+{
+       return i2c_add_driver(&pcf2127a_driver);
+}
+module_init(pcf2127a_init);
+
+static void __exit pcf2127a_exit(void)
+{
+       i2c_del_driver(&pcf2127a_driver);
+}
+module_exit(pcf2127a_exit);
+
+MODULE_AUTHOR("ECKELMANN AG");
+MODULE_DESCRIPTION("NXP/Philips PCF2127A RTC (I2C) driver");
+MODULE_LICENSE("GPL");
--
1.9.3
It would be good if this could be rolled into the distro as this also uses that chip and suggests the same 3.6 custom firmware (which gets nuked as soon as you do an apt-get upgrade).

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Adding a driver for RasClock [RTC]

Wed Jul 09, 2014 10:53 pm

asandford wrote:It would be good if this could be rolled into the distro
I've seen @popcornmix say he's happy to enable extra modules in the default build of https://github.com/raspberrypi/linux (which then gets included into https://github.com/raspberrypi/firmware), but only after the driver has been merged into the upstream kernel first.

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Adding a driver for RasClock [RTC]

Wed Jul 09, 2014 11:40 pm

AndrewS wrote: I've seen @popcornmix say he's happy to enable extra modules in the default build of https://github.com/raspberrypi/linux (which then gets included into https://github.com/raspberrypi/firmware), but only after the driver has been merged into the upstream kernel first.
I have no idea of what needs to be done for this to happen :oops:

There is a module for the pcf2127, but not pcf2127a.

I've just recompiled the module (the last time was a month or so ago) with a screen attached, and I get a load of errors on the console when I modprobed it (but nothing on the ssh session as the pi had gone into dbug mode) , so where would these errors be recorder (gone thru' /var/log/* and can't find them)?

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Adding a driver for RasClock [RTC]

Thu Jul 10, 2014 12:13 am

asandford wrote:I have no idea of what needs to be done for this to happen :oops:
Sounds like you need to get in touch with the original patch author(s), and get them to update it for the 3.12.y kernel and/or ask them to upstream it to the mainline kernel.
I've just recompiled the module (the last time was a month or so ago) with a screen attached, and I get a load of errors on the console when I modprobed it (but nothing on the ssh session as the pi had gone into dbug mode) , so where would these errors be recorder (gone thru' /var/log/* and can't find them)?
When doing this kind of kernel/driver debugging, you really want to be accessing it over a serial console connection...

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

Re: Adding a driver for RasClock [RTC]

Thu Jul 10, 2014 6:56 am

asandford wrote:
AndrewS wrote: I've seen @popcornmix say he's happy to enable extra modules in the default build of https://github.com/raspberrypi/linux (which then gets included into https://github.com/raspberrypi/firmware), but only after the driver has been merged into the upstream kernel first.
I have no idea of what needs to be done for this to happen :oops:

There is a module for the pcf2127, but not pcf2127a.

I've just recompiled the module (the last time was a month or so ago) with a screen attached, and I get a load of errors on the console when I modprobed it (but nothing on the ssh session as the pi had gone into dbug mode) , so where would these errors be recorder (gone thru' /var/log/* and can't find them)?
Please create a new thread - this is going way off topic :?
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

moryoav
Posts: 13
Joined: Tue Jul 08, 2014 8:44 am

Re: Adding a driver for RasClock [RTC]

Thu Jul 10, 2014 11:48 am

For people facing the same problem, I now have a solution.
As mentioned in the op, it turns out that the latest releases of Raspbian include rtc-pcf2127.
It also turns out that the latest RasClock has a chip that's compatible with rtc-pcf2127, even though it's actually rtc-pcf2127a or rtc-pcf2127at.
So all I had to do was to add to etc\modules:

Code: Select all

i2c-bcm2708
rtc-pcf2127
and then to add this to etc\rc.local (notice that it's pcf2127 and not pcf2127a as written in the original manufacturer's documentation):

Code: Select all

echo pcf2127 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
( sleep 2; hwclock -s ) &
And that's it. In the end this turned out to be a very simple solution.

Thank you all for your suggestions.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Adding a driver for RasClock [RTC]

Thu Jul 10, 2014 1:18 pm

moryoav wrote:For people facing the same problem, I now have a solution.
I don't have an RTC, but it's great to hear you solved the problem :)
(notice that it's pcf2127 and not pcf2127a as written in the original manufacturer's documentation)
Did you email them to suggest they update their instructions?

riyakottoor
Posts: 1
Joined: Mon Jun 20, 2016 5:13 am

Copying time from RTC to R Pi

Sat Sep 17, 2016 6:49 pm

I connected PCF2127AT RTC IC using I2C to Raspberry Pi model B+. My system time was not correct. So I made it correct by turning off the NTP and manually setting it and then turning on the NTP. Then I copied the system time to the RTC. Problem is whenever I shut down the R Pi and switch it on, the time is not correct. I will have to set it to the correct date and time again. How can I solve this issue?

Return to “HATs and other add-ons”