dm314
Posts: 10
Joined: Fri Jan 18, 2013 1:40 am

DS1307 hwclock -r problem

Mon Jan 28, 2013 7:58 am

Hi,

I followed this tutorial to setup the RTC for the Rpi.

http://learn.adafruit.com/adding-a-real ... t-rtc-time
(I remove the pullups)

It was pretty successful and I got the hwclock -r to display the time from the hw clock.
As I was moving on to my next phase and while rebooting the Rpi, I noticed the line saying

Loading kernel module rtc-1307
FATAL: Module rtc-1307 not found.

and when I tried sudo hwclock -r, it says

hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

I checked i2cdetect -y 1, but I'm getting the address 68.

What I did was I tried doing the adafruit tutorial and test hwclock -r again.
So I remove the "rtc-1307" and "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device" lines from /etc/modules and /etc/rc.local respectively. I also modprobe -r the rtc_ds1307 under lsmod.
After that I rebooted.

i2cdetect detects address 68, then
sudo modprobe rtc-ds1307, then
sudo bash, then
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device, then

when I hit hwclock -r, I still get

hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --debug option to see the details of our search for an access method.

I think I'm missing something, but I can't figure it out. So far I didn't find any solution and reference on Google so I tried posting here.

Btw, why did the tutorial added just only "rtc-1307" to /etc/modules instead of "rtc-ds1307"?
Just curious, but rtc-1307 worked for me when I didn't have my current problem.

It's my first post :)
Thanks,

repton
Posts: 91
Joined: Sat Mar 17, 2012 6:06 pm
Location: North Yorkshire, UK.
Contact: Website

Re: DS1307 hwclock -r problem

Mon Jan 28, 2013 8:19 am

dm314 wrote:Btw, why did the tutorial added just only "rtc-1307" to /etc/modules instead of "rtc-ds1307"?
Just curious, but rtc-1307 worked for me when I didn't have my current problem.
I suspect that is simply a bug in the tutorial as the module on mine seems to be rtc-ds1307 too.

Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

dm314
Posts: 10
Joined: Fri Jan 18, 2013 1:40 am

Re: DS1307 hwclock -r problem

Mon Jan 28, 2013 8:23 am

Thanks for the reply.

I also want to try "rtc-ds1307" on /etc/modules but I can't read it through hwclock -r. :(

jfornango
Posts: 113
Joined: Fri Sep 14, 2012 7:46 pm
Location: St. Louis, MO USA
Contact: Yahoo Messenger

Re: DS1307 hwclock -r problem

Mon Jan 28, 2013 6:14 pm

Longer discussion on the DS1307 here:
http://www.raspberrypi.org/phpBB3/viewt ... 07#p269238

I hit this too, and found an interesting quirk. Try this:

Code: Select all

sudo -s
hwclock -r
I'll bet you a Cup-O-Ramen that you get the time. Page 18 of the thread I listed has a discussion on the permissions needed to get a non-sudo call for hwclock to work.
I'm only wearing black until they find something darker.

dm314
Posts: 10
Joined: Fri Jan 18, 2013 1:40 am

Re: DS1307 hwclock -r problem

Tue Jan 29, 2013 1:02 am

Hi jfornango,

Thanks, but you owe me a cup. Hahahaha.

I tried sudo -s , sudo -i , I still can't access the hwclock.

Btw, there is this time that when I do an i2cdetect -y 1
instead of getting a "68", I'm getting a "UU"

i2cdetect says (about UU)

Probing was skipped, because this address is currently in use by a
driver. This strongly suggests that there is a chip at this address.

dm314
Posts: 10
Joined: Fri Jan 18, 2013 1:40 am

Re: DS1307 hwclock -r problem

Tue Jan 29, 2013 2:33 am

When I do i2cdetect -y 1, I get a 68
But when I typed echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
I'm getting now the UU on i2cdetect -y 1

It seems that I have to delete or unregister my device on the I2C bus and register again
but I don't know how. Help!

