Austriker
Posts: 19
Joined: Wed Aug 26, 2015 1:18 pm

Chronodot with rtc-ds1307 Read Error

Wed Aug 26, 2015 1:58 pm

Hi,

I just bought a Chronodot v2.1 but I am having trouble making it work with my raspberry pi 2.

I followed the tutorial in this thread : viewtopic.php?f=44&t=16218&start=50

In /etc/rc.local :

Code: Select all

echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -s
and i removed the fake-hwclock with apt-get remove.

But when i do :

Code: Select all

sudo hwclock -s
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc0 to read the time failed: Input/output error
I checked if the driver was loaded on the address 0x68 :

Code: Select all

sudo 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --    
and when I check with dmesg :

Code: Select all

dmesg | grep ds3231
[   20.810822] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0
[   20.810879] i2c i2c-1: new_device: Instantiated device ds3231 at 0x68

dmesg | grep ds1307
[   20.810822] rtc-ds1307 1-0068: rtc core: registered ds3231 as rtc0
[  900.302277] rtc-ds1307 1-0068: read error -5
[ 1041.251866] rtc-ds1307 1-0068: read error -5

dmesg | grep i2c
[    3.089671] bcm2708_i2c 3f804000.i2c: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000)
[    5.842837] i2c /dev entries driver
[   20.810879] i2c i2c-1: new_device: Instantiated device ds3231 at 0x68
But when i test hwclock I get :

Code: Select all

sudo hwclock --show --debug
hwclock from util-linux 2.20.1
Using /dev interface to clock.
Last drift adjustment done at 543 seconds after 1969
Last calibration done at 543 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: ioctl() to /dev/rtc0 to turn on update interrupts failed unexpectedly: Input/output error
...synchronization failed
I can't find the origin of my bug.

Thanks for your help,
Sincerely.

SteveA
Posts: 32
Joined: Sat Mar 14, 2015 11:18 am
Location: South Yorkshire, England

Re: Chronodot with rtc-ds1307 Read Error

Wed Jan 04, 2017 11:02 pm

I have the same/similar problems and have spent many weeks trying to resolve it without success. I made a post at:

viewtopic.php?f=33&t=169833&p=1090515#p1090515

which explains my problem. I have gone back on all of the forums posts I can find and see that it is a common problem but without a resolution.

Have you managed to sort it out? If so, could your share it?

Thanks
Steve

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

Re: Chronodot with rtc-ds1307 Read Error

Wed Jan 04, 2017 11:43 pm

Are you serious, because the way you configure RTC has completely changed since the original post was made?

Add

Code: Select all

dtoverlay=i2c-rtc,ds3231
to /boot/config.txt, reboot and it will "just work".
Criticising any questions is banned on this forum.

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

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

SteveA
Posts: 32
Joined: Sat Mar 14, 2015 11:18 am
Location: South Yorkshire, England

Re: Chronodot with rtc-ds1307 Read Error

Thu Jan 05, 2017 8:36 am

Are you talking about this post or my reference to my recent post?

Yes I am serious.

And yes, I have followed the most recent methods of installing an RTC on Jessie. The RTC works fine, everytime, everyday, etc, until there is just one other access on the i2c to use such as a DAC, after which the RTC access fails as per this post and my post, to which I refer.

As I mention in this post there seems to be a long lasting problem with the RTC/I2C over the years which end up with the similar symptoms of hanging, file i/o error, etc, but only after using the I2C bus for something else, all of which never show a solution or a happy ending.

I have the line added as you show. Out of interest can you access your RTC, then another i2c device on the same bus and then access the RTC again, because if so and if you have a definitive step by step method of installation over and above what is on this forum, please share. It is quite critical for me because the hang up stops the stand alone remote logging system (which has no internet access).

There are many posts relating to I2C/RTC problems and so this is a chance to crack it once and for all!

