Maiku’s Setting up MythTV under Mandrake 10.1 Guide

Posted by maiku


Originally posted Friday, December 03, 2004 @ 4:43 PM


After many weeks of struggle I finally have a functional MythTV box running. This article is a summary of how I got things working with Mandrake 10.1.

Before deciding on Mandrake I tried KnoppMyth and Fedora:

KnoppMyth: I highly recommend first trying KnoppMyth before pursing a Mandrake or Fedora-based machine. It offers a quick, painless installation that seems to work for many people. The KnoppMyth wiki has lots of useful HOWTOs. There’s also good troubleshooting advice available at the KnoppMyth forums. For some reason I encountered kernel panics and general stability issues with the distribution and had to pass on it. Still, if it works for you, go with it!

Fedora: Many people choose Fedora because of Jarod Wilson’s detailed MythTV HOWTO. Fedora’s popularity is definitely an asset as you’re sure to find much help online. While I was able to build a working system with FC2, I again ran into stability issues. Looking back, these were probably caused by my first wireless network card, a DWL-G510.

Mandrake: I ultimately went with Mandrake 10.1. From my experience the Mandrake installation process requires about the same time and effort as Fedora. A set of MythTV RPMs are available thanks to the hard work of Thac of Thac’s RPMs.

————————————————————————————–
————————————————————————————–

Misc. Notes

Lines beginning with ‘|’ represent commands to be entered at the console.
Sections grouped by ‘———‘ usually represent text to be added to scripts or config files.
Commands preceeded by ‘#’ should be entered as root.
Commands preceeded by ‘$’ should be entered as the ‘mythtv’ user.

Ok, I admit a lot of the start-up scripts I use are ugly hacks. Ideally the modules should load from entries in ‘/etc/modprobe.conf’. I hope to fix this in the future, but for now, I’m just glad to see it work!

————————————————————————————–
————————————————————————————–

Hardware and Environment

I used the following hardware for this project:

AMD Athlon 1GHz CPU
384MB PC133 memory
Gigabyte GA-7ZX motherboard
Apollo FX 5200 AGP video card w/ TV-out
Hauppauge PVR-250 (model 980)
D-Link DWL-G120 wireless PCI card (802.11g)
Seagate 160GB hard drive (ST3160023A-RK)
DWL-G120 802.11g USB device

I’m located in the United States, so I relied on zap2it.com for programming guide access. I have plain old analog cable connected to a plain old TV, so no cable box, satellite, or HDTV were involved. Unfortunately I can’t comment on the PVR-350 or any other hardware configurations at this time.

I originally tried to use an ATI Radeon 8500LE with MythTV. I soon learned that nvidia is much more Linux-friendly than ATI, especially when it comes to TV-out. I’d highly recommend going with either an MX440 or FX5200 card for TV-out under Linux.

————————————————————————————–
————————————————————————————–

Installing Mandrake

NOTE: Mandrake 10.1 Official has recently replaced 10.1 Community as the latest release. In the Mandrake development process Community is released first, then after sufficient testing, Official follows. (Official is essentially Community with the latest updates installed.) The latest Community is generally made available for immediate public FTP download. In contrast, Official is available first through commercial bundles and for download by contributors, then after a few weeks Official replaces Community on the FTP servers. These instructions should work with either version. I’ve added notes where Community users may encounter differences.

I began by downloading the three 10.1 Official iso images from http://www.mandrakelinux.com/en/ftp.php3. The Mandrake installation process is fairly straightforward. Below are a few special steps that I took:

I used ‘Custom Disk Partitioning’ rather than the automatic process. I’d suggest creating a separate partition to store your video files so they’ll remain untouched if you ever need to reinstall or switch distributions. I created three partitions, all of type ext3:
— 4GB – mounted as /
— 400MB – swap
— the rest – mounted as /data

I chose the following package groups:
— Workstation: Internet station, Configuration, Console Tools, Development, LSB
— Server: Network Computer server
— Graphical Environment: KDE Workstation

