Driver for NXP PCF8523 (used by Raspy-Juice) ex 3.8 roadmap?

Ask questions about Arch Linux ARM. Please search before making a new topic.

Re: 3.8 roadmap?

Postby catmaker » Tue Feb 05, 2013 8:09 am

$this->bbcode_second_pass_quote('pepedog', 'I') rebuilt again, I need to know if not built into kernel is ok, ie a regular module
http://myplugbox.com/linux-raspberrypi-withPCF8523.tar.gz
It has 0001 and 0002 patches

I tried the above second rebuild of yours and the kernel boots up OK, but the hctosys.c fails to set the system time in the kernel boot up phase.
$this->bbcode_second_pass_code('', '
root@hagar:~# reboot
øø[22627.549955] Restarting system.
øàøø
Arch Linux 3.6.11-5-ARCH+ (ttyAMA0)

hagar login: root
øPassword:
Last login: Thu Jan 1 07:30:19 SGT 1970 on ttyAMA0
Last login: Tue Feb 5 15:22:09 on ttyAMA0
root@hagar:~# uname -a
Linux hagar 3.6.11-5-ARCH+ #1 PREEMPT Mon Feb 4 15:30:57 CST 2013 armv6l GNU/Linux
root@hagar:~# dmesg | grep -i rtc
[ 2.318229] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
root@hagar:~#
')
I also tried module loading with
$this->bbcode_second_pass_code('', '
root@hagar:~# cat /etc/modules-load.d/raspberry-i2c.conf
# Load i2c stuff and peripherals at boot.

i2c_bcm2708
i2c_dev
rtc_pcf8523
root@hagar:~#
')
and the relevant dmesg after rebooting gives
$this->bbcode_second_pass_code('', '
root@hagar:~# dmesg | grep rtc
[ 2.318079] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[ 3.848388] systemd-modules-load[57]: Inserted module 'rtc_pcf8523'
root@hagar:~#
root@hagar:~# ls /dev/rtc*
ls: cannot access /dev/rtc*: No such file or directory
root@hagar:~# !echo
echo pcf8523 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
root@hagar:~# ls /dev/rtc*
/dev/rtc0
root@hagar:~#
')
The rtc-pcf8523 driver module was inserted after hctosys.c wanted to set the system time. Even after the module was inserted, i2c-dev failed to register the device on the /dev directory. I had to manually perform a 'new_device' on the bus to do that..

I guess for more10's request of hctosys.c (kernel boot phase of setting system time) to work, all the below stuff has to be compiled as kernel built-in's: i2c-bcm2708, i2c-dev, hctosys.c, rtc-pcf8523 and the device-tree registration patch during board initialisation.

But, I can also understand why we'd need to keep chip drivers as modules instead of built-ins. It's probably for bloat reduction?

Anyway, thanks for the patches insertion. :D
catmaker
 
Posts: 8
Joined: Fri Jan 18, 2013 3:19 am

Re: 3.8 roadmap?

Postby pepedog » Tue Feb 05, 2013 10:03 am

I got queries on hctosys.c messages from users without rtc hardware, 2 more appeared with pcf8523 builtin
I think this will enable on boot for systemd, can you test please
$this->bbcode_second_pass_code('', 'echo "w /sys/class/i2c-adapter/i2c-0/new_device - - - - pcf8523 0x68" > /etc/tmpfiles.d/pcf8523.conf
echo "# Load i2c stuff and peripherals at boot." > /etc/modules-load.d/raspberry-i2c.conf
echo "i2c_bcm2708" >> /etc/modules-load.d/raspberry-i2c.conf
echo "i2c_dev" >> /etc/modules-load.d/raspberry-i2c.conf
echo "rtc_pcf8523" >> /etc/modules-load.d/raspberry-i2c.conf')
Although I get and error with
$this->bbcode_second_pass_code('', '# echo "pcf8523 0x68" > /sys/class/i2c-adapter/i2c-0/new_device
-bash: echo: write error: Invalid argument')
and dmesg
$this->bbcode_second_pass_code('', '[ 65.554419] i2c i2c-0: Failed to register i2c client pcf8523 at 0x68 (-16)
[ 79.227528] i2c i2c-0: Failed to register i2c client pcf8523 at 0x68 (-16)')
Is that because of lack of hardware?

The kernel is in the repo as you last tested, if on pi with that tarball kernel you will have to-
$this->bbcode_second_pass_code('', 'rm -r /usr/lib/modules/3.6.11-5-ARCH+/extramodules/
pacman -Sf linux-raspberrypi')
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: 3.8 roadmap?

Postby more10 » Tue Feb 05, 2013 10:07 am

Thanks pepedog for your effort. This kind of accomodation is far beyond what I had expected. I am so impressed with the alarm distribution.

If you can compile the driver into the kernel I would be very grateful. If not I will have to do a systemd service to set the RTC up. This is why I proposed using mkinitcpio, the module could be loaded early.

The raspberry is not connected to the internet, there is no NTP. I need the RTC for dating log files so that I can delete old log files with a cron job. If any log file is dated 1970 it will be deleted by my cron job.

PS. Changing the title of the thread so that it better describes the content. DS.
more10
 
Posts: 19
Joined: Mon Sep 10, 2012 10:03 am

Re: Driver for NXP PCF8523 (used by Raspy-Juice) ex 3.8 road

Postby catmaker » Wed Feb 06, 2013 7:01 am

Hi pepedog,

After removing the tar-balled kernel, I've pacman upgraded with the distribution's kernel, and included the /etc/modules-load.d/raspberry-i2c.conf stuff. I have tested the Raspberry Pi Rev.1 without the Raspy Juice (and its PCF8523 RTC) and I get the same error results you observed.

$this->bbcode_second_pass_code('', '
reporoot@hagar:~# dmesg | grep 'i2c\|rtc'
[ 2.318292] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[ 3.632550] bcm2708_i2c bcm2708_i2c.0: BSC0 Controller at 0x20205000 (irq 79) (baudrate 100k)
[ 3.694028] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100k)
[ 3.735314] i2c /dev entries driver
[ 3.781900] systemd-modules-load[57]: Inserted module 'rtc_pcf8523'
[ 6.054938] rtc-pcf8523: probe of 0-0068 failed with error -5
[ 6.054993] i2c i2c-0: new_device: Instantiated device pcf8523 at 0x68
root@hagar:~# echo "pcf8523 0x68" > /sys/class/i2c-adapter/i2c-0/new_device
-bash: echo: write error: Invalid argument
root@hagar:~# echo "pcf8523 0x68" > /sys/class/i2c-adapter/i2c-1/new_device
root@hagar:~# dmesg | grep 'i2c\|rtc'
[ 2.318292] drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[ 3.632550] bcm2708_i2c bcm2708_i2c.0: BSC0 Controller at 0x20205000 (irq 79) (baudrate 100k)
[ 3.694028] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100k)
[ 3.735314] i2c /dev entries driver
[ 3.781900] systemd-modules-load[57]: Inserted module 'rtc_pcf8523'
[ 6.054938] rtc-pcf8523: probe of 0-0068 failed with error -5
[ 6.054993] i2c i2c-0: new_device: Instantiated device pcf8523 at 0x68
[ 142.668040] i2c i2c-0: Failed to register i2c client pcf8523 at 0x68 (-16)
[ 146.654099] rtc-pcf8523: probe of 1-0068 failed with error -5
[ 146.654153] i2c i2c-1: new_device: Instantiated device pcf8523 at 0x68
root@hagar:~#
')

Yes, it is caused by the lack of the RTC chip during the probe. In the above log, I also tried to 'new_device' on the other i2c bus, again without the RTC HW, and then dmesg complained of the second module's probe failure. I think this confirms your message observations of missing RTC HW during module loads.

PS: @more10, for my alarmpi units, I think I will try your suggestion of using a systemd call to set the sytem time in userspace.
catmaker
 
Posts: 8
Joined: Fri Jan 18, 2013 3:19 am

Re: Driver for NXP PCF8523 (used by Raspy-Juice) ex 3.8 road

Postby more10 » Wed Feb 06, 2013 12:06 pm

My RTC is now up and running!

The boot warning about rtc is always displayed, so compiling the driver into the kernel will not make it any worse I believe. But if including in the kernel, other rtc solutions must also be supported.

$this->bbcode_second_pass_code('', 'jan 01 01:00:03 alarmpi kernel: drivers/rtc/hctosys.c: unable to open rtc device (rtc0)')
more10
 
Posts: 19
Joined: Mon Sep 10, 2012 10:03 am

Re: Driver for NXP PCF8523 (used by Raspy-Juice) ex 3.8 road

Postby pepedog » Wed Feb 06, 2013 1:19 pm

more10,
I look at your date (obviously from everything.log) and see jan 01 01:00:03
I got a fakeclock which examines everything.log, if latest entries are not 1970 then clock is set to that. Then syslog-ng comes up, writes dmesg to it (not with 1970 date). No 1970 dates will be in it at all
Not a package btw http://myplugbox.com/fakeclock.tar.xz
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: Driver for NXP PCF8523 (used by Raspy-Juice) ex 3.8 road

Postby more10 » Wed Feb 06, 2013 1:54 pm

$this->bbcode_second_pass_quote('', ' ')(obviously from everything.log)


No, from:
$this->bbcode_second_pass_code('', '[root@alarmpi ~]# journalctl -b')
more10
 
Posts: 19
Joined: Mon Sep 10, 2012 10:03 am

NXP PCF8523 RTC systemd service file

Postby more10 » Wed Feb 06, 2013 2:02 pm

My systemd.service file:

$this->bbcode_second_pass_code('', '
[root@alarmpi ~]# cd /etc/systemd/system
[root@alarmpi system]# cat hwclock.service
[Unit]
Description=Raspy-Juice rtc control

[Service]
Type=oneshot
ExecStart=/sbin/hwclock -s
Requires=systemd-timedated.service
After=systemd-timedated.service

[Install]
WantedBy=basic.target

[root@alarmpi system]#
')

Im not too shure about the basic.target, maybe it is possible to start it even earlier, but systemd documentation is a bit lacking :-)

After reboot:

$this->bbcode_second_pass_code('', '[root@alarmpi ~]# journalctl -b | grep rtc
jan 01 01:00:03 alarmpi kernel: drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
jan 01 01:00:03 alarmpi systemd-modules-load[48]: Module 'rtc_pcf8523' is builtin
jan 01 01:00:05 alarmpi kernel: rtc-pcf8523 0-0068: chip found, driver version 1.0
jan 01 01:00:05 alarmpi kernel: rtc-pcf8523 0-0068: rtc core: registered rtc-pcf8523 as rtc0
jan 01 01:00:05 alarmpi systemd[1]: Starting Raspy-Juice rtc control...
feb 06 13:49:35 alarmpi systemd[1]: Started Raspy-Juice rtc control.
')

It seems to work!
more10
 
Posts: 19
Joined: Mon Sep 10, 2012 10:03 am

Re: NXP PCF8523 RTC systemd service file

Postby catmaker » Thu Feb 07, 2013 9:02 am

Hi pepedog,

$this->bbcode_second_pass_quote('more10', '
')My systemd.service file:
...
After reboot:
...
It seems to work!

I've tested more10's approach and it works for me too! But, it doesn't work on a Raspberry Pi Rev.2 where the GPIO i2c is bus number 1, instead of 0.

I used to have these lines on my debian /etc/rc.local where the script would detect which bus the PCF8523 was on, and instantiate the driver there:
$this->bbcode_second_pass_code('', '
# Adding real time clock chip device to /dev
if ( /usr/sbin/i2cdetect -y 0 | grep -q 68 ) ; then
echo pcf8523 0x68 > /sys/class/i2c-adapter/i2c-0/new_device
fi

if ( /usr/sbin/i2cdetect -y 1 | grep -q 68 ) ; then
echo pcf8523 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
fi
')
I don't feel it's the right way, but I put both adapter buses into /etc/tmpfiles.d/pcf8523.conf
$this->bbcode_second_pass_code('', '
w /sys/class/i2c-adapter/i2c-0/new_device - - - - pcf8523 0x68
w /sys/class/i2c-adapter/i2c-1/new_device - - - - pcf8523 0x68
')
and it seems to work for both Raspberry Pi Rev.1 and Rev.2.

Is there a way to make the above statements conditional?
catmaker
 
Posts: 8
Joined: Fri Jan 18, 2013 3:19 am
Top

Re: Driver for NXP PCF8523 (used by Raspy-Juice) ex 3.8 road

Postby pepedog » Sun Feb 10, 2013 9:51 pm

I am about to follow this
https://github.com/raspberrypi/linux/commit/f7aef7a72c32631b8300af33c44ba3a3421b3c0c
According to their note-
$this->bbcode_second_pass_quote('', 'R')emove RTC_HCTOSYS as it produces a kernel boot error, and doesn't do anything with RTC kernel modules

Hope this is ok

Edit, I don't think I will do this now
< CONFIG_RTC_DRV_PCF8583=m
(amongst many removed)
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK
Top

PreviousNext

Return to User Questions

Who is online

Users browsing this forum: No registered users and 35 guests