Category Archives: raspberry pi

New raspbmc

I had the auto-update for raspbmc turned off so I decided to update.  The UI performs much better with this version.  I did have some more remote issues.  The “back” button and “i/more” button on the remote didn’t work anymore.

The fix was to update the XML files related to the remote.

First .xbmc/userdata/Lircmap.xml

<lircmap>
  <remote device="devinput">
    <back>KEY_ESC</back>
    <info>KEY_COMPOSE</info>
    <star>KEY_SUBTITLE</star>
    <play>KEY_PLAYPAUSE</play>
  </remote>
</lircmap>

And then .xbmc/userdata/keymaps/keyboard.xml

<keymap>
  <global>
    <remote>
      <star>contextmenu</star>
    </remote>
  </global>
</keymap>

This maps:

  • left arrow/back to back
  • i/more to info
  • asterisk to the context menu
  • play/pause works as expected

Raspbmc and HDMI audio

I found recently that I didn’t hear any audio from HDMI.  Googling revealed this: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062

Following those tips, I ssh’ed into the rpi and did this:

sudo nano /boot/config.txt

And added this at the end:

hdmi_drive=2

Then hit control-o to write out the file, control-x to exit, and reboot.

I remember having done this before and I realized my previous change was probably overwritten by a recent auto-update. So just in case, I disabled the auto-update feature from “Programs->Raspbmc Settings”.

Raspbmc and the remote – round 3

Another update, another battle with the remote.

StreetFighterIV_2009_08_12_17_19_15_16

I did all the usual stuff, as mentioned in the previous posts.

Nothing.

Looking at the logs, it turns out all this module stuff is already built into the most recent kernel. I even see the tell-tale “fixing aureal” message in dmesg. I added the changes to /etc/rc.local, but no success. Only the mouse worked.

After a bunch of trial and error, I think there’s some sort of conflict between lirc and eventlirc. Only after I started killing a bunch of lircd processes did the remote start sputtering to life.

My fix right now? Yet another “what am I doing?” hack. Here it goes.  Start from a fresh build/image.

ssh into your raspberry pi using putty

# sudo nano /lib/udev/lircd_helper

This will bring up an editor. Skip the first bunch of lines that start with #.
Right before you see

logger -t "lircd_helper" ACTION ${ACTION}

add the following

# I don't know why this works.  It just does.
logger -t "lircd_helper" Crash and burn.
exit 1;

logger -t "lircd_helper" ACTION ${ACTION}

To exit, the editor, hit control-o (to write the file) and then control-x to exit. And reboot.  No custom kernel.  No downloading headers.  None of that.  Just a hack to stop lircd from running.

All this does is prevent lircd from running. This seems to allow eventlircd to run. Which seems to be the key.

This is how I feel:

pacquiamarquez4

 … a little bit Pacquiou and a little bit Marquez …

Raspbmc – RC5

RC5 is out so I tried it, hoping that with the kernel headers, the addition of the module would be easier.

Unfortunately, I’m not sure what they mean by “kernel headers available” but I was unable to see any headers when I installed the new version.

To get the remote working again, I had redo the same steps as before.  Luckily my Ubuntu box had all the stuff left over from before so it was really quick.

Actually, the only additional change was just before running the make menuconfig command, I made sure I had the proper kernel config.

So on my Ubuntu box, assuming the “chroot” had already been run:

cd /
scp pi@192.168.3.14:/proc/config.gz .
cd /raspberrypi-linux-*
zcat ../config.gz > .config

The kernel configuration is stored in config.gz, but it’s compressed. zcat uncompresses it.

Just need to change the IP address for your rpi.

Also, I found that the remote control would sometimes not respond and looking at the logs, I found that this fix wasn’t working. Adding a delay in rc.local seems to help:

# Sleep for a little bit ... seems to help
/usr/bin/logger rc.local sleeping for 5 seconds 
/bin/sleep 5
/usr/bin/logger rc.local sleeping done

# module magic stuff
/sbin/rmmod usbhid || true
/sbin/modprobe hid-aureal || true
/sbin/modprobe usbhid || true

The logger should put messages in /var/log/syslog on the rpi.

rpi continued

4. Get the module source

# You should still be root after the chroot command
cd /
git clone git://gitorious.org/hid-aureal-kernel-module/hid-aureal-kernel-module.git

5. Prep for adding a new module

Copy the module source into the driver directory. I decided to put in it in the directory that seemed to be similar. Note the use of the wildcard in “raspberrypi-linux*”.  The trailing letters seem to change occassionally.

cd raspberrypi-linux-*/drivers/hid/usbhid/
cp /hid-aureal-kernel-module/aureal-id.h .
cp /hid-aureal-kernel-module/hid-aureal.c .

Edit the kernel configuration to include this new module.

nano Kconfig

Under these lines:

comment "USB Input Devices"
        depends on USB

Add the following text

config HID_AUREAL
        tristate "Aureal fix"
        default m
        help
          Aureal fix

Edit the Makefile

nano Makefile

At the end of the file add:

obj-$(CONFIG_HID_AUREAL)        += hid-aureal.o

6. Configure kernel

# The following needs to be done once
apt-get install libncurses5-dev
# Start the configuration menu
cd /raspberrypi-linux-*
make ARCH=arm menuconfig

You will be given a menu selection with a bunch of options. Go to “Device Drivers” -> “HID Devices”. You should see an “M” next to “Aureal fix”.

Select “USB Human Interface Device (full HID) support” and hit the “m” key so that “M” is shown next to this option also.

Exit out of the menu and make sure to save the configuration.

7. Rebuild

I’ve uploaded a modified version of the build script that will rebuild the kernel and regenerate the output.

cd /
wget http://kaytat.com/rebuild.sh
sh rebuild.sh

8. Install the new kernel onto the rpi

Copy the output to the pi using scp

# You should still be root after the chroot command
cd /
scp kernel-*.gz pi@192.168.3.14:/home/pi

You will need to modify 192.168.3.14 to the IP address of the rpi. This command will ask for a password. It’s “raspberry”.

SSH into the pi and install. I use Putty for SSH. The username is pi and password is the same as above. Then run:

sudo -s
cd /
tar -xzf /home/pi/kernel-rootfs-latest-hardfp.tar.gz
cd boot
tar -xzf /home/pi/kernel-vfat-latest-hardfp.tar.gz
nano /etc/rc.local

Near the very end, just before “exit 0” add the following lines:

/sbin/rmmod usbhid || true
/sbin/modprobe hid-aureal || true
/sbin/modprobe usbhid || true

The “|| true” is necessary due to the -e switch in #!/bin/sh. Save the file and then reboot.  This is actually the main part of this whole exercise.  I did all this so that I could make kernel modules and then be able to unload them, and then reload them in the proper order.

reboot

That should be it.

9. Verify

On the pi, run

dmesg

You should see

aureal 0003:0755:2626.0001: fixing Aureal Cy se W-01RN USB_V3.1 report descriptor. Keyboard Logical Maximum = 101

The key is the “fixing” part since that word comes from the module we built.

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)