Questions: Real Time Clock over I2C

446 views
Skip to first unread message

Beagle Boner

unread,
Jun 8, 2017, 7:59:03 AM6/8/17
to BeagleBoard
Hi,

i´m using the latest Debian Image an I´m trying to set an external RTC as a hardwareclock for my BBB. I have a different RTC module (PCF8563) but basicly I stick to the following manual:
https://learn.adafruit.com/adding-a-real-time-clock-to-beaglebone-black/set-rtc-time

What I dont understand here is the following:

The author sets the ds1307 as a new i2c device with the command:

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

In the next step he can already access the new rtc1 device.

hwclock -r -f /dev/rtc1

Why is that? How does the system know that the new i2c device connected is a RTC and how to access it. Is there a preinstalled driver for DS1307?



According to the manual I did the following:

echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-2/new_device

My PCF8563 is getting recognized as rtc1 (not sure why - I havent installed any drivers?)

When I try to access

hwclock -r -f /dev/rtc1

I just get

hwclock: ioctl(RTC_RD_TIME) to /dev/rtc1 to read the time failed: Invalid argument

Does anyone have some hints on that?

Cheers.




David Lechner

unread,
Jun 8, 2017, 10:15:10 AM6/8/17
to beagl...@googlegroups.com
On 06/08/2017 06:59 AM, Beagle Boner wrote:
Hi,

i´m using the latest Debian Image an I´m trying to set an external RTC as a hardwareclock for my BBB. I have a different RTC module (PCF8563) but basicly I stick to the following manual:
https://learn.adafruit.com/adding-a-real-time-clock-to-beaglebone-black/set-rtc-time

What I dont understand here is the following:

The author sets the ds1307 as a new i2c device with the command:

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

In the next step he can already access the new rtc1 device.

hwclock -r -f /dev/rtc1

Why is that? How does the system know that the new i2c device connected is a RTC and how to access it. Is there a preinstalled driver for DS1307?

The first command instructs the I2C adapter that there is a device at address 0x68 and to match it with an I2C driver "ds1307". When the driver loads, it creates a new /dev/rtcX device (and also a new /sys/class/rtc/rtcX device).




According to the manual I did the following:

echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-2/new_device

My PCF8563 is getting recognized as rtc1 (not sure why - I havent installed any drivers?)

The beaglebone kernel includes the driver for this device.



When I try to access

hwclock -r -f /dev/rtc1

I just get

hwclock: ioctl(RTC_RD_TIME) to /dev/rtc1 to read the time failed: Invalid argument

Does anyone have some hints on that?

Which pins are you using? Have you set the pin mux for I2C? Can you read any of the files at /sys/class/rtc/rtc1/* ?


Cheers.




--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/9645489d-9a24-4888-b124-e3eeac3f0811%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


William Hermans

unread,
Jun 8, 2017, 5:15:38 PM6/8/17
to beagl...@googlegroups.com
If the driver is loading, it's very unlikely the hardware is setup incorrectly. I will tell you from hands on, if you manually load your RTC driver like this. You may have to write to the RTC, before reading from it. Otherwise you'll experience that error, or one similar to it.



Message has been deleted

Beagle Boner

unread,
Jun 9, 2017, 4:57:39 AM6/9/17
to BeagleBoard
Thanks guys,

your thoughts and hints helped me a bit and I think it´s running fine now.

@David:
I2C was setup correctly. I can read and write all the registers manualy with the i2c tools.

@Willian:
Just as you thought, after I wrote to the RTC I don´t get the error when reading anymore, thanks.
When i wrote the time to the RTC for the first time with

hwclock -w -f /dev/rtc1

I got the same error although it´s working fine.

must...@braingrid.io

unread,
Oct 30, 2018, 8:01:23 PM10/30/18
to BeagleBoard
@Beagle Bone How did you end up resolving the error? I followed the exact same set up as you but still getting Invalid arguments error?

MG

unread,
Oct 30, 2018, 8:01:35 PM10/30/18
to BeagleBoard
@Beagle Boner I'm still having this issue you reported. Even when I try to write to it I get the Invalid argument error. How did you solve that?
Reply all
Reply to author
Forward
0 new messages