One of my pet projects is a media center computer. I have since upgraded to a new system, but I will leave the following for posterity. See my new config at the System76 Wiki.
The goal is transparent technology, something that is integrated into the living space, not something that looks like a tangled mess of wires or a dilapidated computer lab. ;)
The system is a Linux DVR / PVR / HTPC, scheduled tv recorder, audio/video file and DVD playback unit w/ infrared remote control, FM radio receiver, wireless access point and Internet gateway that firewalls the internal network, file server, RSS viewer, weather display and a dedicated peer-to-peer client host.
The operating systems of choice is DebianLinux.
I've been happy with Verizon DSL, which is 1.5/384 PPP over Ethernet (PPPoE).
The connection was up and running a week after I called to subscribe, having to wait on the modem to be shipped. When the package first arrived, I had to use the Verizon installation CD-ROM on a Windows machine to initially set up my account with their flash-bassed installer.
# apt-get install pppoe
/etc/ppp/peers/dsl-provider:
pty "/usr/sbin/pppoe -I eth0 -T 80 -m 1452" noipdefault defaultroute lcp-echo-interval 20 lcp-echo-failure 3 connect /bin/true noauth persist mtu 1492 default-asyncmap hide-password mru 1492 noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp usepeerdns user INSERTUSERNAME
/etc/ppp/pap-secrets:
USERNAMEHERE * PASSWORDHERE
The Host AP wireless access point driver works perfectly with a NetGear MA311 card. I am bridging one of the wired ethernet cards with the wireless one. Currently using hostap compiled from the source tarball, but it is also available as a package.
# apt-get install bridge-utils
Enable ethernet bridging under your kernel networking options.
/etc/network/interfaces:
auto br0
iface br0 inet static
bridge_ports wlan0 eth1
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
pre-up iwconfig wlan0 essid MYBASE
pre-up iwconfig wlan0 channel 2
pre-up iwconfig wlan0 mode Master
pre-up iwconfig wlan0 key s:MYKEY
pre-up prism2_param wlan0 ap_bridge_packets 0
pre-up prism2_param wlan0 beacon_int 1000
Flashing your Intersil Prism chipset card to a newer version may help with performance and configurability. I was able to upgrade my Netgear MA311 card to v1.7.4:
# prism2_srec -v -f wlan0 pk010101.hex sf010704.hex
DHCP is enabled on br0.
# apt-get install dhcp
/etc/dhcpd.conf:
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name-servers 151.201.0.39, 151.197.0.39;
option time-offset -18000; # Eastern Standard Time
default-lease-time 600;
max-lease-time 7200;
host laptop {
hardware ethernet 02:05:2F:6D:95:G7;
fixed-address 192.168.1.2;
}
range dynamic-bootp 192.168.1.3 192.168.1.254;
}
If you get a "No subnet declaration for wlan0 (0.0.0.0)" in syslog when you start the dhcp server, then make sure to specify the interface.
/etc/default/dhcp:
INTERFACES="br0"
Configuring a firewall is easy with the firestarter package, or others.
# apt-get install firestarter
Then run firestarter and step through the wizard.
On wireless Debian Linux clients, run the following:
# iwconfig eth1 key s:YOURKEYHERE # dhclient eth1
On wireless Windows clients, under the 'Network Connctions' 'Control Panel', open your 'Wireless Network Connection', select your 'Wireless Networks' and enter the network key.
DynDNS.org provides free dynamic DNS updates, so that every time your PPP connection reconnects, you can still have a working hostname. I use the ipcheck package to auto-update on connect.
# apt-get install ipcheck # mkdir /var/lib/ipcheck # ipcheck --makedat -d /var/lib/ipcheck -i ppp0 username password hostname.dyndns.org
/etc/ppp/ip-up.d/dyndns:
#!/bin/sh /usr/sbin/ipcheck -d /var/lib/ipcheck -l -i ppp0 username password hostname.dyndns.org
# chmod +x /etc/ppp/ip-up.d/dyndns
The Matrox Millenium G400 video card works well under Linux, with high quality tv-out. Subtitles and fine detail are very easy to view.
enable I2C support, including bit-banger, in the kernel config
enable matrox framebuffer support
enable mtrr
# apt-get install matrox-tools fbset
enable tv-out on second head:
# matroxset -f /dev/fb1 -m 0 # this disconnects fb1 from outputs # matroxset -f /dev/fb0 -m 3 # this connects fb0 to both outputs # matroxset -f /dev/fb0 -o 1 2 # this sets fb0 to NTSC output # fbset -fb /dev/fb0 -xres 800 -yres 600 # set to 800x600 resolution
/etc/X11/XF86Config-4:
<snip>
Load "v4l" # Video4Linux
<snip>
Driver "mga"
Option "hw cursor" "off"
Option "UseFBDev" "on"
<snip>
DefaultDepth 16
DefaultFbBPP 16
SubSection "Display"
Depth 16
Modes "800x600"
EndSubSection
<snip>
fine tune with fbset to center display, start with left edge, incrementing up:
# fbset -left 10then:
# fbset -right 10and etc to get something like:
# fbset -fb /dev/fb0 -left 40 -right 26 -lower 32 -upper 80 -hslen 20
once tweaked to fill tv screen without a squirrelly monitor, get a modeline to insert into the /etc/X11/XFree86-4 config under the Monitor section:
# fbset -x
tweak contrast, saturation, hue and brightness:
# matrox 0x1e 0xd0 # #matrox 0x20 0xff # #matrox 0x22 0xff
and place setup commands in your init script /etc/init.d/g400:
#!/bin/sh # reset framebuffer matroxset -f /dev/fb0 -m 0 matroxset -f /dev/fb1 -m 0 matroxset -f /dev/fb0 -m 1 matroxset -f /dev/fb0 -o 0 128 fbset -fb /dev/fb0 640x480-60 # set up 800x600 w/ NTSC tv-out matroxset -f /dev/fb1 -m 0 matroxset -f /dev/fb0 -m 3 matroxset -f /dev/fb0 -o 1 2 fbset -fb /dev/fb0 -xres 800 -yres 600
# chmod +x /etc/init.d/g400 # cd /etc/rc2.d # ln -s ../init.d/g400 S99g400
This displays xvideo playback only on the CRT and not TV out in clone mode, but is good for dual-head monitors! The above framebuffer setup is what should be used for tv-out.
download Matrox binary drivers mga.o & mga_hal.o:
copy them to /usr/X11R6/lib/modules/drivers/
# apt-get install mgapdesk
startxand run
mgapdeskto config, and then restart X
The main use of the burner will be for system backups and to archive large video files. An IDE drive must be used through SCSI emulation for the burner software to work.
enable ide-scsi emulation, ide-cdrom, scsi-cdrom and scsi-generic support in the kernel as modules. My burner is the second ide drive, hdb, which becomes sr0 after scsi emulation.
add ide-scsi to /etc/modules
create /etc/modutils/burner:
options ide-cd ignore=hdb pre-install sg modprobe ide-scsi pre-install sr_mod modprobe ide-scsi pre-install ide-scsi modprobe ide-cd
# update-modules # apt-get install dvd+rw-tools cdrecord mkisofs cdrtools-doc # reboot
check that your through-put to/from your burner is fast enough for the process, enable dma on IDE drives:
# hdparm -u1 -c3 -d1 /dev/hdb
create and iso image and burn a data CD-R:
# mkisofs -J -joliet-long -r -o cd_image.iso -V MyCD /some/files/ /more/files/ # cdrecord -sao -overburn dev=0,0,0 speed=8 driveropts=burnfree -vvvv cd_image.iso
download and install the latest cdrecord-ProDVD in /usr/local/bin/:
make an iso image and burn directly to a data DVD+R/DVD-R:
# growisofs -speed=2 -Z /dev/sr0 -r -J -joliet-long -V MyDVD /some/files/ # growisofs -speed=2 -M /dev/sr0 -r -J -joliet-long /more/files/
firmware updates and flashing utility for Linux:
# ./DVRFlash -vf /dev/sg0 R5100004.133 R5100104.133
DVD recordable media support info for Pioneer drives
DVD format info and statistics
NIST Care and Handling of CDs and DVDs
Freevo does the job, handling media playback with Mplayer & Xine. It loads at boot with rungetty.
An apt source for freevo and mplayer is now available. Add these lines to your /etc/apt/sources.list:
deb http://freevo.sourceforge.net/debian unstable main deb ftp://ftp.nerim.net/debian-marillat/ unstable main
Then run:
# apt-get update # apt-get install mplayer-686 mencoder-686 mplayer-fonts w32codecs libdvdcss2 xine-ui # apt-get install freevo unclutter rungetty
Freevo can start up automatically by using rungetty. This can also be done on redhat with the "open" package. In runlevel 2, I remove the getty login from tty1 and replace it with and automatic rungetty login of the freevo user:
/etc/inittab:
<snip> 1:345:respawn:/sbin/getty 38400 tty1 2:23:respawn:/sbin/getty 38400 tty2 3:23:respawn:/sbin/getty 38400 tty3 4:23:respawn:/sbin/getty 38400 tty4 5:23:respawn:/sbin/getty 38400 tty5 6:23:respawn:/sbin/getty 38400 tty6 r1:2:respawn:/sbin/rungetty tty1 --autologin freevo <snip>
When freevo logs in on tty1, X is started and freevo launches.
~freevo/.bash_profile:
<snip>
if [ "$TERM" = "linux" -a `tty` = "/dev/tty1" ]; then
/usr/bin/X11/startx ; exit
fi
~freevo/.xsession:
#!/bin/sh # turn off screen blanking /usr/bin/X11/xset s off /usr/bin/X11/xset -dpms # hide mouse cursor and set background /usr/bin/unclutter -root -idle 1 & /usr/bin/X11/xsetroot -solid "#999999" & # allow local user access to display /usr/bin/X11/xhost +local: # adjust size and centering of framebuffer #/usr/sbin/fbset -fb /dev/fb0 -left 42 -right 26 -lower 32 -upper 80 -hslen 40 # adjust contrast, saturation, hue and brightness of the g400 /usr/sbin/matrox 0x1e 0xd0 #/usr/sbin/matrox 0x20 0xff #/usr/sbin/matrox 0x22 0xff # showtime #xterm #esd -as 1 -tcp -public & freevo
LIRC and an Irman infrared receiver provides remote control capabilities.
# apt-get install lirc
set your hardware type and device in /etc/lirc/hardware.conf:
<snip> DRIVER="irman" DEVICE="/dev/ttyS0" <snip>
make a config file for lirc:
# cd /etc/lirc # /etc/init.d/lirc stop # irrecord -H irman -d /dev/ttyS0 lircd.conf # /etc/init.d/lirc start
you can then see the commands when pushing remote buttons:
# irw
make an lirc config in /etc/freevo/lircrc mapping buttons to freevo commands, Eg:
begin
prog = freevo
button = vsh_up
config = CH+
repeat = 2
end
you can then see the mapped freevo commands when you press buttons:
# ircat --config=/etc/freevo/lircrc freevo
needed commands:
LEFT, RIGHT, UP, DOWN, SELECT, ENTER, EXIT, DISPLAY, REC, REW, PLAY,
FFWD, PAUSE, STOP, CH+, CH-, VOL+, VOL-
grip, a GUI for lame, is the best for ripping CDs to MP3.
dvd:rip, a GUI for transcode, is the best for converting your DVDs to AVIs.
I like to download files with bittorrent, but it can flood an adsl connection, choking outgoing connections. Shaping the bandwidth to around 70-80% of maximum will lower latency and fixes this. The Wonder Shaper is an easy to use traffic shapping script.
# wondershaper ppp0 1228 307
Traffic shapping reduced a test round trip time during network load from an average of 972.611 ms to under 88.570 ms.
Using trickle as a normal user is another option to do bandwidth shaping.
$ btdownloadcurses --max_upload_rate 36 --max_uploads 4 whatever.torrent
Original BitTorrent or TheSHAD0W's Experimental BitTorrent Client - BitTornado
mldonkey multi-network peer2peer client