=====
For completeness these are my notes listing the steps I use to install the RTC, please feel free to correct or comment as a solution is what I am aiming for:

1. ENABLE I2C MODULE AT BOOTUP USING CONFIG
The I2C module needs to be be enabled in the RPi kernel to come in at boot up. Edit the config menu settings:
sudo raspi-config

Select (5) Interfacing` Options then 'P5 I2C - Enable/Disable automatic loading of I2C kernel module' and follow the prompts to ENABLE the ARM i2c interface, to add it to the kernel and include it at boot time.

2. I2C AT BOOTUP
Open and check config.txt file:
sudo nano /boot/config.txt

The following line should already be in the config.txt, and it sets i2c on:
dtparm=i2c_arm=on # should be on

Info: the previous param to turn on I2C is not used now as it specified channel 0 or 1
# dtparm=i2c1=on # this sets ch1 on and so best to use above dtparm=i2c_arm=on

Note that these other options are also seen in the config.txt file
#dtparam=i2s=on # this option is commented out
dtparam=spi=off # spi off as I use bcm2835 lib for spi

3. INSTALL I2C-TOOLS
sudo apt-get install i2c-tools

4. CHECK ATTACHED I2C DEVICES ON BUS
This command reads each address and should only take 1 sec:
sudo i2cdetect -y 1

This shows a DAC device at 62 and the RTC device at 68. If UU is shown at an address it means probing was skipped because there is a (kernel) driver associated with that address.

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

If it takes longer than 1sec to probe the above the I2C bus could be held down, the I2C i/o has been changed to general GPIO or the driver has been corrupted somehow.

RTC DRIVER INSTALLATION
1. Use the I2C tools to check that the required I2C module has been detected and the RTC should appear at address 0x68 (UU).

2. Add the RTC module to the config.txt file
sudo nano /boot/config.txt

At the end of the file add this line then save:
dtoverlay=i2c-rtc,ds3231 # needed for RPI to access RTC (or ds1307, pcf2127 as per chipset)

3. Edit the /lib/udev/hwclock-set file
sudo nano /lib/udev/hwclock-set

Comment out the following 3 lines using #
# if [ -e /run/systemd/system ] ; then
# exit 0
# fi

Comment out the following 2 lines using # or remove any with --systz
#/sbin/hwclock --rtc=$dev --systz --badyear
...
#/sbin/hwclock --rtc=$dev --systz

Save.

4. Disable the 'fake hwclock' which can interfere with the 'real' hwclock
sudo apt-get remove fake-hwclock
sudo rm /etc/cron.hourly/fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo rm /etc/init.d/fake-hwclock
sudo update-rc.d hwclock.sh enable << some do not mention this line

5. Reboot to bring in the changes
sudo reboot

===
Q: are there any errors in the above setup for Jessie?

Apparently, this long standing I2C issue has been talked about and comments bounced around often, but I have not seen any specific fix being offered by anyone who has actually experienced the fault, pinned the issue down and found a proper workaround. I wish I knew where the hang up occurs in the (kernel/driver) software and if there was a method to clear it without requiring a reboot. Or if there was some method of 'flushing' out current I2C operations. If there is someone who could assist and would like to visit/see/analyze the setup I use please let me know.
Thanks
Steve

User avatar
SlowBro
Posts: 169
Joined: Sat Feb 18, 2017 1:30 am

Re: Chronodot with rtc-ds1307 Read Error

Mon Nov 19, 2018 6:12 am

I'm responding to this old thread because this is the first hit on Google for this error. I had the same issue so I want to leave what I found for posterity's sake.

The solution for me was to reinstall the OS. Something got corrupted. I reinstalled on a separate SD card and now hwclock -s shows no error messages. I can boot to the old installation on the other SD card and it's still broken.

I knew it wasn't a hardware failure because I tried two different RPi Zero Ws, four different RTCs including one brand new from the package and one from a different maker than the other three. (All DS3231.)

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