Prettymad.net

How to build a Myth TV Box, Revised

This is a Guide to installing MythTV on Debian/Unstable not using Knoppmyth or anything like that, its based on my preferred installation of MythTV on my hardware and could be used as a guide. I've written down all the steps I've taken to get my box going from start to end.

I'm in Australia, so all the settings are based around whats available and works here.

Hardware Configuration

My Setup

HDD Config

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1              12G  4.4G  6.6G  40% /
tmpfs                 126M  4.0K  126M   1% /dev/shm
/dev/hdc1             187G  179G  7.6G  96% /mnt/store
/dev/hdd1             233G  186G   48G  80% /mnt/media
tmpfs                  10M  2.8M  7.3M  28% /dev

Debian Installation

I used a Debian Net-Inst CD to install a Basic Copy of Debian.

  1. Connect via Ethernet (no wireless yet) to a network with DHCP.
  2. Boot with the command option for 2.6 Kernel: linux26
  3. Choose language: English
  4. Country or Region: Australia
  5. Keyboard Layout: American English
  6. Choose a servername [mythtv] and a domain
  7. I chose to manually partition my HDDs with a combination of ReiserFS for host HDD + JFS for Data HDDs + ~600Mb of swap space
  8. I chose not to use LVM, although you might want to set it up but that's out of the scope of this document
  9. Install GRUB to the MBR
  10. Reboot, my netinst had kernel 2.6.8-1-386 by default
  11. You will be greeted by the 'Welcome to your new Debian system!' dialog
  12. Don't set hardware clock to GMT
  13. Choose Australia/Sydney (NSW)
  14. Enter your new root password, and a new user account, don't use the name 'mythtv' use something else, mythtv is added later
  15. Select to access apt via ftp using ftp.debian.org, or your closest mirror (although ftp.au.debian.org generally has really old packages, so not recommended!)
  16. Apt will test your sources, and download a few apps like mdetect
  17. Next you are prompted with the 'Debian software selection screen', I choose nothing at this point, and hit
  18. Apt will then download more libraries/apps mainly libc6 and other core libraries, let it do its thing
  19. Select to configure the Mail Transfer Agent (MTA), don't split into smaller files, and use local delivery, use the default settings
  20. Finish configuring the base system, you should now have a shell, login and you are ready to do more installation and downloads...
  21. Note I had to add APT::Force-LoopBreak "1"; line to /etc/apt/apt.conf
  22. $ apt-get install sudo vim less gnupg
  23. Install sudo and vim, edit the /etc/sudoers file using 'visudo' and add the mythtv user (its just easier that way, you can remove it later)

Upgrade Debian to Unstable from Testing

  1. login as root
  2. $ vi /etc/apt/sources.list
  3. Change "testing main" to "unstable main", leave the security.debian.org as is
  4. $ apt-get update
  5. $ apt-get upgrade;
  6. you will probably have to answer some questions, just use default. Upgrade glibc, restart services etc..
  7. if asked about configuration files, install the package maintainers version 'Y' or 'I'
  8. $ apt-get dist-upgrade
  9. go through just about the same process as above with apt-get upgrade

Apt get all the stuff you need for a working system

deb http://apt.cerkinfo.be/ unstable main contrib non-free
sudo vim less gnupg xserver-xorg xfonts-base xfonts-100dpi xfonts-75dpi 
xfonts-scalable ssh rsh-server dvbstream dvbtune dvb-utils
qt3-dev-tools libqt3-mt-dev libqt3-compat-headers 
libgnome-dev libqt3-i18n imlib1 esound-clients orbit 
libc6-dev tk8.3 libncurses5-dev alsa-base alsa-utils 
alsa-oss udev g++ lib64stdc++6 libmp3lame-dev libmp3lame0 
xmltv libasound2-dev libdvdnav-dev libdvdnav kdelibs4-dev 
libcdaudio0-dev libcdparanoia0-dev libflac-dev flac libid3tag0-dev
ratpoison cvs make sharutils wireless-tools

Install X Windows

  1. $ apt-get install xserver-xorg xfonts-base xfonts-100dpi xfonts-75dpi xfonts-scalable ssh rsh-server xbase-clients
  2. when setting up xserver-xorg use the default settings and it should auto-detect everything for you.. hopefully :P
  3. when choosing the resolution, select something minimal that you *know* will work, the default is generally quite safe
  4. start up x, twm will probably be your default window manager
  5. $ startx

