"Hier staunt der Laie und Fachmann wundert sich."

Samstag, Oktober 29, 2005

Upgrading to KnoppMyth R5A22

After getting the then latest release R5A16 of KnoppMyth to work with my equipment (Hauppauge PVR 500 and remote, which is a "new" MCE remote), I was anxious to upgrade to the newer version. After all, I had to make quite a lot of changes to the default installation (compile current ivtv and things like that).

Step one: Backup your system -- the easy way

I backed up my system partition /dev/hda1 using
dd if=/dev/hda1 of=/mythtv/backup/mybackup_r5a16.img bs=1024k

This will create a complete, block by block, backup of /dev/hda1 in the file /mythtv/backup/mybackup_r5a16.img. This way I will have all my configuration files in case I forget some of the necessary changes. Or I can even revert to my old system by copying the image file back to /dev/hda1 using
dd if=/mythtv/backup/mybackup_r5a16.img of=/dev/hda1 bs=1024k

This will overwrite the contents of /dev/hda1 with the contents of the image file. This will be my last resort. In fact, I do not plan to do this unless something goes terribly wrong. Instead I plan to use the backup only as a reference source for my old config-files. The image file can easily be mounted, making the contents accessable like a regular filesystem using
mount -o loop /mythtv/backup/mybackup_r5a16.img /mnt/backup

This will mount the backup image read only to the mount point /mnt/backup. (You will need to create this mount point first: mkdir /mnt/backup).

Step two: Prepare KnoppMyth for upgrade

This step is even simpler. Just use the the MythTV menu "KnoppMyth" and there "Backup KnoppMyth". This creates archives of important directories and your mysql database and puts them in /mythtv/backup. The upgrade routine of KnoppMyth will use some of this to restore your configuration. This includes e.g. your channel settings and schedule.

Step three: Upgrade KnoppMyth

Now shut down your system and boot from a new KnoppMyth R5A22 CD. Remember to choose the correct language at the lilo-prompt. E.g. "knoppmyth lang=de" for a German keyboard. When the installation menu appears choose "Auto upgrade". If you are sure that you backed up your data you may proceed. Wait till you have to reboot again, remove the disc and reboot from harddisk.

Step four: First boot after upgrading

One thing I noticed was that the screen resolution had changed. This seems to be because of the bootsplash which is now activated by default (see below). The new resolution makes your fonts appear bigger (not in MythTV but everywhere else) which is not so bad, even though I never bothered to change it before.

After the first boot I expected to have to go through the installation process and having to restore my settings by hand. Surprise, surprise, I did not have to. KnoppMyth obviously comes with an upgrade script which works nicely. It prompts you for the root password and then proceeds to restore your settings (the mysql database) and install some stuff as usual. This version also asks for the remote control you are using. I have a MCE-type remote that came with my TV card. It uses the lirc_mceusb2 driver. This one wasn't listed (I thought) but it turns out that choosing the (original) mceusb driver makes the script ask you whether you are using an old or a new version of the remote. Choosing "new" here corresponds to installing the lirc_mceusb2 driver. So I did all this but the script complains that it should be able to autodetect the remote at this point, which it could not. Thus first thing I checked after completing the install was the remote (using "irw", which should output something on the console if you press a button on the remote). But it doesn't work. -- But I'm jumping ahead of myself. Follow the instructions of the upgrade script and reboot your computer one more time. If you chose to install bootsplash (like I did) you will see an image (a version of the KnoppMyth X background) during the boot process instead of the boot messages. Pressing ESCAPE will show the boot messages though.

Step four: Assessing the upgraded system

Instead of checking dmesg to see if there were any error messages I checked to things: Does the remote work (after all the upgrade script had complained) and do my tuners work?

I had already said that my remote did not work. But the tuners do, both of them. This is nice because last time I had to compile ivtv myself. So KnoppMyth obviously now supports the Hauppauge PVR 500 out of the box. The first time I tried the picture seemed to be too big for the screen though. When I tried again this was gone (strange!). All I did in between was call "ivtv -U" which only outputs the available TV norm on the console.

Anyway, next thing I did was changing KnoppMyths settings for the ivtv-cards in /etc/sysconfig/ivtv/cfg-0 and cfg-1. Because I'm in a PAL country I enabled
IVTV_TYPE=PAL

in both files (i.e. for both tuners of my PVR 500). If you use NTSC then you don't have to change anything as this defaults to NTSC. KnoppMyth uses these configuration files in the script /etc/init.d/set_ivtv_params. [I rebooted after this to see its effects. You don't have to do this here.]