During the ‘Add a user’ configuration stage create a regular user named ‘mythtv’. Enable the option to automatically log-on with the KDE window manager.

At the summary screen, adjust your network adapter settings if necessary, then reboot. I used a USB wireless adapter that was not supported by default, so I left the network unconfigured. For details on how to configure the DWL-G120 and other oddball wireless devices with ndiswrapper, see the ‘Configuring Wireless Networking’ section below.

After the initial reboot, log-in as user ‘mythtv’. Next, open a Konsole window and use the su command to become root and load the kernel-source RPM from installation disc 3 with this command:

|
| # urpmi kernel-source
|

The kernel source is needed to build other packages. If you have a wireless card like mine you’ll need the source to build ndiswrapper as well.

We also need to fix the permissions on ‘/data’ so the mythtv user can access it:

|
| # chown mythtv.mythtv /data
| $ mkdir /data/mythtv
|

————————————————————————————–
————————————————————————————–

Configuring Wireless Networking with ndiswrapper

NOTE: This step only applies to folks with the DWL-G120 or other unsupported wireless adapters.

Much of my early Linux struggle wasn’t with MythTV, but rather the DWL-G510 wireless adapter. The card caused stability problems and generated many strange errors in my log files. I eventually gave up on it and started using a DWL-G120 wireless USB adapter. The G120 has worked flawlessly so far.

Linux can be very particular about wireless devices. If a driver isn’t available, you may be able to use a program called ndiswrapper that loads Windows ndis drivers for use under Linux. Here’s a list of supported cards. Because I initially lacked network support I created a CD-ROM with the ndiswrapper source and the DWL-G120 drivers on a separate computer and copied them over.

Mandrake 10.1 comes with an ndiswrapper module that conflicts with our hand-built version. Before installation we need to find and remove this older module to avoid confusion over which is loading:

|
| # find /lib -name "ndis*"
| /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ndiswrapper
| /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ndiswrapper/ndiswrapper.ko.gz
|
| # rm -rf /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ndiswrapper
|

Then build and install ndiswrapper:

|
| $ cp /mnt/cdrom/ndiswrapper-0.11.tar.gz /home/mythtv
| $ cd /home/mythtv
| $ tar -zxvf ./ndiswrapper-0.11.tar.gz
| $ cd ndiswrapper-0.11
| $ make
| # make install
|

Next, load the DWL-G120 driver and reboot to make sure the old ndiswrapper doesn’t linger:

|
| # ndiswrapper -i /mnt/cdrom/drivers/PRISMA02.inf
| # /sbin/reboot
|

After reboot you can create a simple start-up script to bring up the adapter. I wrote one called ‘start-wlan0’ which I placed in ‘/usr/local/bin’. Set your essid, encryption key, adapter IP, and default gateway accordingly:

——————————————————–
#!/bin/bash

/sbin/modprobe ndiswrapper
/sbin/iwconfig wlan0 mode Managed
/sbin/iwconfig wlan0 essid mynet
/sbin/iwconfig wlan0 key open 11111111111111111111111111
/sbin/ifconfig wlan0 up
/sbin/ifconfig wlan0 192.168.1.50
/sbin/route add default gw 192.168.1.1
——————————————————–

We need to add a DNS entry to ‘/etc/resolv.conf’:

——————————————————–
nameserver 192.168.1.1
——————————————————–

After running the new start-up script you should have network connectivity:

|
| # /usr/local/bin/start-wlan0
|

I added a line to the bottom of the ‘/etc/rc.d/rc.local’ file so the adapter would start at boot time:

——————————————————–
/usr/local/bin/start-wlan0
——————————————————–

NOTE: If you run into any problems after installing Myth, make sure the ‘start-wlan0’ line is at the very bottom of your ‘rc.local’ file after the ‘start-ivtv’ entry.

————————————————————————————–
————————————————————————————–

Configuring urpmi

urpmi is a Mandrake tool that downloads and installs RPMS from a list of user-specified servers. We’ll need to tell the tool what sites to download from. First we’ll clear the default list of media:

|
| # urpmi.removemedia -a
|

