Friday, December 24, 2010

HOWTO: Get working ASRock HT330 remote on XBMC and Ubuntu

HOWTO: Get working ASRock HT330 remote on XBMC and Ubuntu

Note: If you don't care for the details, scroll down and grab the entire script below.

First thing you need to do is get a console. If you are using XBMC, press CTRL+ALT+F1.
In the console, you need to log in with your username and password.

Once you are logged in, create a working folder:
mkdir ir
cd ir


You need lirc for remotes to work:
sudo apt-get install lirc


Now you need to get the CIR drivers from ASRock:

wget "http://europe.asrock.com/downloadsite/drivers/Nettop/Ubuntu/IR(10.04).zip" --output-document=cir.zip
unzip -j cir.zip
unzip -j lirc-nct677x-1.0.4-ubuntu10.04.zip


I found the ASRock drivers here.

Now try to install it:
sudo dpkg -i lirc-nct677x-1.0.4-ubuntu10.04.deb


As explained in another blog you must choose "None" and then "None" again.

It will do work, and then ask you again for receiver type. This time select the
"Nuvoton Transceivers/Remotes" as the receiver and then "None" for the transmitter.

If it fails, your output will look like this:
* Stopping remote control daemon(s): LIRC[ OK ]
patching file /usr/share/lirc/lirc.hwdb
* Stopping execution daemon: irexec [fail]
* Stopping remote control daemon(s): LIRC [fail]
* Starting execution daemon: irexec [fail]


Now try to manually load the module:
sudo modprobe lirc_wb677


You will likely get an error like this:
FATAL: Error inserting lirc_wb677 (/lib/modules/2.6.31-16-generic/kernel/ubuntu/lirc/lirc_wb677/lirc_wb677.ko): Invalid module format


And if you run dmesg you will see:
[  534.630092] lirc_dev: IR Remote Control driver registered, major 61
[ 534.631027] lirc_wb677: disagrees about version of symbol module_layout


What has happened is that the kernel version does not match the version that the driver was made for, so now you need to build your own driver.

First, get the tools to build the driver:
sudo apt-get update
sudo apt-get install dkms build-essential lirc-modules-source


Then install the source for the driver:
unzip -j lirc-nct677x-src-1.0.4-ubuntu10.04.zip
sudo dpkg -i lirc-nct677x-src-1.0.4-ubuntu10.04.deb


You will now get the message:
You can use dkms commands to compile / install nct677x / w836x7 CIR driver now.
e.g.
to build src : dkms build -m lirc-nct677x-src -v 1.0.0-ubuntu9.10
to install binary : dkms install -m lirc-nct677x-src -v 1.0.0-ubuntu9.10
to uninstall binary : dkms uninstall -m lirc-nct677x-src -v 1.0.0-ubuntu9.10
to remove src : dkms remove -m lirc-nct677x-src -v 1.0.0-ubuntu9.10 --all
After updating src, remember to update lirc.hwdb and
reconfigure lirc by the following command:
dpkg-reconfigure lirc


Apart from the fact that the version is 1.0.4, this looks nice, so lets try the build command:
sudo dkms build -m lirc-nct677x-src -v 1.0.4-ubuntu9.10


This gives the rather unhelpfull error:
Error! DKMS tree does not contain: lirc-nct677x-src-1.0.0-ubuntu9.10
Build cannot continue without the proper tree.


After some poking around, it turns out that the "tree" is actually located in /var/lib/dkms,
so we need to make a structure that fits DKMS:
sudo mkdir /var/lib/dkms/lirc-nct677x-src
sudo mkdir /var/lib/dkms/lirc-nct677x-src/1.0.4-ubuntu9.10
sudo cp -R /usr/src/lirc-nct677x-src-1.0.4-ubuntu9.10/ /var/lib/dkms/lirc-nct677x-src/1.0.4-ubuntu9.10/source


Now DKMS should be happy, so build and install the module (we force the module to overwrite the one installed by the package earlier):
sudo dkms build -m lirc-nct677x-src -v 1.0.4-ubuntu9.10
sudo dkms install -m lirc-nct677x-src -v 1.0.4-ubuntu9.10 --force


Lets try modprobe again:
sudo modprobe lirc_wb677


And this time there should be no errors.

Now re-configure lirc:
sudo dpkg-reconfigure lirc


Select the "Nuvoton Transceivers/Remotes" as the reciever and then "None" for the transmitter.

The output should show that it succeeds:
* Loading LIRC modules [ OK ]
* Starting remote control daemon(s) : LIRC [ OK ]
* Starting execution daemon: irexec [ OK ]


Now reboot the machine:
sudo reboot


And it should work!

If you upgrade your kernel at some point, you just need to rebuild the module again:
sudo dkms build -m lirc-nct677x-src -v 1.0.0-ubuntu9.10
sudo dkms install -m lirc-nct677x-src -v 1.0.0-ubuntu9.10 --force


As promised a full script. When asked for the reciever select "Nuvoton Transceivers/Remotes", and if
it is not on the list, select "None". It should show the selection dialog two/three times, with two selections
for each run (a total of 4/6 blue dialogs):

mkdir ir
cd ir
wget "http://europe.asrock.com/downloadsite/drivers/Nettop/Ubuntu/IR(10.04).zip" --output-document=cir.zip
unzip -j cir.zip
unzip -j lirc-nct677x-1.0.4-ubuntu10.04.zip
unzip -j lirc-nct677x-src-1.0.4-ubuntu10.04.zip
sudo apt-get install dkms build-essential lirc-modules-source
sudo dpkg -i lirc-nct677x-1.0.4-ubuntu10.04.deb
sudo dpkg -i lirc-nct677x-src-1.0.4-ubuntu10.04.deb
sudo mkdir /var/lib/dkms/lirc-nct677x-src
sudo mkdir /var/lib/dkms/lirc-nct677x-src/1.0.4-ubuntu9.10
sudo cp -R /usr/src/lirc-nct677x-src-1.0.4-ubuntu9.10/ /var/lib/dkms/lirc-nct677x-src/1.0.4-ubuntu9.10/source
sudo dkms build -m lirc-nct677x-src -v 1.0.4-ubuntu9.10
sudo dkms install -m lirc-nct677x-src -v 1.0.4-ubuntu9.10 --force
sudo modprobe lirc_wb677
sudo dpkg-reconfigure lirc

No comments: