Page 1 of 2

PI2 RTC can't work PCF8563

Posted: Sat Feb 14, 2015 10:20 am
by DRAgon715205
Hi People
I get a Pi2 . my RTC is pcf8563. it can work fine at my B+ . but can't work fine at my PI2

MY CODE:
[email protected]:/home/pi# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

[email protected]:/home/pi# modprobe i2c-dev
[email protected]:/home/pi# echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
[email protected]:/home/pi# hwclock -r
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: No such file or directory

who can tell me Why I can find "/dev/rtc0 " at B+ But can't find it at PI2?

Re: PI2 RTC can't work PCF8563

Posted: Sat Feb 14, 2015 2:45 pm
by mikronauts
I ran into this problem too, without a resolution. I was pointed at the new device tree documentation.

My best guess is that the source for hwclock has not been updated.

I wrote some python code to read/set the RTC, I'll post it on my site once I clean it up.

Re: PI2 RTC can't work PCF8563

Posted: Sat Feb 14, 2015 4:04 pm
by Paul Webster
You could try disabling Device Tree ... with device_tree= in config.txt
However, RPF states this this work around might not be kept for the future ... so proper solution may well be to ensure that the correct DT is loaded and then take a look to see which devices appear

https://github.com/raspberrypi/document ... ce-tree.md

Re: PI2 RTC can't work PCF8563

Posted: Sat Feb 14, 2015 4:17 pm
by mikronauts
Thank you, I'll take a look.

On my previous try, I found /dev/rtc0 without issues, but even specifying /dev/rtc0 to hwclock it still hung.

I ended up writing Python code to set the RTC from the system time, and another script to read it back.

Now I just have to finish the part that sets the system time from what I read back from the RTC :)
Paul Webster wrote:You could try disabling Device Tree ... with device_tree= in config.txt
However, RPF states this this work around might not be kept for the future ... so proper solution may well be to ensure that the correct DT is loaded and then take a look to see which devices appear

https://github.com/raspberrypi/document ... ce-tree.md

Re: PI2 RTC can't work PCF8563

Posted: Sat Feb 14, 2015 4:47 pm
by DRAgon715205
Changing the Device Tree seem to don't change anything!!

I think I just can wait it to update the hwclock

Re: PI2 RTC can't work PCF8563

Posted: Sat Feb 14, 2015 4:48 pm
by DRAgon715205
I hope someone to update the hwclock to work at the PI2

Re: PI2 RTC can't work PCF8563

Posted: Fri Feb 27, 2015 3:40 pm
by apelizza
Does someone have found a solution to this problem? I've got a pcf8563 and I don't know how to keep it working with the new pi2 with raspbian.

Re: PI2 RTC can't work PCF8563

Posted: Sat Mar 28, 2015 2:46 pm
by MrBool
I have the some problem with Raspberry Compute Module. Does someone have found a solution?

Re: PI2 RTC can't work PCF8563

Posted: Sat Mar 28, 2015 8:11 pm
by pykoon
I have the same problem since my last update in march.

As saw there is no solution... So bad. :cry: :cry: :cry: :cry:

Re: PI2 RTC can't work PCF8563

Posted: Sun Mar 29, 2015 10:27 am
by DirkS
pykoon wrote:I have the same problem since my last update in march.

As saw there is no solution... So bad. :cry: :cry: :cry: :cry:
Exactly what is not working? Did you set up the RTC by adding

Code: Select all

dtparam=i2c
dtoverlay=i2c-rtc,pcf8563
to /boot/config.txt.
You may also have to add

Code: Select all

i2c-dev
to /etc/modules

Re: PI2 RTC can't work PCF8563

Posted: Sun Mar 29, 2015 7:29 pm
by MrBool
The reason is hwclock from util-linux.
I download, compile and install latest version of util-linux and hwclock works fine, but after reboot I can't login.
So solution will be new util-linux package.

Re: PI2 RTC can't work PCF8563

Posted: Sat Apr 04, 2015 9:03 pm
by pykoon
MrBool, Could you explain how do you rebuilt util-linux on raspberry?
It seem to be hard no?

Tx,

Re: PI2 RTC can't work PCF8563

Posted: Thu Apr 09, 2015 7:06 am
by MrBool
Build util-linux on raspberry is easy. Here is build procedure for hwclock. If you want build all util-linux change "make hwclock" to "make".

Code: Select all


wget https://www.kernel.org/pub/linux/utils/util-linux/v2.26/util-linux-2.26.1.tar.gz

tar zxvf util-linux-2.26.1.tar.gz

cd util-linux-2.26.1

apt-get install gcc

./configure --without-python --without-systemd --without-ncurses 

make hwclock

Re: PI2 RTC can't work PCF8563

Posted: Thu Apr 16, 2015 5:58 pm
by ShiftPlusOne
Upgrading hwclock does not fix the issue, it just hides it:

Code: Select all

[email protected] ~/temp $ tar zxf util-linux-2.26.1.tar.gz
[email protected] ~/temp $ cd util-linux-2.26.1/
[email protected] ~/temp/util-linux-2.26.1 $ ./configure --without-python --without-systemd --without-ncurses  > /dev/null
configure: WARNING: ncurses or slang library not found; not building cfdisk
configure: WARNING: libcap-ng library not found; not building setpriv
configure: WARNING: PAM header file not found; not building chfn_chsh
configure: WARNING: PAM header file not found; not building login
configure: WARNING: PAM header file not found; not building su
configure: WARNING: PAM header file not found; not building runuser
configure: WARNING: ncurses or ncursesw library not found; not building pg
configure: WARNING: ncurses library not found; not building setterm
configure: WARNING: libpython not found; not building pylibmount
[email protected] ~/temp/util-linux-2.26.1 $ make hwclock > /dev/null
[email protected] ~/temp/util-linux-2.26.1 $ sudo ./hwclock -r
Thu 16 Apr 2015 17:57:07 UTC  .983229 seconds
[email protected] ~/temp/util-linux-2.26.1 $ sudo ./hwclock -r -D
hwclock from util-linux 2.26.1
Using the /dev interface to the clock.
Last drift adjustment done at 1429205484 seconds after 1969
Last calibration done at 1429205484 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
select() to /dev/rtc0 to wait for clock tick timed out...synchronization failed
[email protected] ~/temp/util-linux-2.26.1 $ 
Edit: actually, the warning is a red herring. viewtopic.php?f=28&t=97257&start=25#p730378

