External RTC not working on apalis evaluation board

I follow this article How to use the Real Time Clock in Linux but after cold reboot, the RTC time will be set to 1970. I put the jumber J22 to 2-3 position to chose external rtc.

The debug information:

root@apalis-imx6:~# dmesg | grep -i rtc
[    1.774345] rtc-ds1307: probe of 1-0068 failed with error -5
[    1.775003] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc0
[    3.344887] snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:01 UTC (1)
root@apalis-imx6:~# i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

Thanks for your help.

Hi @Hieu

Welcome to the Toradex Community!!!

Which carrier board are you using?

He uses an apalis evaluation board. We seem actually to have the same issue on the colibri evaluation board. Jumper J23 set to 2-3.

[    1.408695] rtc-ds1307: probe of 3-0068 failed with error -5
[    1.417250] snvs_rtc 30370000.snvs:snvs-rtc-lp: rtc core: registered 30370000.snvs:snvs- as rtc0
[    2.540313] snvs_rtc 30370000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:01 UTC (1)

Additionally I also scanned the i2cdetect -y -r 3 bus, but only discovered our device. So bus is working. There was no sign of the ominous slave with address 0xD0 (according datasheet https://www.st.com/resource/en/datasheet/m41t0.pdf ), which is probably meant to be 0x50 (UPDATE: if shifting correctly this gives 0x68) and was already shifted. Then again the linux puts it into the ds1307 family assuming a 0x68 slave address as it seems. That would be consistent with the probe message.

So, I strongly suspect that the external rtc isn’t even running and I don’t know which slave address it really has, but that should be easy to find out with probing.

hi @Hieu

Have you done any changes to the image (device tree or kernel)? Are the jumpers (X9AM or X9AN) for the i2c connection to the RTC set or not?

I tested it on my side with the same setup as you and RTC is working.

root@apalis-imx6:~# dmesg | grep -i rtc
[    1.908995] rtc-ds1307 1-0068: rtc core: registered m41t0 as rtc0
[    1.920678] snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc1
[    3.133335] rtc-ds1307 1-0068: setting system clock to 2018-07-19 15:20:36 UTC (1532013636)

@andriscewo: Could you ask a separate question, please?

It’s fine, found my error. I hadn’t connected a the i2c data line jumper on the evaluation board and used the wrong address on our own hardware

Hi @jaski.tx
Thank you very much for your helps. That right, the cause is jumpers (A9AM and X9AN) is not connect. After i connect jumpers, every things work fine.

Perfect, that it works. Thanks for your feedback.