Cheap remote with rpi

I bought a Raspberry Pi (www.raspberrypi.org) with the intention on of installing XBMC (www.raspbmc.com) on it.

Raspbmc was straightforward to install.  The issue I had was with the remote control.  I have a cheapo MCE remote with a USB IR receiver and I was hoping it would work straight out of the box, but alas it didn’t.

Edit: Here’s the remote: http://wiki.xbmc.org/index.php?title=Remote_Control_Reviews#IRF_Media_W-01RN

At first I thought it was the weird mouse pointer/arrow mode blue button, but after some trial and error, I realized that wasn’t it.

After a little digging, I found a solution for Linux: http://club.dx.com/forums/Forums.dx/threadid.624377

I verified the solution on my Ubuntu box by cloning the git repository locally (http://gitorious.org/hid-aureal-kernel-module), rebuilding the module, installing it, and executing those modprobe commands.

I figured it would be just as easy on raspbmc, but unfortunately, the headers for the rpi kernel (3.1.9+) aren’t published in the regular repository.  I think raspbmc is based on rasbian (http://www.raspbian.org/).  It didn’t make sense to try and mix-and-match headers, so I decided to rebuild the kernel from scratch.

I had never rebuilt a kernel from scrach, or used that fancy “make menuconfig”, or chroot so I thought I’d give it a shot.  The rpi is made for tinkering, right?

Luckily, the entire process is fairly well documented on the raspbmc site (http://www.raspbmc.com/wiki/technical/kernel/) but I just wanted to share my step-by-step process.

1. Start with a regular Ubuntu box

The kernel build procedure for raspbmc uses a cross-compiler so it builds a lot faster than building it on the rpi itself.  I didn’t time the full compilation process, but I think it’s on the order of 10’s of minutes, not hours.

I don’t remember if I had to install any extra packages before building, but just in case, I would suggest at least this:

sudo apt-get install build-essential

2. Get the build filesystem

The instructions are here: http://www.raspbmc.com/wiki/technical/build-filesystem/

My ubuntu commands were something like:

cd ~
wget http://download.raspbmc.com/downloads/source/filesystem/buildfs-bcm_rootfs-raspbmc-i386_cross_r2-hardfp.tar.gz
mkdir target
cd target
sudo tar -xzf ../buildfs-bcm_rootfs-raspbmc*
cd ..
sudo cp /etc/network/interfaces target/etc/network/interfaces
sudo cp /etc/resolv.conf target/etc/resolv.conf
sudo mount proc -t proc target/proc
sudo chroot target/

3. Get the kernel source and build … all in one go!

A script exists to do all this at once.

# At this point, you should be in the new root file system, as root
wget http://svn.stmlabs.com/svn/raspbmc/testing/kernel/build_kernel.sh
sh build_kernel.sh 4

This downloads the latest kernel source, applies the raspbmc specific patches, and rebuilds. I got a bunch of these errors at the end, but I think they can be ignored:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_COLLATE = "C",
        LC_NUMERIC = "C",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

If this works, congrats, you’ve built a Linux kernel.  Nice.

To be continued … (get module source, create menconfig entry, change usbhid from built-in to module, add new module, rebuild, upgrade pi, edit rc.local to rmmod and then modprobe)