jfornango
Posts: 113
Joined: Fri Sep 14, 2012 7:46 pm
Location: St. Louis, MO USA
Contact: Yahoo Messenger

Re: DS1307 hwclock -r problem

Tue Jan 29, 2013 7:52 pm

UU? That changes things.
I remember seeing that when I was getting mine set up.

Can't remember where in the troubleshooting I found it (currently at work, so I can't get to my notes).
Let me run down the setup and see if you missed something (I seem to remember that was my problem).

As root (sudo -s)
# dpkg --purge fake-hwclock
# rm /etc/rcS.d/K0?hwclock.sh

Install the I2C tools:
# apt-get update && sudo apt-get install i2c-tools
# modprobe i2c-bcm2708
# modprobe i2c-dev
# modprobe rtc-ds1307

edit /etc/init.d/hwclock and modify the following lines in the header as:
# Required-Start: mountdevsubfs kmod
# X-Start-Before:

Add this to the end of /etc/default/hwclock:
echo pcf8563 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

Manually build your symlinks:
# cd /etc/rc0.d
# ln -s ../init.d/hwclock.sh K06hwclock.sh
# cd ../rc6.d
# ln -s ../init.d/hwclock.sh K06hwclock.sh
# cd ../rcS.d
# ln -s ../init.d/hwclock.sh S10hwclock.sh

Then enable it:
# update-rc.d hwclock.sh enable

Add these to /etc/modules:
i2c-bcm2708
i2cdev
rtc-ds1307 (yes, this one is needed)

Edit /etc/modprobe.d/raspi-blacklist.conf and comment out the line
#blacklist i2c-bcm2708

At this point, I'd recommend a reboot ( I know I did one several times while I was working on this). However, at this point, a 'sudo hwclock -r' should get you the time.
I'm only wearing black until they find something darker.

dm314
Posts: 10
Joined: Fri Jan 18, 2013 1:40 am

Re: DS1307 hwclock -r problem

Thu Jan 31, 2013 2:55 am

I've got it working!!

My problem was the RTC hardware. I don't know but when I unplugged and plugged the power
supply of the RTC, it doesn't preserve the time even though it has a backup battery. That 's why
I've got an "invalid argument" error always.

Thanks

technion
Posts: 238
Joined: Sun Dec 02, 2012 9:49 am

Re: DS1307 hwclock -r problem

Thu Jan 31, 2013 3:59 am

dm314 wrote:I've got it working!!

My problem was the RTC hardware. I don't know but when I unplugged and plugged the power
supply of the RTC, it doesn't preserve the time even though it has a backup battery. That 's why
I've got an "invalid argument" error always.

Thanks
That's exactly what the battery is there to protect against. Either your battery isn't connected properly or the unit is faulty somehow.
I know I relocated my pi several times by physically unplugging every cable and the RTC always kept its time, though I have the improved "Chronodot".

jfornango
Posts: 113
Joined: Fri Sep 14, 2012 7:46 pm
Location: St. Louis, MO USA
Contact: Yahoo Messenger

Re: DS1307 hwclock -r problem

Sat Feb 02, 2013 12:55 am

stupid question: Did you remember to write the current time to the RTC? (hwclock -w)
I'm only wearing black until they find something darker.

ismo67
Posts: 1
Joined: Tue Mar 12, 2013 9:33 pm

Re: DS1307 hwclock -r problem

Tue Mar 12, 2013 9:38 pm

I will get this result:

[email protected] ~ $ sudo hwclock -r
hwclock: Timed out waiting for time change.
hwclock: The Hardware Clock registers contain values that are either invalid (e.g. 50th day of month) or beyond the range we can handle (e.g. Year 2095).

What went wrong?

Should hwclock.sh be edited like the bold lines?
edit /etc/init.d/hwclock and modify the following lines in the header as:
Required-Start: mountdevsubfs kmod
X-Start-Before:

treybert64
Posts: 1
Joined: Wed Jan 08, 2014 2:45 am

Re: DS1307 hwclock -r problem

Wed Jan 08, 2014 2:47 am