Get the latest Kernel Version

  1. At the time of writing the latest stable kernel is 2.6.13, but the latest version in the Debian repository is 2.6.12, so we install that. I'm install the k7 version. But if you are intel install the 686 version.
  2. $ apt-get install linux-image-2.6.12-1-k7 linux-headers-2.6.12-1-k7
  3. Restart and reboot into your new kernel

An "lspci" shows you our two DVB tuners:

0000:00:09.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
0000:00:09.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
0000:00:0a.0 Multimedia video controller: Brooktree Corporation Bt878 Video Capture (rev 11)
0000:00:0a.1 Multimedia controller: Brooktree Corporation Bt878 Audio Capture (rev 11)
  1. Edit the /etc/modules and add dvb-bt8xx
  2. $ modprobe dvb-bt8xx

Our "lsmod | grep dvb" shows:

dvb_bt8xx              12932  0
nxt6000                 8132  1 dvb_bt8xx
mt352                   6980  1 dvb_bt8xx
sp887x                  8324  1 dvb_bt8xx
dst_ca                 17280  1 dvb_bt8xx
dst                    19844  2 dvb_bt8xx,dst_ca
dvb_core               84904  2 dvb_bt8xx,dst_ca
cx24110                 8580  1 dvb_bt8xx
 or51211                10116  1 dvb_bt8xx
bt878                  10552  2 dvb_bt8xx,dst
bttv                  156944  2 dvb_bt8xx,bt878
firmware_class         10432  4 dvb_bt8xx,sp887x,or51211,bttv
i2c_core               21904  12 dvb_bt8xx,nxt6000,mt352,sp887x,dst,cx24110,or51211,i2c_viapro,tuner,bttv,i2c_algo_bit,tveeprom

nVidia Configuration

I suggest you visit http://gentoo-wiki.com/HOWTO_Xorg_HDTV for a good guide

Testing DVB Tuning and Scanning

  1. $ apt-get install dvbstream dvbtune dvb-utils
  2. Get Australian frequencies frequencies from here

DVB Utils has a few frequencies for Sydney/Australia. I'm on the Central Coast so I had to make my own.

The most popular one would no doubt be au-sydney_north_shore, you can find it, and others in the directory: /usr/share/doc/dvb-utils/examples/scan/dvb-t

Now that we have our frequencies we can scan to make a channels.conf file:

mkdir ~/.tzap
./scan /usr/share/doc/dvb-utils/examples/scan/dvb-t/au-sydney_north_shore > ~/.tzap/channels.conf

If all goes well it should scan the frequencies in the input file, and output dvb streams to the channels.conf file

Have a look at the channels.conf file, it should look something like this:

$ head ~/.tzap/channels.conf
7 Digital 1:760500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:513:514:1313
7 Digital 2:760500000:INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_2_3:FEC_NONE:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:513:514:1314

We output to ~/.tzap because tzap is the program we will use to LOCK and test our frequency.

Now try to lock to a channel, the secret keyword is FE_LOCK, if you see this it means you can get a stream!

tzap "7 Digital 1"

If you got a lock, you can use dvbstream to save the output somewhere and use mplayer to view it, this is beyond the scope of this document, as if u get a lock it means u got a stream and proper data.

Install MythTV from a Repository

I don't recommend this part, I always have had problems from installing myth using binaries, I recommend you compile! So skip this section...

  1. No doubt there are quite a few repositories around there to install MythTV from. I used deb http://dijkstra.csh.rit.edu/~mdz/debian unstable mythtv
$ vi /etc/apt/sources #and add the following line
deb http://dijkstra.csh.rit.edu/~mdz/debian unstable mythtv
deb http://apt.cerkinfo.be/ unstable main contrib non-free
$ apt-get update
$ apt-get install mythtv
  1. follow the defaults for installing mysql etc..

Or, Build and Compile MythTV yourself

I prefer this method myself

$ cd /usr/src && mkdir mythtv && cd mythtv
$ svn co http://svn.mythtv.org/svn/branches/release-0-18-fixes/mythtv

$ apt-get install qt3-dev-tools libqt3-mt-dev libqt3-compat-headers libgnome-dev libqt3-i18n\
> imlib1 esound-clients orbit libc6-dev tk8.3 libncurses5-dev alsa-base alsa-utils alsa-oss udev\
> g++ lib64stdc++6 libmp3lame-dev libmp3lame0 xmltv libasound2-dev libdvdnav-dev libdvdnav
> kdelibs4-dev libcdaudio0-dev libcdparanoia0-dev libflac-dev flac libid3tag0-dev

