I have spent several hours on this project and at one point I was almost ready to give up. But now when I have everything running I must say it was definitely worth it.
I have had some experience with Linux before I started this project and it helped me a lot. You don't need to be a guru on Linux to build your own HTPC, but it will be much easier with some basic knowledge. Internet is a great source to find information. Often with Linux it is very difficult to find a guide that exactly describes everything step by step. I guess that is mainly because different hardware requires different setup and it is very unlikely to find a guide that describes exactly the setup you are using. My advice is to get some hardware that others are using and that you know should work. Then if you run into trouble there will be people on the Net that can help you.
First step is to select a Linux distribution of your choice. It does not really matter so select one you feel comfortable with. For my old installation of VDR I used Fedora Core, but this time I picked Debian. Have heard a lot of good things about Debian but never tried it before so I thought it was a good opportunity to try it.
Go to http://www.debian.org follow the instructions how to download and start your installation. Easiest is probably to download a network installation CD-image, burn it and then boot the HTPC from the CD. It is a minimal CD-image with only the necessary files to start the installation, the rest of the files will be downloaded from Internet during the installation.
I decided to download the testing distribution of Debian, found here: http://www.debian.org/devel/debian-installer/.
The testing distribution includes later versions of all the software and is a better choice when installing VDR.
I am not going to go through all the steps in installing Debian. The installation is pretty much straight forward and there are lots of info to be found on Internet. When selecting the installation tasks I deselected "Desktop Environment" and only selected "Standard System". As I am using VDR with a full feature DVB card, a card with MPEG encoder and TV-out, I do not need a graphical desktop. So removing it saves both space and time to download and install.
As I downloaded a distribution on CD it did not contain the latest Linux kernel. As I wanted to use the latest possible I began with upgrading the kernel. I strongly recommend doing this as you will get a better understanding of your system and you will have the option to add and remove features from the kernel. It is possible to continue without upgrading the kernel, but later on you might need the kernel source depending on how you install the additional software.
Here is a good guide for Debian and how to upgrade the kernel.
Here is a summary of the installation and how I did it:
To compile the kernel you will need to following software installed:
To check if it is installed run dpkg -s, example: "dpkg -s gcc". If not use apt-get to download and install it.
Run this to install all software at the same time:
#apt-get install gcc kernel-package libc6-dev libncurses5-dev
Download the latest kernel source in a Debian package with apt-get:
- # apt-get install linux-source
It will download the kernel and save it in /usr/src.
Unpack it and create a symlink called linux:
- # tar -jxf linux-source-2.6.18.tar.bz2
- # ln -s linux-2.6.18 linux
- # cd linux
All configuration parameters for the kernel are saved in a file called .config located in /usr/src/linux. With a new kernel source this file does not exist. It is possible to use an old config file from a previous kernel. Just copy that file to /usr/src/linux. I ran this to copy the configuration file that came with the distribution:
# cp /boot/config-2.6.7-2-486 .config
As this configuration file was create for an older kernel it is missing information about all the new features in the new kernel. It is necessary to run the following command to add all new features to the configuration file:
# make oldconfig
You will be asked questions if the new features shall be enabled or not. If you do not have an idea it is pretty safe to just press enter and leave the default answer.
Next step is to start configuring the kernel. Run:
# make menuconfig
Now comes the fun part to configure every single option of the Kernel. Basic rule is to leave everything as it is if you do not know what it is:
- Remove DVB support but add video 4 linux
- Add support for "Module unloading"
- Add support for USB. I needed uhci-hcd in my HTPC. Check by running:
# lspci -v | grep HCI
It should either return UHCI USB or OHCI USB. Depending on your result select either uhci-hcd or ohci-hcd in the kernel configuration.
- Add support for ACPI.
- When you are done select exit and save the config.
- # make-kpkg clean
- # make-kpkg --append-to-version=.060717 kernel_image
- # cd ..
- # dpkg -i kernel-image-184.108.40.206.060717_10.00.Custom_i386.deb
For me the initrd image has never been created automatically so I needed to create it with mkinitrd. mkinitrd was not installed so I had to run the following to install it:
- # apt-get install initrd-tools
Then run the following to create the image:
- # mkinitrd -o /boot/initrd.img-220.127.116.11.060717 /lib/modules/18.104.22.168.060717
After the image is created you have to update the boot menu. Run:
- # update-grub
Please refer to the Kernel installation guide for more detailed instruction.
General Linux configuration:
In addition to the ACPI support in the kernel the deamon "acpid" need to be installed to trigger events, ie. when pressing the power button.
- apt-get install acpid
- Set ACPI in BIOS to S3(STR).
- Suspend is now working: echo mem > /sys/power/state
It works fine but I need to have the script below to reload some drivers.
I have chosen to leave the DVB drivers outside of the kernel and compile them separately. The DVB drivers can be found at http://www.linuxtv.org. You need to have "mercurial" installed to download the latest source. Follow instructions on http://www.linuxtv.org/repo/. On my installation I had to update libc6. But before I could do that I had to remove initrd-tools as it was causing a conflict with libc6.
To install I did the following:
- hg clone http://linuxtv.org/hg/v4l-dvb
to download the DVB source tree.
- ln -s v4l-dvb DVB
to create the DVB symlink.
- Follow the instructions in INSTALL in the DVB directory. Basically:
- make all
- make install
Depending on your card you need to load different modules. Run "modprobe module-name" for each module. List of modules to load for my cards can be found in the runvdr script listed at the bottom.
- Put firmware for DVB card in /usr/lib/hotplug/firmware/
- Change name to: dvb-ttpci-01.fw
If you do not know what LIRC is have a look at http://www.lirc.org. LIRC is the software in your HTPC which interprets the the IR signal from your remote control. The HTPC also needs a IR receiver. It is this device LIRC is controlling. I am using both remote and IR receiver that was shipped with my Technisat DVB card.
- Go to http://www.lirc.org and download the source code.
I used the latest, which was lirc-0.8.0.
- Intallation instructions: http://www.lirc.org/html/install.html
- Unpack in /usr/src.
- Create symlink: ln -s lirc-0.8.0 lirc
- Run ./setup.sh
- In "Driver configuration" I selected a home-brewed serial device, connected to COM1. The rest I left standard.
- In "Software configuration" I removed X-windows and selected only "Use syslogd".
- Select "Save configuration & run configure".
- Run make & make install.
If you upgrade your kernel you have to run make distclean and then redo from ./setup.sh
Now we will test that everything is working. For LIRC to work you need to have the module lirc_serial loaded and the lircd deamon running. Below I will use two programs called mode2 and irw. I used "apt-get install" to install them.
- Load the module for LIRC: modprobe lirc_serial.
- Run: mode2 and press any keys on your remote. Some output like "pulse 108, space 4969" will be shown. mode2 is a program to test the signal from the remote.
- For lircd to work you need to have a config file for your remote. You can either search for your remote here: http://lirc.sourceforge.net/remotes/ or record your own config file with the program irrecord.
- Store the config file as /etc/lircd.conf
- Start lircd and run the program irw to test the remote.
Most likely you will get an error when accessing the serial port and you have to run:
setserial /dev/ttyS0 uart none
This is because the serial port driver is loaded and is occupying all the serial ports. Running the setserial command will free the port. Another option is to load the lirc_serial module before the serial port driver module, but that requires that the serial driver is configured in the kernel as a module. I use the setserial command myself and I run it in my start script for VDR before I load the lirc_serial module.
# runvdr: Loads the DVB driver and runs VDR
VDRCMD="$VDRPRG -Pmplayer -Pmp3 -Pfemon -Posdteletext -s vdrshut.sh -w 60 $*"
KILL="/usr/bin/killall -q -TERM"
setserial /dev/ttyS0 uart none
/usr/local/sbin/lircd -d /dev/lirc0
# Detect whether the DVB driver is already loaded
# and return 0 if it *is* loaded, 1 if not:
if lsmod | grep 'dvb_ttpci' > /dev/null ; then
# Load all DVB driver modules needed for your hardware:
# Unload all DVB driver modules loaded in LoadDriver():
modprobe -r dvb_ttpci
modprobe -r b2c2-flexcop-pci
modprobe -r mt352
# Load driver if it hasn't been loaded already:
if ! DriverLoaded; then
while (true) do
if test $? -eq 0 -o $? -eq 2; then exit; fi
echo "`date` reloading DVB driver"
echo "`date` restarting VDR"
# Initiates a shutdown when the power putton has been
killall -9 runvdr
killall -9 vdr
modprobe -r uhci-hcd
modprobe -r lirc-serial
modprobe -r i2c-core
modprobe -r dvb_ttpci
modprobe -r b2c2-flexcop-pci
modprobe -r mt352
echo mem > /sys/power/state
runvdr --terminal=/dev/tty10 -w 60 &
|< Prev||Next >|