i'm having the same exact problem as you are.

kolon
Posts: 13
Joined: Tue Sep 10, 2013 10:34 pm

Re: DS1307 hwclock -r problem

Sat Mar 22, 2014 8:15 pm

Just thought I'd comment - I recently purchased an i2c pressure sensor, and found that with it plugged in along side my RTC, i got

Code: Select all

[email protected] ~ $ sudo hwclock -r
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Input/output error
But, if I issued two hwclock commands quickly, the first failed but the second responded

Code: Select all

[email protected] ~ $ sudo hwclock -r
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Input/output error
[email protected] ~ $ sudo hwclock -r
Sat 22 Mar 2014 20:07:11 UTC  -0.772628 seconds
With the sensor unplugged, the rtc worked fine.

I'm doing some investigation into the pressure sensor, as I think it might be dodgy, which is no surprise, as it came from chinabay!

litoy2x
Posts: 12
Joined: Fri Apr 19, 2013 9:08 am

Re: DS1307 hwclock -r problem

Sat Sep 13, 2014 6:25 pm

I just bought my pi, enable i2c and install the i2c tools. I didn't connect anything yet, I just tried the i2cdetect:

$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

i don't know what is UU means, but i just add blocklisted snd_soc_wm8804 in my /etc/modprobe.d/raspi-blacklist.conf
i found the solution in here https://www.hifiberry.com/forums/topic/i2cdetect/

RPi info:
$uname -a
Linux rasp1 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux

$ /opt/vc/bin/vcgencmd version
Sep 8 2014 19:02:48
Copyright (c) 2012 Broadcom
version 3f2f2607186be72e4945cfa8edc77872dfc73195 (clean) (release)

User avatar
DougieLawson
Posts: 37666
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: DS1307 hwclock -r problem

Sat Sep 13, 2014 7:53 pm

Try powering your DS1307 from the Raspberry Pi's 5V0 (pin2 or pin4) line rather than 3V3.

If using the Adafruit breakout board snip those two 2.2Kohm resistors off the board so you don't feed 5V0 into a GPIO pin.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

lcteam
Posts: 1
Joined: Sat Oct 04, 2014 5:52 pm

Re: DS1307 hwclock -r problem

Sat Oct 04, 2014 6:07 pm

check the "Crystal 32.768kHz"

I had the same problem and i had broken "Crystal 32.768kHz"


Best regards

mr.mtb
Posts: 1
Joined: Fri Aug 26, 2016 4:10 pm

Re: DS1307 hwclock -r problem

Fri Aug 26, 2016 4:21 pm

In regards to the original question, I had the same problem and I fixed it by using a pipe "|" instead of a stdout ">". So, I would try:
"sudo echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device"

I have a ds3231, so I used that instead of ds1307 above. I too had 68 at 68, but after the above command it changed to UU at 68 and "sudo hwclock" worked. I found this solution here:
http://bohdan-danishevsky.blogspot.com/ ... 32-to.html

User avatar
DougieLawson
Posts: 37666
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: DS1307 hwclock -r problem

Fri Aug 26, 2016 11:14 pm

mr.mtb wrote:In regards to the original question, I had the same problem and I fixed it by using a pipe "|" instead of a stdout ">". So, I would try:
"sudo echo ds1307 0x68 | sudo tee /sys/class/i2c-adapter/i2c-1/new_device"
That is 100% completely irrelevant. There's no need to run the echo command with the DT enabled kernels.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

spoksss
Posts: 1
Joined: Tue Mar 20, 2018 10:52 pm

Re: DS1307 hwclock -r problem

Tue Mar 20, 2018 10:55 pm

lcteam wrote:
Sat Oct 04, 2014 6:07 pm
check the "Crystal 32.768kHz"

I had the same problem and i had broken "Crystal 32.768kHz"


Best regards

That was the same case in my situation.
I fight with software and after this comment I replace RTC with new one for test without any other changes.
Now works perfect!
Thank you

Return to “Interfacing (DSI, CSI, I2C, etc.)”