Easy urpmi is a helpful site that generates a list of commands needed to configure your urpmi servers. Specify ‘10.1 official’ for the version, then select contrib, main, updates, plf, and jpackage sources. Enter the resulting commands one-by-one as root at the command line. Here’s a sample command list:

——————————————————–
urpmi.addmedia plf ftp://ftp.free.fr/pub/Distributions_Linux/plf/mandrake/10.1 with hdlist.cz
urpmi.addmedia –update updates ftp://mirror.pacific.net.au/linux/Mandrakelinux/official/updates/10.1/main_updates with media_info/hdlist.cz
urpmi.addmedia main ftp://gd.tuwien.ac.at/pub/linux/Mandrakelinux/official/10.1/i586/media/main with media_info/hdlist.cz
urpmi.addmedia contrib ftp://gd.tuwien.ac.at/pub/linux/Mandrakelinux/official/10.1/i586/media/contrib with media_info/hdlist.cz
urpmi.addmedia jpackage ftp://gd.tuwien.ac.at/pub/linux/Mandrakelinux/official/10.1/i586/media/jpackage with media_info/hdlist.cz
——————————————————–

With a DSL connnection it took a few minutes for each command to finish downloading.

Finally, we need to add the most important source of all — thacs.rpms:

|
| # urpmi.addmedia thacs.rpms http://rpm.nyvalls.se/10.1/RPMS with hdlist.cz
|

Thanks again to Thac for maintaining these!

————————————————————————————–
————————————————————————————–

Getting MythTV

With the urpmi sources specified we can began the installation:

|
| # urpmi mythtv-suite
|

The installer prompts you to choose from a series of packages. Not knowing any better, I chose all the packages that referenced ‘nvidia’ (mythtv-nvidia-themes, libmyth_nvidia0, etc.). This seems to work. When prompted with the other choices (e.g. apache2-2/apache2-worker) I chose the first package listed. You’ll eventually be presented with a long list of packages to be installed. Enter ‘y’ and find something to do for the next 1-2 hours.

NOTE: 10.1 Community users may encounter other errors during installation. If so, read on, otherwise skip to the next section:

During the installation if you encounter warnings about packages with ‘bad signatures’. Enter ‘y’ to continue.

4 times out of 5 I ran into some sort of error during installation with Community. This was usually an ‘installation failed’ message caused by conflicts between files in two different packages. If you encounter this, wait for the install attempt to finish, then try running ‘urpmi mythtv-suite’ again.

If you see errors again, try to scroll back through them and see which package is causing the problem. Try installing the trouble package(s) individually with the ‘urpmi PACKAGE_NAME’ command.

If all else fails, try the following command to override the conflict and force an installation:

|
| # urpmi –allow-force mythtv-suite
|

If it finishes without errors, cross your fingers and continue.

————————————————————————————–
————————————————————————————–

Installing ivtv — the capture card driver

The next step is to install ivtv, the PVR-250 driver. This is probably the most involved step in the entire process. Fortunately it usually works on the first try!

At this point Mandrake will already have an ivtv module installed. We need to remove this first to avoid conflicts:

|
| # find /lib -name "*ivtv*"
| /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ivtv
| /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ivtv/ivtv-fb.ko.gz
| /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ivtv/ivtv.ko.gz
|
| # rm -rf /lib/modules/2.6.8.1-10mdk/kernel/3rdparty/ivtv
|

We also need to do this for the msp3400 module:

|
| # find /lib -name "msp3400*"
| /lib/modules/2.6.8.1-10mdk/kernel/drivers/media/video/msp3400.ko.gz
|
| # rm /lib/modules/2.6.8.1-10mdk/kernel/drivers/media/video/msp3400.ko.gz
|

The next step is to download the source and build it. I originally downloaded version 0.1.9 from the ivtv SourceForge site, but found that it didn’t build with the 2.6 kernel. Instead I used a 0.2.0 beta file found on Chris Kennedy’s ivtv site. At the time of this writing, the file is ‘ivtv-0.2.0-rc3a.tgz’ at http://ivtv.no-ip.com. The URL seems to vary, so if in doubt, Google for ‘ckennedy ivtv’ and poke around.