I'll keep digging.

Re: PI2 RTC can't work PCF8563

Posted: Thu Apr 16, 2015 6:51 pm
by ShiftPlusOne
...there it is!

hwclock-rtc.c:311

Code: Select all

			rc = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
			ret = 1;
			if (rc == -1)
				warn(_("select() to %s to wait for clock tick failed"),
				     rtc_dev_name);
			else if (rc == 0 && debug)
				printf(_("select() to %s to wait for clock tick timed out"),
				     rtc_dev_name);
			else
				ret = 0;
In both cases, select times out and returns 0. When you run it without -D, the 'else' path is taken and the function returns success. If you run with -D, the else if (rc == 0 && debug) condition is met and the 'else' doesn't run, leaving ret == 1!

Edit: let's see what happens https://bugs.debian.org/cgi-bin/bugrepo ... bug=782726
Edit 2: http://thread.gmane.org/gmane.linux.uti ... x-ng/11187
https://git.kernel.org/cgit/utils/util- ... bd5c5a51dc

Re: PI2 RTC can't work PCF8563

Posted: Tue May 26, 2015 11:32 pm
by j03r6
ShiftPlusOne, I think that's more a problem of hwclock-rtc.c:269 which should fail with the pcf 8563, because it's an i2c and has no interrupts.
But I have no idea how or where to fix that.

For a quick and dirty test hack I just changed 271 to make the condition always true:

Code: Select all

if (1 || rc == -1 && (errno == ENOTTY || errno == EINVAL)) {
And succeeded:

Code: Select all

[email protected] ~/util-linux-2.26.1 $ sudo ./hwclock -Dr
hwclock from util-linux 2.26.1
Using the /dev interface to the clock.
Last drift adjustment done at 1432675502 seconds after 1969
Last calibration done at 1432675502 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc0 does not have interrupt functions. Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2015/05/26 23:29:37
Hw clock time : 2015/05/26 23:29:37 = 1432682977 seconds since 1969
Time since last adjustment is 7475 seconds
Calculated Hardware Clock drift is 0.000000 seconds
Mit 27 Mai 2015 01:29:36 CEST  .864657 seconds

Re: PI2 RTC can't work PCF8563

Posted: Wed May 27, 2015 1:25 pm
by ShiftPlusOne
I think there are multiple problems and the fact that hwclock failed to report an error was one of them. The next is why it doesn't work in the first place. I don't think that problem is in hwclock, I think it's in the driver, since it works properly with other devices. Looking into it is at the bottom of a long todo list.

Re: PI2 RTC can't work PCF8563

Posted: Mon Jun 15, 2015 5:34 pm
by uxc
It looks like the problem has been resolved.

Code: Select all

sudo apt-get update 
sudo apt-get install util-linux
hwclock from util-linux 2.25.2 works fine with pcf8563.

Re: PI2 RTC can't work PCF8563

Posted: Mon Jun 15, 2015 5:49 pm
by ShiftPlusOne
uxc wrote:It looks like the problem has been resolved.

Code: Select all

sudo apt-get update 
sudo apt-get install util-linux
hwclock from util-linux 2.25.2 works fine with pcf8563.
No, it hasn't.

Re: PI2 RTC can't work PCF8563

Posted: Sun Jul 05, 2015 4:22 am
by mikronauts
Is there any news on this?

In case there is not, I have written (and I am now testing)

setrtc.py - sets PCF8563 to current system time
getrtc.py - sets current system time from PCF8563

As soon as I am satisfied that there are no multi-legged creatures left in my code I'll upload it to my Pi Rtc Dio product page (which has a PCF8563 and two MCP23017's on it, thus my interest in this thread)

http://www.mikronauts.com/raspberry-pi/pi-rtc-dio/

Re: PI2 RTC can't work PCF8563

Posted: Sun Jul 05, 2015 4:59 am
by ShiftPlusOne
I haven't looked at it in a while, but I doubt anything has changed.

Re: PI2 RTC can't work PCF8563

Posted: Mon Jul 06, 2015 6:06 pm
by Houtkamp
Has anyone found a way to make the RTC work? Mine says no such file or directory.

sudo i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory

Is somebody working on it, or is it just another lost cause?

THANKS

Bill

Re: PI2 RTC can't work PCF8563

Posted: Mon Jul 06, 2015 6:24 pm
by DougieLawson
You'd not enabled the i2c overlay or a specific RTC overlay in /boot/config.txt. Take a look at /boot/overlays/README.

Re: PI2 RTC can't work PCF8563

Posted: Tue Jul 07, 2015 6:29 am
by ShiftPlusOne
That particular error is a result of not having i2c-dev loaded.

Re: PI2 RTC can't work PCF8563

Posted: Wed Jul 29, 2015 1:54 pm
by jackbrux
Any update on this? I tried everything online to get my pcf8563 to work with my B+, keep getting this error using hwclock --debug:

Code: Select all

Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: No such file or directory
...synchronisation failed