Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does the i2cdetect always gives UU on my RTC in embedded Linux

I'd like to communicate read from my RTC in C code rather than the "hwclock" shell command.

However, when I use i2cdetect, it shows 0x68(which is my RTC slave address) is having the status "UU", which means "Probing was skipped, because this address is currently in use by a driver". And after I tried the i2cget, its givng "could bot set address to 0x68: Device or resource busy".

So I'm thinking if there are some problem in my Linux kernel that will force to read from my RTC all the time, or some other reason.

Thanks

like image 316
henryyao Avatar asked Jul 23 '13 21:07

henryyao


1 Answers

I am assuming that you are using DS-1307 RTC, or one of its variants (because of 0x68 slave address). Check if its driver is loaded by:

$ lsmod | grep rtc

If you seen an entry of rtc_ds1307, (like this -> rtc_ds1307 17394 0 ) in the output of above command then this driver might be in hold of that address.

If the driver is loaded in system then unload it using

$ rmmod rtc-ds1307

EDIT:

(In light of OP's feedback,) Please do the following

1) cat /sys/bus/i2c/devices/3-0068/modalias. This will give you the name of the kernel driver that is keeping this device busy. Copy the driver-name after the colon(:) OP's output of the command tells us that its ds1337

2) Check if ds1337 is an alias for a driver, using

grep ds1337 /lib/modules/`uname -r`/modules.alias

Hopefully you will get the following output

alias i2c:ds1337 rtc_ds1307

This confirms our presumption that rtc_ds1307 is infact the driver in hold of the I2C address 0x68.

3) use rmmod rtc_ds1307 to unload the driver. Note: This will only work if the driver is a Loadable Kernel Module, otherwise you will see the following error:

ERROR: Module rtc_ds1307 does not exist in /proc/modules

In that case you will have to recompile the kernel again with that driver disabled/modularized.

like image 158
microMolvi Avatar answered Oct 03 '22 02:10

microMolvi