Questions: Real Time Clock over I2C


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:

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?


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). The beaglebone kernel includes the driver for this device. 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/* ?

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.

Thanks guys,

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

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

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.

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

@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?

@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?