Time to build and install the ivtv driver:

|
| $ cd /home/mythtv
| $ tar -zxvf ./ivtv-0.2.0-rc3a.tgz
| $ cd ivtv-0.2.0-rc3a/driver
| $ make
| # make install
|

Now make sure you have g++ installed:

|
| $ which g++
| /usr/bin/g++
|

If it isn’t found, install it with urpmi:

|
| # urpmi gcc-g++
|

Now make and install the utilities:

|
| $ cd ../utils
| $ make
| # make install
|

The next step is to extract the firmware from the pvr-250 drivers. There’s a good explanation of the process at the ivtv wiki. I downloaded the 1.81.21.22254 driver from the wiki’s driver list.

Now the firmware extraction:

|
| # cd /home/mythtv/ivtv-0.2.0-rc3a/utils
| # ./ivtvfwextract.pl /home/mythtv/pvr_1.18.21.22254_inf.zip
|

If all goes well, you should have two files in ‘/lib/modules’: ‘ivtv-fw-dec.bin’ and ‘ivtv-fw-enc.bin’.

By default the installer places our new modules in ‘/lib/modules/2.6.8.1-10mdkcustom/extra’. Our kernel won’t see these, so we need to move them to ‘/lib/modules/2.6.8.1-10mdk/misc’:

|
| # cp /lib/modules/2.6.8.1-10mdkcustom/extra/*.ko /lib/modules/2.6.8.1-10mdk/misc
|

Just to be safe, we’ll reload the module list and reboot:

|
| # /sbin/depmod -a
| # /sbin/reboot
|

Installation complete! After rebooting we need to load the new modules:
(NOTE: The ‘type=39’ line may vary.)

|
| # /sbin/modprobe i2c-core
| # /sbin/modprobe i2c-algo-bit
| # /sbin/modprobe tuner type=39
| # /sbin/modprobe msp3400
| # /sbin/modprobe videodev
| # /sbin/modprobe saa7115
| # /sbin/modprobe ivtv
|

Now we can test the video, try:

|
| # /bin/cat /dev/video > blah.mpg
|

Wait 10 seconds for the command to collect video, then hit CTRL-C. Now try to play it back:

|
| # /usr/bin/mplayer blah.mpg
|

If all goes well, you should see a video clip and hear audio.

For MythTV to work, all of these modules need to be loaded before starting the services. I wrote a script — ‘/usr/local/bin/start-ivtv’ that looks like this:

——————————————————–
#!/bin/bash

/sbin/modprobe i2c-core
/sbin/modprobe i2c-algo-bit
/sbin/modprobe tuner type=39
/sbin/modprobe msp3400
/sbin/modprobe videodev
/sbin/modprobe saa7115
/sbin/modprobe ivtv
——————————————————–

We’ll be adding more to the script later.

————————————————————————————–
————————————————————————————–

Setting up MySQL

First we need to make sure MySQL starts at boot time, then we need to start it:

|
| # /sbin/chkconfig mysql on
| # /etc/init.d/mysql start
|

Now we adjust DB permissions with the following commands. Enter the root password in place of ROOT_PWD:

|
| # mysql -u root mysql
| mysql> UPDATE user SET Password=PASSWORD(‘ROOT_PWD’) WHERE user=’root’;
| mysql> FLUSH PRIVILEGES;
| mysql> quit
|

Finally we create the necessary Myth tables. Enter this line, then enter the root password when prompted:

|
| $ mysql -u root -p < /usr/share/doc/mythtv-0.16/database/mc.sql
|

(Thanks to the MythTV HOWTO for these steps!)

————————————————————————————-
————————————————————————————-

Setting up MythTV and downloading the program guide

If you’re in the US, you’ll need to create a zap2it.com account to access program guide information. See http://mythtv.org/docs/mythtv-HOWTO-5.html#ss5.4 for details.

At last, it’s time to configure MythTV! Run the setup program, enter ‘yes’ when prompted to clear the ‘capture card’ and ‘program/channel’ settings:

