ubuntu-users Digest, Vol 7, Issue 367

Zach uid000 at gmail.com
Thu Mar 31 18:03:13 UTC 2005

Excuse the really long reply, but these are my notes for how I got
lirc working on Ubuntu for whoever can put them to good use.

I'll try to explain in greater detail the convoluted steps I went
through that ended up with LIRC working for me.  But
BIG-FAT-DISCLAIMER: I would hate for anyone to follow my steps because
the way I went about it was wrong in so many ways.  I was trying
everything and it ended up working.  Fortunately I took notes so I can
backtrack my steps, but that doesn't make it right or reliable. 
Anyway here goes.

I'm writing this as a narrative rather than a step by step
description, because it shouldn't be interpretted as a howto.
Also for those unfamiliar with lirc, it consists of two parts. (1)
userspace utilities (tools you actually interact with like irw) and
(2) kernel modules.  There are packages in one of the ubuntu
repositories (universe or multiverse) for the lirc userspace utilities
as well as lirc modules source code.

For the record, I'm using a hauppauge pvr 250, so I need to get the
lirc_i2c driver working.  However the process should be similar for
other supported hardware.
I originally installed Kubuntu (Ubuntu vs Kubuntu shouldn't make any
difference).  I did apt-get update && apt-get dist-upgrade to make
sure every thing was good to go. Then I installed the lirc and
lirc-modules-source packages.  Also installed all relevent
linux-headers packages (at the time for 686 kernel) as well as the
2.6.10 kernel source package.  I also installed some other packages
like build-essential, and kernel-package.  Can't remember what all. 
But a check with any debian/ubuntu kernel howto will reveal all the
required packages and more for building kernel modules.