Looking at the LiveTV doesn't look as good as it did before, so I checked the output of "dmesg" for any inconsistencies. While doing that I also disabled (using "modconf") some modules that I'm sure I won't need:
  • under kernel/drivers/media/dvb/bt8xx (do it in this order or it may not work!):
    • dvb-bt8xx (this will also remove bt878, dst_ca, dst, and bttv and possibly more)

Of course, this did not fix the picture quality. I still have to figure out what's wrong with that.

New MythTV setting

Switching to watching Live TV the first time I had also noticed that the program displayed some weird "Signal %" stuff instead of the show's description. Maybe this is related to the new setting in MythTV (mythfrontend) that can be found under Configuration / TV / General / Local settings. There are two new settings called "Guide language #1" and "Guide language #2". Instead of figuring out it's meaning I simply changed if "Arfa" to "German". Of course, you will want to choose your own language. Note that they do not seem to be strictly in alphabetical order, so keep on looking if you can't find the right language right away.

ndiswrapper

I have a WLAN USB adaper (Linksys WUSB54G) which I run with the ndiswrapper modules. There are other ways of doing this (not using ndiswrapper) but I have no time fiddling around with this so I stick to ndiswrapper.

Because I don't have an Internet connection without this card, I had to use the deb-package on my backup image instead of apt-getting the newest one. I created a mount point for my backup image ("mkdir /mnt/loop") and mounted it there:
mount -r -o lo /mythtv/backup/mybackupr5a22.img /mnt/loop
After doing this I was able to access (read only) all my configuration files and everything else via /mnt/loop. First thing I did was update my locate database so the locate command knows about /mnt/loop.
updatedb

Depending on the number of files and speed of your disks this may take a couple of minutes. Afterwards you can use
locate [part_of_name]

to find any files containing [part_of_name]. If used that to locate the driver files for my wlan card (wusb54g). I found them to be at /mnt/loop/etc/ndiswrapper/wusb54g. Using ndiswrapper I installed them with
ndiswrapper -i /mnt/loop/etc/ndiswrapper/wusb54g/wusb54g.inf

If you have a different card then you will need to supply the driver's .inf-file here. Check with "ndiswrapper -l" afterwards if the drivers were correctly installed.

Because I use WPA to protect my WLAN (you should, too!) I also had to install wpa_supplicant. Again, not yet being able to access the internet I had to use my backup image. This time I looked for wpa ("locate wpa") and found the .deb-package at /mnt/loop/var/cache/wpasupplicant_x_i386.deb" where x is a version string, depending on the version you installed. Use "ls /mnt/loop/var/cache/wpa*" to find the correct one. Mine was wpasupplicant_0.4.4-1_i386.deb so I will use that here. Install the package using
dpkg -i /mnt/loop/var/cache/wpasupplicant_0.4.4-1_i386.deb

You will also want to copy the following configuration files (which pertain to the wlan and network in gerneral):
cp /mnt/loop/etc/wpa_supplicant.conf /etc/wpa_supplicant.conf

cp /mnt/loop/etc/default/wpasupplicant /etc/default/wpasupplicant

cp /mnt/loop/etc/network/interfaces /etc/network/interfaces


After that there are a couple of things left to do:
  1. Enable the ndiswrapper-module using modconf (the module is found under "misc", all the way down).
  2. Remove all "linux-wlan-ng" modules using modconf (the modules have their own group right above "misc"). You should disable all of them.
  3. Enalbe wpasupplicant to be started at boot time using
    update-rd.d wpasupplicant defaults

    This will add the script /etc/init.d/wpasupplicant to your default run-levels (2, 3, and 4).
  4. Start wpasupplicant using
    /etc/init.d/wpasupplicant start
  5. Bring up your wlan interface. Mine is called "wlan0" so I do "ifup wlan0". Now you should be able to ping other NICs on you network.


If you used hotplug to bring up your card then you will also want to copy the necessary files. In my case /mnt/loop/etc/hotplug/usb/wlan0 and wlan0.usermap.

Getting the remote to work again

The new upgrade script asks for the type of remote but mine did not work right away. The script installed the correct driver (lirc_mceusb2 in my case) but irw did not show any output. This point to an incorrect /etc/lircd.conf file, and indeed this is the culprit. The upgrade script did not replace it with a correct version (or which would have been even better: with my original one). So I had to do it myself:
cp /mnt/loop/etc/lircd.conf /etc/lircd.conf

After restarting lircd ("/etc/init.d/lirc restart") and quitting and restarting mythfrontend, my remote works like a charm again.

At this point my MythTV box is working as before. I will check out the new features later.