|
| $ mythtvsetup
|

The setup program is fairly straightfoward. Here are some notes on my configuration:

——————————————————–
1. General:
Enter your IP address for ‘IP address for localhost’ and ‘Master Server IP address’.
Enter ‘/data/mythtv’ for the ‘recordings’ and ‘Live-TV buffers’ directories.
For the ‘TV format’ I selected ‘NTSC’.
For ‘VBI format’ I selected ‘NTSC Closed Caption’.
For ‘Channel frequency table’ I selected ‘us-cable’.

2. Capture cards:
Create a new capture card, set the ‘Card type’ to ‘MPEG-2 Encoder card’, set ‘Default input’ to ‘Tuner 0’.

3. Video sources:
Create a new video source.
Set ‘XMLV listings grabber’ to ‘North America (DataDirect)’.
Enter your zap2it User ID and Password.
Click retrieve lineups.
‘Data Direct Lineup’ should be correct based on your zap2it registration info.

4. Input connections:
Set the ‘Tuner 0’ item’s ‘Video source’ equal to the name of the source you just created.
——————————————————–

Now we can fill the database with our initial program guide data:

|
| $ mythfilldatabase
|

Time to run myth:

|
| # /etc/init.d/mythbackend start
| $ mythfrontend
|

Everything works perfectly, right? Right??

————————————————————————————–
————————————————————————————–

Configuring the Hauppauge Silver Remote

The following steps should get your Hauppauge working with lirc. If you run into problems, try searching the lirc mailing list archives for clues.

We first remove the liblirc files that were installed by mythtv-suite to avoid conflict:

|
| # rpm -e –nodeps liblirc0
| # rpm -e –nodeps liblirc0-devel
|

Download the most recent lirc source from http://www.lirc.org, then unpack and configure:

|
| $ cd /home/mythtv
| $ tar -zxvf ./lirc-0.7.0.tar.gz
| $ cd lirc-0.7.0
| $ ./setup.sh
|

In the setup app, select item 1, then item 5 ‘TV Card’, then item f, ‘Hauppauge TV card’.
Next select item 3, ‘Save configuration & run configure’.

Build and install lirc. Link the new library files:

|
| $ make
| # make install
| # ln -s /usr/local/lib/liblirc_client.so.0 /usr/lib/liblirc_client.so.0
|

Edit ‘/etc/ld.so.conf’, adding the following line:

——————————————————–
/usr/local/lib
——————————————————–

Then run ldconfig:

|
| # ldconfig
|

Copy the lircrc file for the Hauppauge remote from the MythTV installation and add a necessary link:

|
| $ cd /usr/share/doc/mythtv-0.16/configfiles
| $ cp hauppauge-lircrc-nativelirc /home/mythtv/.mythtv/lircrc
| $ ln -s /home/mythtv/.mythtv/lircrc /home/mythtv/.lircrc
|

Copy the lircd.conf sample from the lirc source directory, then reboot once more for luck:

|
| $ cd /home/mythtv/lirc-0.7.0/remotes/hauppauge
| # cp ./lircd.conf.hauppauge /etc/lircd.conf
| # /sbin/reboot
|

After rebooting I altered my ‘/usr/local/bin/start-ivtv’ file to look like this:

——————————————————–
#!/bin/bash

/sbin/modprobe i2c-core
/sbin/modprobe i2c-algo-bit
/sbin/modprobe tuner type=39
/sbin/modprobe msp3400 simple=1
/sbin/modprobe videodev
/sbin/modprobe saa7115
/sbin/modprobe ivtv
/sbin/modprobe lirc_i2c
/usr/local/sbin/lircd -d /dev/lirc0 –permission=666
/etc/init.d/mythbackend start
——————————————————–

If all’s well, you should be able to start everything with the script and begin using your remote:

|
| # /usr/local/bin/start-ivtv
| $ mythtvfrontend
|

To get the script to start at boot time add this line to the bottom of ‘/etc/rc.d/rc.local’:

——————————————————–
/usr/local/bin/start-ivtv
——————————————————–

