User avatar
psergiu
Posts: 224
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Kernel panic w/ PCF8563 I2C RTC & bootc kernel

Wed May 30, 2012 4:35 pm

Hi everyone,

I built myself a Olimex MOD-RTC clone with the PCF8563 chip using the schematics from their page:
http://www.olimex.com/dev/mod-rtc.html
(i even included the 330ohm resistors on the SDA & SCL lines, the RTC board works ok when connected to a DuinoMite)

I'm using the "official" debian image with bootc's 3.2.18 kernel with I2C & SPI:
http://www.bootc.net/archives/2012/05/2 ... pi-kernel/

When i connect it to the RPi it is detected correctly but when i try to add the device i get a kernel panic.

Here's the output on the serial console:

Code: Select all

root@raspberrypi:~# modprobe i2c-dev
root@raspberrypi:~# modprobe rtc-pcf8563
root@raspberrypi:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
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: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

root@raspberrypi:~# echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-0/new_device
[  507.916192] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: bf149320
[  507.916204]
[  507.934266] [<c0011cd4>] (unwind_backtrace+0x0/0xe0) from [<c02eea24>] (panic+0x68/0x1a4)
[  507.948041] [<c02eea24>] (panic+0x68/0x1a4) from [<c0024bb4>] (__stack_chk_fail+0x10/0x14)
[  507.962121] [<c0024bb4>] (__stack_chk_fail+0x10/0x14) from [<bf149320>] (pcf8563_rtc_read_time+0x18c/0x1a8 [rtc_pcf8563]
)
[  507.979166] [<bf149320>] (pcf8563_rtc_read_time+0x18c/0x1a8 [rtc_pcf8563]) from [<c020e0d8>] (__rtc_read_time+0x48/0x54)
[  507.996395] [<c020e0d8>] (__rtc_read_time+0x48/0x54) from [<c020ea50>] (rtc_read_time+0x2c/0x40)
[  508.011733] [<c020ea50>] (rtc_read_time+0x2c/0x40) from [<c020eb60>] (__rtc_read_alarm+0x18/0x26c)
[  508.027461] [<c020eb60>] (__rtc_read_alarm+0x18/0x26c) from [<c020dc44>] (rtc_device_register+0x110/0x22c)
[  508.044207] [<c020dc44>] (rtc_device_register+0x110/0x22c) from [<bf1493b4>] (pcf8563_probe+0x78/0xb4 [rtc_pcf8563])
[  508.062091] [<bf1493b4>] (pcf8563_probe+0x78/0xb4 [rtc_pcf8563]) from [<bf03e44c>] (i2c_device_probe+0xac/0xd8 [i2c_core
])
[  508.080794] [<bf03e44c>] (i2c_device_probe+0xac/0xd8 [i2c_core]) from [<c01e5528>] (driver_probe_device+0xc8/0x184)
[  508.099144] [<c01e5528>] (driver_probe_device+0xc8/0x184) from [<c01e453c>] (bus_for_each_drv+0x4c/0x84)
[  508.116833] [<c01e453c>] (bus_for_each_drv+0x4c/0x84) from [<c01e5418>] (device_attach+0x74/0xa0)
[  508.134111] [<c01e5418>] (device_attach+0x74/0xa0) from [<c01e4d04>] (bus_probe_device+0x24/0x44)
[  508.151457] [<c01e4d04>] (bus_probe_device+0x24/0x44) from [<c01e3524>] (device_add+0x3b0/0x548)
[  508.168846] [<c01e3524>] (device_add+0x3b0/0x548) from [<bf03eb28>] (i2c_new_device+0x100/0x164 [i2c_core])
[  508.187235] [<bf03eb28>] (i2c_new_device+0x100/0x164 [i2c_core]) from [<bf03ec4c>] (i2c_sysfs_new_device+0xc0/0x160 [i2c
_core])
[  508.207410] [<bf03ec4c>] (i2c_sysfs_new_device+0xc0/0x160 [i2c_core]) from [<c01e20fc>] (dev_attr_store+0x18/0x24)
[  508.226396] [<c01e20fc>] (dev_attr_store+0x18/0x24) from [<c0120774>] (sysfs_write_file+0x108/0x140)
[  508.244132] [<c0120774>] (sysfs_write_file+0x108/0x140) from [<c00c4cac>] (vfs_write+0xb0/0x178)
[  508.261484] [<c00c4cac>] (vfs_write+0xb0/0x178) from [<c00c4f8c>] (sys_write+0x3c/0x68)
[  508.278034] [<c00c4f8c>] (sys_write+0x3c/0x68) from [<c000d160>] (ret_fast_syscall+0x0/0x30)
Help please ? :)
Thanks.

bootc
Posts: 19
Joined: Mon May 28, 2012 7:45 pm

Re: Kernel panic w/ PCF8563 I2C RTC & bootc kernel

Thu May 31, 2012 9:09 am

Ah, I can see a potential problem in my code that might cause this. Let me get a patch pushed out that should hopefully fix it.

bootc
Posts: 19
Joined: Mon May 28, 2012 7:45 pm

Re: Kernel panic w/ PCF8563 I2C RTC & bootc kernel

Thu May 31, 2012 11:23 am

Can you please give this new kernel a try and see if you still get the error?

http://www.bootc.net/raspberrypi/linux- ... _armel.deb

HTH,
Chris

User avatar
psergiu
Posts: 224
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: Kernel panic w/ PCF8563 I2C RTC & bootc kernel

Thu May 31, 2012 1:30 pm

Oh yes, it works ! Thanks a lot.

Code: Select all

root@raspberrypi:~# echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-0/new_device
root@raspberrypi:~# dmesg | tail -5
[   52.712747] i2c /dev entries driver
[   73.359291] rtc-pcf8563 0-0051: chip found, driver version 0.4.3
[   73.360958] rtc-pcf8563 0-0051: low voltage detected, date/time is not reliable.
[   73.361528] rtc-pcf8563 0-0051: rtc core: registered rtc-pcf8563 as rtc0
[   73.361576] i2c i2c-0: new_device: Instantiated device pcf8563 at 0x51
root@raspberrypi:~# hwclock
Sun 10 Aug 1980 21:02:32 EEST  -0.190252 seconds
root@raspberrypi:~# hwclock --systohc
root@raspberrypi:~# hwclock
Thu 31 May 2012 16:14:54 EEST  -0.079515 seconds
And after plugging in a CR2032 battery and powering off then on with network cable removed:

Code: Select all

Date and Time are unknown - using 2012-05-31 16:18 as an approximation
Correct the date and time using e.g: sudo date --set="2012-05-31 16:18"
root@raspberrypi:~# date
Thu May 31 16:18:06 EEST 2012
root@raspberrypi:~# modprobe i2c-dev
root@raspberrypi:~# modprobe rtc-pcf8563
root@raspberrypi:~# echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-0/new_device
root@raspberrypi:~# hwclock
Thu 31 May 2012 16:23:10 EEST  -0.303895 seconds
root@raspberrypi:~# hwclock --hctosys
root@raspberrypi:~# date
Thu May 31 16:23:50 EEST 2012
root@raspberrypi:~# hwclock
Thu 31 May 2012 16:23:55 EEST  -0.964459 seconds

bootc
Posts: 19
Joined: Mon May 28, 2012 7:45 pm

Re: Kernel panic w/ PCF8563 I2C RTC & bootc kernel

Thu May 31, 2012 8:41 pm

Good news! Thanks for pointing out the bug :-)

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