Enable remote support for Asrock ION 330HT

I have bought an Asrock ION 330HT-BD some time ago and today I managed to get the remote working right. Now I can control XBMC with the remote and also put to to sleep and resume it again. Unfortunately, it wasn’t obvious so I describe how I enabled the remote. I used XBMC Live v9.11 (based on Ubuntu v9.10) as a starting point.

Make sure XBMC is not running, when you make changes to the system. Some commands cannot be executed when XBMC is running.

Check BIOS

The integrated IR receiver can be enabled/disabled in the system’s BIOS. The default setting is to enable the IR receiver, but make sure you check the setting. The IR receiver is called CIR in the BIOS and ACPI settings.

Install LIRC

First you need to make sure you have installed ‘LIRC’. Most distributions will install it by default, but otherwise you can enter the following command to install it:

apt-get install lirc

Make sure you have the correct version of LIRC (I use v0.8.6). You can check the version by typing the following command:

lircd --version

Install driver

Install the Asrock driver from the Asrock website. Unpack the driver and make sure you have the v1.0.1 version. The v1.0.0 driver works, but isn’t able to wake up the device when it is in sleep mode. The v1.0.2 version has issues with repeating buttons and it seems that it has been pulled from the Asrock website.

When the driver is downloaded, then you should install the driver using the following command (assuming you run a 32-bit version):

dpkg -i lirc-nct677x-1.0.1-ubuntu9.10.deb

This will install the driver and will guide you through some screens. Note that LIRC is used for IR receivers and transmitters, but we are only interested in the receiver part. In the first list, you can select the IR receiver and in the second list, you choose the IR transmitter. For the Asrock ION 330HT, you’ll need the NUVOTRON receiver and you can leave the transmitter set to ‘NONE’. Oddly enough, the first time the NUVOTRON is not in the list. Just select ‘none’ for both the receiver and transmitter and it will ask you again for an IR receiver. The second time the NUVOTRON is in the list and you should be able to use the remote from within XMBC.

Enable suspend/resume in XBMC

It’s quite convenient to use the remote to suspend/resume the device. Make sure you set XBMC power management options to suspend the device.

You should also configure the system to listen to the IR receiver while suspended to be able to resume when the remote is used again. This can be done by adding the following lines to your /etc/rc.local file:

echo CIR > /proc/acpi/wakeup    # Enable wake-up on IR receiver
echo USB0 > /proc/acpi/wakeup   # Enable wake-up on USB0 port (keyboard)

Make sure this code is executed, so I put it just below the comments that are at the top of the file. Check it by saving the file and reboot your Asrock device. When the system has rebooted, then enter the following command:

cat /proc/acpi/wakeup

It should output the following data:

Device  S-state	  Status    Sysfs node
CIR     S4        enabled   pnp:00:04
SMB0    S4        disabled  pci:0000:00:03.2
USB0    S4        enabled   pci:0000:00:04.0
USB2    S4        disabled  pci:0000:00:04.1
NMAC    S5        disabled  pci:0000:00:0a.0
PBB0    S4        disabled  pci:0000:00:09.0
HDAC    S4        disabled  pci:0000:00:08.0
XVR0    S4        disabled
XVR1    S4        disabled
P0P5    S4        disabled
P0P6    S4        disabled
P0P7    S4        disabled
P0P8    S4        disabled
P0P9    S4        disabled

When you press the ‘ON/OFF’ button on your remote (upper right), then the Asrock should suspend if you have XBMC running (the blue led will flash). When pressing the ON/OFF button again, then it should resume again.

Re-initialize remote in XBMC

When the Asrock resumes, then the IR drivers need to be reloaded and XBMC must be notified. Create a new file called /etc/pm/sleep.d/99lirc-resume.sh with the following content:

#!/bin/sh

# This script uses curl. Install curl using the following command from your terminal apt-get install curl
# This script will restart lirc drivers, Lirc, and XBMC's lirc interpreter upon resume.

# Make sure you also use the LIRC_WB677 driver. You can check which driver is loaded by typing 'lsmod'.
lircDriver=lirc_wb677

case "$1" in
    resume)
        curl "http://127.0.0.1:8080/xbmcCmds /xbmcHttp?command=ExecBuilt&Inparameter=LIRC.Stop"
        /etc/init.d/lirc stop
        rmmod $lircDriver
        modprobe $lircDriver
        /etc/init.d/lirc start
        #remove the comment if the computer automatically sleeps after resume
        #irw & sleep 1; killall irw
        curl "http://127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=LIRC.Start"
        echo "lirc resume script completed!!!" >>/tmp/script.log
    ;;
esac

Make sure the script can be executed by entering the following command:

chmod 755 /etc/pm/sleep.d/99lirc-resume.sh

Some older examples that use the non-HT version of the Asrock use a different driver, so make sure your driver is correct.