$ ./configure --enable-dvb --dvb-path=/usr/src/linux-headers-2.6.12-1/include --prefix=/usr
$ qmake mythtv.pro
$ make && make install

Create mythtv user in mysql

In order to mythtv to work we need to create a user and 'mythconverg' database.

$ su -
$ mysql
$ mysql> GRANT ALL PRIVILEGES ON *.* TO 'mythtv'@'localhost'
   ->     IDENTIFIED BY 'mythtv' WITH GRANT OPTION;

Add a mythtv user if one dosn't exist, and create a database for mythtv

$ mysql -u mythtv -p
$ create database mythconverg;

Install tv_grab_au

Get the latest version from http://immir.com/tv_grab_au

This is a perl script, debian dosn't have all the perl packages required by this script, so you need to fetch some packages via cpam, which is not that difficult.

I don't remember what packages exactly so you'll have to have a play

Configure MythTV and add channels

Ok, I'm not going to run thru the main details here, basically just the most simple things.

$ mythtv-setup

As this is the first time running mythtv-setup, delete your card settings and your channel configs

  1. 2. Add your Capture Cards
  2. 3. Add your Video Source, I call mine dvbt, it should ask about your tv_grab_au details
  3. 4. Link your Input Connections to your new Video Source
  4. 5. Channel Editor, try Scan for Channels, if you get a transport failure then add your transports manually from the channels.conf file you have

If you get something about "Error tuning to transport", you have to add your transports manually. So go to advanced/new transport, and using your channels.conf and this awk script this will help you figure out what to add:

$ cat ~/.tzap/channels.conf | awk -F: '{ printf("%s:%s:%s:%s:%s:%s:%s:%s:%s\n", $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) }' | sort | uniq > ~/.tzap/channels.conf.uniq
$ cat channels.conf.uniq | awk -F: '{ printf("Frequency: %s\nBandwidth: %s\nInversion: %s\nConstellation: %s\nLP Coderate: %s\nHP Coderate: %s\nTrans. Mode: %s\nGuard Interval: %s\nHeirarchy: %s\n\n", $1, $3, $2, $6, $4, $5, $7, $8, $9); } ' | less

That should give u a neat listing of data to enter, once you done that hit 'Scan for channels' and choose Scan Type 'Full Scan of Existing Transports', hit Next a few times and it will begin scanning. This time you should get some action!

Enable Console Auto-Login

  1. Follow http://jamesthornton.com/linux/gazette/issue72/chung.html to compile and install an autologin script
  2. Setup to automatically startx for your mythtv user on login via your .profile or .bash_profile

Install ratpoison

Ratpoison is a great window manager, especially so for this purpose. Its based on the idea of an emacs editor (secretly I always wanted a vi-like based window manager).

So you control the window manager via key commands, rather than the mouse.

$ apt-get install ratpoison

That's it! I have a ~/.ratpoisonrc file that looks like so:

$ cat ~/.ratpoisonrc
escape C-t
alias xterm exec xterm -bg black bash
unbind c
bind c xterm
exec mythfrontend

What the above does is start mythfrontend whenever we login to x, cool hey

Install and Configure Atheros Wireless

$ apt-get install cvs make sharutils wireless-tools
$ cd /usr/src
$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/madwifi co madwifi
$ cd madwifi
$ make && make install

For some reason my modules always get install to /lib/modules/2.6.12 instead of 2.6.12-1-k7, so we need to link them to fix it (not shown here)

$ make install
$ modprobe ath_pci; modprobe ath_hal
$ dmesg | tail # check to see if it worked!

Edit the /etc/network/interfaces and configure ath0

$ ifup ath0

Change some X settings

To change the default blue background to black try this:

xvattr -a XV_COLORKEY -v 0

To turn off screen blanking try this

xset -dpms s off

List of all the NSW Frequencies for channel scanning

Get an error tuning to transport?

Following is a list of all the frequencies I've found in NSW, Australia. They are all 7Mhz.. So if you get an error like 'Error tuning to transport', add these frequencies (i.e. add new transports using advanced option in scanner) on the 7Mhz bandwidth and then do a scan of existing transports

177500000
191625000
219500000
226500000
571500000
578500000
585500000
585625000
592500000
599500000
690500000
704500000
725500000
746500000
760500000
767500000
788625000
809500000