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 https://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)

Version 2.7.0.31

Option to change HTTP server port. You can change the port used by the Stoker HTTP server by using a menu option on the front panel, under “Main -> System Info -> Port”.

The range of valid ports is 1 – 65535. This is fairly large range so just hold down the + or – buttons and it should jump from 10’s to 100’s to 1000’s.

The default port is 80.

Version 2.7.0.31

IP address issues

There have been some issues found for the new 2.7.0.x releases. These have been removed temporarily.

The issues result in the Stoker ceasing to be operational immediately after upgrade. If you have upgraded and the Stoker is working, then this warning can be ignored.

Update: The problem seems to be that the Stoker sometimes fails to acquire an IP address after an update. Everything else is functioning.

Version 2.7.0.7

Fix blower disassociation on web page

Option for outputting the version number of firmware from JSON. Example:

        http://192.168.0.1/stoker.json?version=true

The output:

        { "stoker" : {
            "version" : "2.7.0.7",
            "sensors" :
                [
                    { "id" : id, "name" : name, "al" : al, "ta" : ta, "th" : th, "tl" : tl, "tc" : tc, "blower" : blower_id },
                    ...
                ],

            "blowers" :
                [
                    { "id" : id, "name" : name, "on": on },
                    ...
                ]
            }
        }

This is compatible with JSONP so this is also valid:

        http://192.168.0.1/stoker.json?version=true&callback=parseResponse

Version 2.7.0.7

Version 2.7.0.1

A few minor updates for speed.

New favicon.ico

JSONP support. The firwmare will now allow the JSON GET request to specify a callback parameter. Example:

        http://192.168.0.1/stoker.json?callback=parseResponse

The Stoker will send back the JSON response wrapped in parseResponse.

Version 2.7.0.1

 

Twitter and static IP addresses

When using the Twitter functionality with a static IP address on the Stoker, please make sure all the IP-related fields are filled in properly. The four fields are:

  • IP address
  • Subnet mask
  • Gateway
  • DNS server

These settings can be found on a Windows machine using the command ipconfig /all at the command prompt. The /alloption is necessary to show the DNS server. This should be run on the same physical network the Stoker is on.