NOTE: To get the FastForward/Rewind buttons working, edit ‘/home/mythtv/.mythtv/lircrc’ changing "Rew" to "Rewind" and "FFW" to "Forward".

————————————————————————————–
————————————————————————————–

Configuring TV-out

I downloaded the ‘Linux IA32’ drivers from the ‘Graphics Drivers’ section of the Linux nvidia site. I then followed the instructions in the detailed README.txt file.

NOTE: If you encounter errors like "Unable to load kernel module," try commenting out the ‘start-ivtv’ and ‘start-wlan0’ items from your ‘rc.local’ file, rebooting, and installing the driver again. Once the install passes, uncomment the lines and continue.

After installing the drivers I added a line to /etc/modprobe.preload so the nvidia driver would load at startup:

———————————————
nvidia
———————————————

Here’s how the ‘device’ section of my ‘/etc/X11/xorg.conf’ file turned out:

———————————————
Section "Device"
Identifier "device1"
VendorName "nVidia"
BoardName "NVIDIA GeForce FX (generic)"
#Driver "nv"
Driver "nvidia"
Option "TVStandard" "NTSC-M"
Option "TVOutFormat" "SVIDEO"
Option "ConnectedMonitor" "TV"
EndSection
———————————————

This configuration results in output to just the TV under X. I never figured out how to get the clone mode working (TV + Monitor), but this is fine for now. When I need to do any extensive work in X I just comment out the ‘ConnectedMonitor’ option and restart, then set it back later.

I found that if I exited from X to the full-screen console mode everything became garbled with large fonts. I fixed this by editing ‘/etc/lilo.conf’ and setting ‘vga=normal’. Be sure to run the ‘lilo’ command after editing the file!

————————————————————————————–
————————————————————————————–

Loose Ends

Here are some other things worth tweaking. I hope to elaborate on these in future updates:

Blue lines!!

When viewing live TV with TV-out I noticed faint blue lines across the top and left-hand side of the screen. This can be fixed with the xvattr command:

|
| # urpmi xvattr
| $ xvattr -a XV_COLORKEY -v 0
|

The command has to be run every time X starts. I first tried adding it to .xinirc, but this stopped X from launching. I eventually wrote a little script to take care of this and placed a link to it in /home/mythtv/.kde/Autostart/.

—————————————
#!/bin/bash
/usr/bin/xvattr -a XV_COLORKEY -v 0
/usr/bin/mythfrontend
—————————————

Time with ntp

It’s important to keep your system time set correctly. Here’s a Time Synchronization HOWTO for KnoppMyth that explains how to configure ‘ntp’.

Using the remote with DVDs and Videos

Myth relies on mplayer to play DVDs and imported video files. The ‘lircrc’ file we installed doesn’t have mplayer entries, so the remote won’t work with these types of media. The solution is simply to edit ‘lircrc’ and add the entries. Jarod Wilson has a sample file that serves as a good guide. Just copy the lines that reference ‘mplayer’ and tweak to your liking.

mplayer doesn’t have support for DVD menus, so many people configure Myth to use xine instead. I hope to write about this in a future update.

MythWeb

If you browse to http://yourhostip/mythweb/ you should see an interactive web version of the program guide. Myth can be a pain to install, but perks like this are worth it!

Dynamic DNS

If you’re a real TV fanatic, you’ll probably want to access MythWeb from work. Most of us have dynamic IP addresses that make it difficult to know what URL to visit. One workaround is to create a free Dynamic DNS account at DynDNS.org. To keep your DNS entry current, try ddclient, a Linux daemon that periodically checks your IP and sends updates to DynDNS as needed.

————————————————————————————–
————————————————————————————–

Credits

I never would have gotten Myth working without Jarod’s HOWTO and the MythTV docs.

The Mandrake Users is great site for Mandrake-specific help.

————————————————————————————–
————————————————————————————–

Update History

12/11/04
– Updated for Mandrake 10.1 Official.
– Fixed lirc section.
– Added Update History section.

12/3/04
– Initial Release