I had another look at the error messages from my attempt to use Portage to build LIRC 0.8.6 with patched source code to work with the 2.6.33 kernel (see my first post of March 26), and noticed that kfifo is mentioned. Now, the purpose of the patch lirc-LP529514.patch that I mentioned in an earlier post is specifically to fix a problem with kfifo introduced by the 2.6.33 kernel. So I began to wonder whether I had patched correctly the lirc-0.8.6 source code. So I had another go today:
1. I did a 'make uninstall' and a 'make clean' in /usr/src/lirc-0.8.6/ and in /usr/src/lirc_wb677/ directories, and then deleted the /usr/src/lirc-0.8.6/ directory.
2. I applied the lirc-LP529514.patch and the autoconf.patch to the LIRC 0.8.6 source code, and copied the resulting source code to a newly-created /usr/src/lirc-0.8.6/ directory.
3. I don't know if it is necessary, but I followed a note from 2005 in the Gentoo Wiki article on LIRC, and did the following:
- Code: Select all
# cp /usr/src/lirc-0.8.6/contrib/lirc.rules /etc/udev/rules.d
# cat /etc/udev/rules.d/lirc.rules
KERNEL=="lirc[0-9]*", NAME="lirc/%n"
#
4. I created a tarball lirc-0.8.6.tar.bz2 of the patched LIRC 0.8.6 source code, and copied it to the /usr/portage/distfiles/ directory.
5. I edited /etc/make.conf and changed LIRC_DEVICES="all" to LIRC_DEVICES="wpc8769l" because of Gentoo Bugzilla Bug Report No. 296739 (yet
another LIRC bug report!), as the error message mentioned in that bug report was displayed when I used LIRC_DEVICES="all" in a previous build attempt, even though I was not using the gentoo-sources-2.6.32 mentioned in the bug report. (I just chose the device wpc8769l as a 'dummy', since my IR receiver does not use that chip.)
6. cd /usr/portage/app-misc/lirc/
7. ebuild --force lirc-0.8.6-r2.ebuild manifest
8. emerge -1v lirc
9. I checked that the wpc8769l module I had built LIRC with was correctly listed in the dependency file for modules:
- Code: Select all
# cat /lib/modules/2.6.33-sabayon/modules.dep | grep lirc
misc/lirc_dev.ko:
misc/lirc_wpc8769l.ko: misc/lirc_dev.ko
10. I copied the LIRC configuration files /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 and usr/share/lirc_lirc_wb677/lircrc_nuvoton from the Ubuntu lirc_wb677-1.0.4 tarball to /etc/lirc/lircd.conf and /etc/lirc/lircrc respectively. I don't have the file /etc/lirc/lircmd.conf though, which perhaps I may need to create for mouse emulation.
11. I built the module for my IR receiver:
a) I first edited the Makefile /usr/src/lirc_wb677-1.0.4/Makefile that I extracted from the Ubuntu tarball so that it looks like this:
- Code: Select all
#!/bin/bash
LIRC_DIR := /usr/src/lirc-0.8.6
obj-m += lirc_wb677.o
lirc_wb677-objs := lirc_wb677_main.o lirc_wb677_mouse_kbd.o
KSRC ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
echo KERNELDIR=$(KSRC)
$(MAKE) -C $(KSRC) -I $(LIRC_DIR) M=$(PWD) modules
install:
# Following line edited but then commented out because it stops script if lircd not already running:
# /etc/init.d/lircd stop
rmmod lirc_wb677 || echo "lirc_wb677.ko is not executing"
file="lirc_wb677.ko"; \
dir="/lib/modules/$(shell uname -r)/misc"; \
if test -d "$$dir"; then echo ""; else mkdir -p $$dir; fi; \
cp -vf *.ko $$dir
depmod -a
# Following line edited but then commented out because /usr/share/lirc/lirc.hwdb does not exist on my PC:
# patch -p0 /usr/share/lirc/lirc.hwdb < /usr/src/lirc_wb677-1.0.4/lirc_nct667x-lirc0.8.6.patch
@echo ""
@echo "Hint: You can configure lirc."
@echo " And start lirc by executing \"/etc/init.d/lircd start\""
uninstall:
# Following line edited but then commented out because it stops script if lircd not already running:
# /etc/init.d/lircd stop
( rmmod lirc_wb677 ) || echo "lirc_wb677.ko is not executing"
dir="/lib/modules/$(shell uname -r)/misc"; \
if test -d "$$dir"; then rm -R $$dir; fi;
depmod -a
# Following line edited but then commented out because /usr/share/lirc/lirc.hwdb does not exist on my PC:
# patch -R -p0 /usr/share/lirc/lirc.hwdb < /usr/src/lirc_wb677-1.0.4/lirc_nct667x-lirc0.8.6.patch
clean:
rm -rf *.o *.ko *.mod.c Module.symvers .tmp_versions .*.cmd
b) Then I compiled and installed the module file:
- Code: Select all
# cd /usr/src/lirc_wb677-1.0.4/
# make
echo KERNELDIR=/lib/modules/2.6.33-sabayon/build
KERNELDIR=/lib/modules/2.6.33-sabayon/build
make -C /lib/modules/2.6.33-sabayon/build -I /usr/src/lirc-0.8.6 M=/usr/src/lirc_wb677-1.0.4 modules
make[1]: Entering directory `/usr/src/linux-2.6.33-sabayon'
CC [M] /usr/src/lirc_wb677-1.0.4/lirc_wb677_main.o
In file included from /usr/src/linux-2.6.33-sabayon/arch/x86/include/asm/uaccess.h:571,
from include/linux/poll.h:13,
from /usr/src/lirc_wb677-1.0.4/lirc_wb677.h:25,
from /usr/src/lirc_wb677-1.0.4/lirc_wb677_main.c:2:
In function ‘copy_from_user’,
inlined from ‘lirc_write’ at /usr/src/lirc_wb677-1.0.4/lirc_wb677_main.c:674:
/usr/src/linux-2.6.33-sabayon/arch/x86/include/asm/uaccess_32.h:212: warning: call to ‘copy_from_user_overflow’ declared with attribute warning: copy_from_user() buffer size is not provably correct
CC [M] /usr/src/lirc_wb677-1.0.4/lirc_wb677_mouse_kbd.o
LD [M] /usr/src/lirc_wb677-1.0.4/lirc_wb677.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "lirc_register_driver" [/usr/src/lirc_wb677-1.0.4/lirc_wb677.ko] undefined!
WARNING: "lirc_unregister_driver" [/usr/src/lirc_wb677-1.0.4/lirc_wb677.ko] undefined!
CC /usr/src/lirc_wb677-1.0.4/lirc_wb677.mod.o
LD [M] /usr/src/lirc_wb677-1.0.4/lirc_wb677.ko
make[1]: Leaving directory `/usr/src/linux-2.6.33-sabayon'
# make install
rmmod lirc_wb677 || echo "lirc_wb677.ko is not executing"
ERROR: Module lirc_wb677 does not exist in /proc/modules
lirc_wb677.ko is not executing
file="lirc_wb677.ko"; \
dir="/lib/modules/2.6.33-sabayon/misc"; \
if test -d "$dir"; then echo ""; else mkdir -p $dir; fi; \
cp -vf *.ko $dir
`lirc_wb677.ko' -> `/lib/modules/2.6.33-sabayon/misc/lirc_wb677.ko'
depmod -a
Hint: You can configure lirc.
And start lirc by executing "/etc/init.d/lircd start"
12. I inserted the module by force when it would not insert normally:
- Code: Select all
# modprobe lirc_wb677
FATAL: Error inserting lirc_wb677 (/lib/modules/2.6.33-sabayon/misc/lirc_wb677.ko): Unknown symbol in module, or unknown parameter (see dmesg)
# modprobe -f lirc_wb677
# lsmod | grep lirc
lirc_wb677 22499 0
lirc_dev 6837 1 lirc_wb677
#
13. I tried to run the LIRC daemon:
- Code: Select all
# /etc/init.d/lircd start
* Caching service dependencies... [ ok ]
* Starting lircd... [ ok ]
# rc-status update
* runlevel `update' does not exist
# rc-status | grep lircd
lircd [ started ]
Eureka, it runs!
14. I checked the contents of the /var/run/lirc/ and /dev/ directories:
- Code: Select all
# ls -la /var/run/lirc/*
srw-rw-rw- 1 root root 0 Mar 28 05:45 /var/run/lirc/lircd
-rw-r--r-- 1 root root 6 Mar 28 05:45 /var/run/lirc/lircd.pid
prw-r--r-- 1 root root 0 Mar 28 03:14 /var/run/lirc/lircm
# ls -la /dev/lirc*
lrwxrwxrwx 1 root root 19 Mar 28 05:45 /dev/lircd -> /var/run/lirc/lircd
/dev/lirc:
total 0
drwxr-xr-x 2 root root 60 Mar 28 05:45 .
drwxr-xr-x 21 root root 14680 Mar 28 05:45 ..
crw-rw---- 1 root root 61, 0 Mar 28 05:45 0
#
At long last the socket file and PID file are there as they should be.
15. I issued the following command and pressed some keys on the Remote Controller:
- Code: Select all
# cat /dev/lirc/0
and a string of characters (garbage) appeared in the Konsole whenever I pressed a key. Finally the IR receiver is doing something, and with the 2.6.33 kernel too.

I think I now need to work out the correct key mapping to go in /etc/lirc/lircmd.conf and the XBMC keymap file, and perhaps I will be able to get the remote controller to actually control XBMC. My only worry is why I had to force the module lirc_wb677 to load, but hopefully that is only because of missing kernel version information in the module (remembering the two messages for lirc_wb677 in dmesg: "no symbol version for lirc_unregister_driver" and "Unknown symbol lirc_unregister_driver").
Anyway, after burning the candle at both ends for several days, I feel rather pleased to have got some sort of a result. Mind you, the IR receiver works out of the box with Windows 7! Linux, eh?!