10

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

Eran
  • 387,369
  • 54
  • 702
  • 768
henryyao
  • 1,758
  • 6
  • 23
  • 37

2 Answers2

12

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.

microMolvi
  • 636
  • 11
  • 30
  • hmm.. can u give us the output of `ls /sys/bus/i2c/devices` – microMolvi Jul 24 '13 at 18:11
  • 1
    The ls command gives 3-0068(3 is the bus number), and some other devices. And btw, I can read from the RTC using ioctl() function from my C code. Which is weird since i2ctools cannot read. – henryyao Jul 24 '13 at 19:48
  • 1
    The cat command gives me i2c:ds1337 and then I run command 'rmmod ds1337' or 'rmmod -f ds1337', but it gives out: cannot unload 'ds1337', unknown symbol in module, or unknown parameter. – henryyao Jul 25 '13 at 13:00
  • okay.. ds1337 might be an alias for a module. Try `grep ds1337 /lib/modules/\`uname -r\`/modules.alias` – microMolvi Jul 25 '13 at 13:13
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34159/discussion-between-micromolvi-and-henryyao) – microMolvi Jul 25 '13 at 13:16
0

0x68 is being used by some driver, Disable that driver in kernel source code and recompile source code.

Bahubali
  • 13
  • 2