I tried following the instructions in the lirc-modules-source package
that ended up with a binary package for the lirc kernel modules.  I
installed the custom package.  I read somewhere that it installs the
kernel modules under /lib/modules/2.6.10/misc (I think that's right)
and that misc should be moved to /lib/modules/`uname
-r`/kernel/drivers/misc, where`uname -r` gives your full kernel
version like 2.6.10-5, etc.  So I moved the modules up under the
apropriate directory (it didn't occur to me until much later that the
package had insalled *.o modules rather than *.ko which I think is
what 2.6 modules are).  Anyway I think I still had to manually create
/etc/modutils/lirc_i2c (remember lirc_i2c is the module for pvr 250
remote).  Can't remember.  Anyway it should contain something like
alias char major 61 lirc_i2c.
Then I ran depmod -a to update the kernel's modules dependencies file.
then I ran update-modules (you normally have to do this when making an
addition to the /etc/modutils/ directory).  Anyway, modprobe lirc_i2c
yielded no results.  And after messing around with some other stuff I
finally just removed the custom lirc modules package.

Giving up on the lirc-modules-source I downloaded the latest lirc
source package (not an actual deb, just tar/gzipped source) from the
lirc website.  Following the instructions in this packge, as well as
(skip to the part about lirc), I ran the setup script, setup.sh, in
the lirc source code directory that configures everything for
compiling.  I found out later that it requires dialog, so if not
installed, it's available in the apt respositories.  So following the
instructions I ran ./setup.sh, make, and make install.  Then I did
depmod -ae.  Also I checked to see where the kernels had been placed,
and they were under /lib/modules/lirc or something like that.  Anyway,
it didn't look wrong.  I removed the /etc/modutils/lirc_i2c that I had
created earlier.  Then, per the instructions, I edited
/etc/modutils/ivtv (already there from my earlier installation of ivtv
for pvr 250).  In addition to the line the walkthrough says to add, I
knew I needed the alias char major 61 lirc_i2c line.  If you don't
know about major/minor device numbers, etc.  Don't worry, I don't
really understand them fully myself, but they're usually well
documented for any given device module.  Then i ran update-modules,
and modprobe lirc_dev lirc_i2c.  lsmod | grep lirc_i2c revealed that
the module had indeed loaded!  Finally, success.  I downloaded a
lircd.conf for my specific remote (each remote needs it's own
lircd.conf) and put it into /etc/.  Jarod Wilson's mythtv guide at at
wilsonet.com has lots of info about lirc including where to get conf
files for some different remotes.  Anyway, I fired up irw, and pointed
my remote at the ir receiver and started mashing buttons.  I was
getting output to the screen!  Woohoo!  It works.  Time for bed.

The next day, I began to worry about a couple of things (1) i had been
running the wrong kernel for my machine, a k7, not 686, and (2) after
all the trial and error, would I be able to reproduce the results on a
clean setup?  I decided to to a clean install of (k)ubuntu.  I figured
just apt-getting a new kernel would be messy since kernel modules are
compiled against your specifc kernel, and besides lirc, I also had to
worry about the ivtv module as well. After reinstalling from scratch,
and updating all packages, gettin ivtv up and going, I started in on
lirc.  The lirc-modules-source route failing last time, I skipped it,
and just followed my notes for compiling lirc from source.  Except it
wouldn't make.  Lots of errors.  I have a little experience editing
makefiles and having to fix pathnames, etc. but these were lots of
errors.  Clearly make was looking for something it couldn't find in
the build enviroment.  I even symlinked /usr/src/linux-source-2.6.10/
to /usr/src/linux, since lots of programs look for your kernel source
to be under ./linux/ when compiling.  Lots of reading the various
READMEs/FAQs,etc that come with lirc, and lots of googling, searching
forums/mailing lists, turned up no definitive answers.  Compiling
software from source is highly environment sensitive, and results
under one distro vary greatly from another.  So I was looking
specifically for info on compiling lirc under ubuntu or debian. 
Compiling lirc under RH, or mandrake or anything else would not likely
be helpful.

It was at this point I realized I really needed to backtrack my steps
from the previous night, since clearly something I did then allowed
the build process to work.  So I installed the troublesome
lirc-modules-source package, and went through that song and dance.  Of
course it didn't work.  Maybe I'm just not smart enough to figure it
out, I don't know.  There are even specific instructions for debian
and I followed those as well.  After trying everything I could think
of I uninstalled the custom packages that had been generated, and
removed any copies of the kernel modules I had made (I tried placing
the modules in different locations under /lib/modules, to no avail).

Then just like the previous night i proceeded to build lirc from
source, and followed the process I mentioned above.  Now I started
getting some success, as they would make and make install.  I ran
depmod -ae I edited /etc/modutils/ivtv (again i don't think which file
you use/create actually matters), then ran update-modules.  I don't
know if the modules loaded or not.  I can't remember.  I think they
wouldn't.  Or maybe they would, but lircd (the lirc daemon) wouldn't
run.  Anyway, for some reason I thought to run dpkg-reconfigure lirc,
which takes you through a bunch of questions about what type of ir
controller you have, etc.  Then it offers to make appropriate device
nodes for you, and some other things.  When it got done, I remember
the kernel modules were loaded (lsmod | grep lirc), and lircd was
running (ps -ef | grep lircd).  After a reboot lircd wasn't running,
although the init scripts (/etc/init.d/; /etc/rcx.d/, etc) were set up
for it.  I attempted to manually start the init script for lirc.  It
wouldn't give an error message, but ps -ef | grep lirc showed not lirc
processes running.  So I ran dpkg-reconfigure lirc again, an
afterwards, everything was happy like before.  However, after a
reboot, lircd wouldn't run again.  Some poking and prodding led me to
take a close look at /etc/lirc/hardware.conf.  This file contains lots
of interesting things such as what device nodes to use, what kernel
modules to load & and whether to attempt to load them if theyre not
loaded.  It also had the path to some configuration files like
lircd.conf.  The first thing I noticed, is that the device file
hardware.conf was referencing wasn't available when I ran ls
/dev/lirc*.  I don't remember what it said, or what devices were
actually listed (i'm not at home now and can't check), but i updated
hardware.conf to use the device file that is there (I think for me it
was /dev/lirc0).  I also checked the other parameters in
hardware.conf, such as path to lircd.conf and some other things, to
make sure they jived with reality.  Newer versions of lirc like
everything to be under /etc/lirc.  Also realizing I had installed two
sets of userspace utilites, one from the lirc ubuntu package and the
other set from the compile & installation of lirc from source, I
discovered that they were installed in different locations.  I moved
the set from the source installation out of the way.  mv
/path/to/file/lircd /path/to/file/lircd.bak.  This probably isn't
important but I don't like dueling binaries especially when both are
in the path. I think the ubuntu package puts them in /usr/bin and the
source puts them in /usr/local/bin.  Can't remember though.  Anyway,
now lircd (and the complementary lircmd) would load.  As well, irw
worked and the remote generated output.  And it works across reboots. 
So here I am, frustrated because I don't know exactly what steps I
took actually made the thing work, and what the right way is to
replicate the steps.  Also installing utilities & modules from source
makes for a difficult to maintain system.

Hope these notes help.  Remember they're not a howto, just an
accounting what all I did that did & didn't work.  If anybody has a
howto, we really need it.

Some other lessons I learned along the way:  When you're working on a
project like this, keep a journal so you can record what works and
doesn't work.  That way if you need to do it again, or fix it when it
breaks, you can remember how you put it together to start with. 
Particulary useful months or a year from now.

Also if you find some useful bit of information on some obscure
website like a mail archive or somebodies blog, be sure to write
down/bookmark the url, and also print it out.  The web page may not be
there tomorrow.  One of the webpages I used for ivtv was gone the next
day and I had to use google cache to find it and print it out.

Good luck

> Date: Thu, 31 Mar 2005 07:44:13 -0500
> From: macta <ulist at gs1.ubuntuforums.org>
> Subject: Re: getting lirc working
> To: ubuntu-users at lists.ubuntu.com
> Message-ID: <macta.1mrdsz at gs1.ubuntuforums.org>
> I too have been struglling to get LIRC running - so reading your post at
> least gives me hope.
> Am I correct in understanding (and this might be tricky as I know that
> in these circumstances you try all sorts of things)
> You did:
> 1) apt-get install lirc-source-headers
> 2) followed the instructions in the README
> e.g.
> make-kpkg --revision 4 modules_image
> dpkg -i lirc<version stuff>.deb
> (actually in the above - for Ubunutu hoary, not sure what revision
> number to use as uname -r gives: 2.6.10-4-386?)
> 3) ignore the .o that is put in /lib/modules/kernel-source-ver/misc/
> 4) Download the lirc.org source ( lirc-0.7.0.tar.gz ) extract it and
> follow the INSTALL instructions:
> ./setup.sh && make install
> At this point things seem to work (where as if you did step 4 first it
> wouldn't work - I recall I never got it to work when I tried it, but
> havne't followed these steps)
> 5) Do some manual configuration of modules (what exactly did you have
> to do?)
> 6) fix /etc/lirc/hardware.conf (not sure what you had to do - but I
> imagine this bit depends on your remote)
> Does this seem about right - and if you could expand on any of the bits
> that I didn't understand that would be great.
> Tim
> --
> macta

More information about the ubuntu-users mailing list