Soundstation: 2 - Initial setup
2a - Case is ready
So, I got the case - very nice and small. Mounting the mainboard, CD reader and the harddisk was easy.
I had some troubles connecting the internal USB cables because for each connector I had 4 wires named something like GND (ground), D+, etc... and didn't know exactly how to connect them, but after having a look at the manual of the mainboard (not included - you'll have to download it) it was no problem.
As I wasn't able to find SATA harddisks rotating at 5400 RPM I had to stick to the 7200 and decided to go for a 500GB 3.5 Hitachi. Hitachi harddisks are a little bit loud but I went for it because I personally think they're reliable - we'll see... .
Now that everything is connected, it looks like this:
2b - Installing basic software
The first open question was which filesystem I should use.
I already did some investigations some time ago by reading articles in the web, but as I couldn't come to any conclusion I decided to create 4 partitions on the same drive for the four filesystems I took into consideration (JFS, ReiserFS, XFS, ext3, all of them installed with standard options as of 2006), download the big FreeDB compressed file (~600MB) which contains a huge amount of small files (each of them contains a description of a music CD ever put on the market), unpack it once in each partition and see how much time it was taking and what was the amount of CPU that was used during that. I additionally did a copy of a 2GB file. All filesystem drivers and utilities and the kernel were compiled specifically for my machine, which was an Intel Pentium-M 2Ghz using a 5400 2.5 hard disk. Here are the results:
| Filesystem | Unpack TAR (minutes) | Unpack TAR (CPU%) | Unpack TAR (tot.allocated size on partition after unpack) | Search TAR (minutes) | Copy 2GB file (minutes) |
|---|---|---|---|---|---|
| ext3 | stopped after 240 | 10% | n/a | n/a | 2 |
| XFS | 27 | 25% | 7.6GB | 8 | 4 |
| JFS | 15 | 40% | 8.1GB | 143 | 3 |
| ReiserFS | 11 | 50% | 2.3GB | 4 | 1 |
So, even if I consider myself more a "friend" of JFS, I decided to go for ReiserFS, as yes, it uses more CPU than the others (very valuable on a 800Mhz machine), but is much much much faster. By the way, it's very interesting to see how slow ext3 was (i stopped it unpacking the TAR file on ext3 after that it was running for 4 hours) and how small the total allocated space for the files was when using ReiserFS compared to the others.
Once I had my partitions in place I installed Gentoo with a 2.6.19 Linux kernel (I installed everything from scratch using a stage3 file and re-compiling everything afterwards). As CFLAGS for the VIA SP 80000 motherboard with integrated Nehemiah processor I used...
CFLAGS="-march=i686 -msse -mmmx -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
..and until now everything is running fine. I recommend to set these flags as soon as possible and recompile everything which is already there (binutils, GCC, etc...) as soon as possible, as after this I think I noticed a big improvement in the configure and compilation times. Performance was better with -O2 than with -Os.
I had in the meanwhile the problem that the system wasn't fisically shutting down the machine after issuing the shutdown -h now command - see below for the resolution.
Ok, now that I had the operating system in place I changed in the BIOS the setting for the poweroff button (don't shutdown the machine immediately if pressed, but do it only if pressed for 4 seconds), so I could install the acpid daemon and have a nice normal shutdown when the power button was pressed, as Microsoft Windows does (if it doesn't hang during the shutdown).
As from /proc/acpi/thermal_zone/THRM/temperature I was getting a CPU temperature of -266 degrees, I activated and compiled in the kernel the module support for I2C VIA 82C586B support, the EEPROM reader and the VIA VT1211 super I/O chip (supported only from the Kernel 2.6.19 onwards).
After re-compiling and installing the kernel and rebooting I was able to install the lm_sensors package and get nice CPU and case temperature readings through the sensors executable. Now that the PC is running since a couple of hours I get temperatures of 53 for the CPU, 58 for the case and 45 degrees celsius for the harddisk (hddtemp) - hope it stays like that.
Here you'll find all basic settings for the kernel.
I additionally tought that the startup respectively the shutdown should be as fast as possible. As I don't want to fiddle around too much with the init scripts (I tried to do a startup in parallel some time ago, but it never worked fine) I decided to try to suspend the system to disk. It was very easy and it looks like it works reliably, if you don't use a touchscreen and Lirc. All you need to do is:
- go as usual to /usr/src/linux and start the graphical kernel setup with
make menuconfig. - go to Power management options => Power management support and activate Software suspend.
- below that option you should see as well Default resume partition. Press enter on it and insert the swap partition you're using (in my case it's /dev/sda2).
Yes, the place where the data will be saved will be your swap partition. The swap partition has therefore to be at least as big as the amount of physical RAM you have (as in my case). I wonder what happens when the system that is being put into suspense has all RAM used and is swapping. If you read the docs of the software suspend you'll see that there are a lot of warnings, as well for SATA disks, but I am using a SATA disk and didn't have any problems.
And now? How do you put the PC into suspend mode? Very easy: execute the following commands or put them into a small script:
echo shutdown > /sys/power/disk echo disk > /sys/power/state
This is working fine on my notebook, but unluckily when I put into suspend mode the Jukebox, the touchscreen loses calibration and Lirc has to be shutdown before trying to go into suspend mode. I didn't find any solution for this - perhaps patching the kernel with swsusp2 would work, but I didn't try it out.
One last thing: this is just a jukebox, so I don't want to have to login each time I switch it on with ID and password, so in order to automate it (auto login / login without password) I first emerge mingetty and change in the file /etc/inittab under the TERMINALS section the line that reads
c1:12345:respawn:/sbin/agetty 38400 tty1 linux
to
c1:12345:respawn:/sbin/mingetty --autologin root tty1
and voilą, after rebooting the machine you''ll be logged in automatically.
Stuff that the system has to execute after that the user is logged in (like starting up the graphical user interface) can be put in the file (create it if it doesn't exist) $HOME/.bash_profile if you're using the bash shell - if you aren't, save yourself :o)
2c - Setting up the graphical stuff
This part was very easy. I just followed the standard Gentoo instructions after adding in /etc/make.conf the string
VIDEO_CARDS="fbdev vesa via"
, changed in /etc/rc.conf to have enlightenment as window manager (have the feeling that is faster and "lighter" than Gnome or KDE)
XSESSION="enlightenment"
, emerged enlightenment (you have to set the "png" use flag otherwise enlightenment won't be able to load its graphics) and voilą, it worked.
Before emerging Mplayer and Xine I modified /etc/make.conf and inserted the additional USE-Flags "xv", "xvmc" and "lirc". The first two are apparently for the hardware accelleration provided by the graphic card and the last one is for the remote control. For lirc you'll have to insert in there as well something like
LIRC_DEVICES="hauppauge"
(I'm using a hauppauge TV card - see next) otherwise you won't have support for your remote control. The USE-Flags I am using are:
USE="X alsa apache2 -3dnow a52 aac aalib acpi bluetooth bzip2 cdparanoia cdr ch it tv_check tv_pick_cgi de_tvtoday dts dvd dvdr dvdread encode esd ffmpeg flac ftp gif gps java javascript jpeg -ldap lirc mad -matrox mime mmx mmxext mp3 mp4 mpeg musicbrainz mysql ogg opengl pcmcia png pdf qt quicktime real server sse tiff -unicode usb USB v4l v4l2 visualization -voodoo3 vorbis wifi win32codecs wmf gtk2 x264 xine xmms xv xvid xvmc xv"
When I now try to watch movies, the ones that use a xvid or divx codec run fine (~30% CPU), but the others (mpeg2, x264, mp4) have huge problems. I tried installing the graphic drivers provided by openchrome and the patches for Mplayer and Xine, but unfortunately it didn't work. Well, this is not on top of my to-do-list, so I'll have a look at it sometimes later.
As I want to be able to remotely access the machine, I emerged x11vnc and I set it up as follows:
- executed
vncpasswdand set up the passwords. You should now have the file$HOME/.vnc/passwd. - I usually put all stuff I want to start running when I start up X with enlightenment in /etc/X11/Sessions/enlightenment.
- In the enlightenment file, I put just before the command
exec /usr/bin/e16, an additional command called$STESCRIPTS/for_desktops/desktop0 &, which fires up the script desktop0. - In the desktop0 I inserted the commands
sleep 5and$STESCRIPTS/for_desktops/startmyvnc_desk0 &, which starts the script startmyvnc_desk0. - In the startmyvnc_desk0 I give the order to start the vnc with
x11vnc -rc /$STESCRIPTS/for_desktops/x11vnc_config_desk0 &. - The configuration file x11vnc_config_desk0 looks like this:
- In the enlightenment file, I put just before the command
forever rfbauth /root/.vnc/passwd display :0.0 rfbport 5900
So, all in all the scripts are executed in the following order:
- /etc/X11/Sessions/enlightenment
- $STESCRIPTS/for_desktops/desktop0
- $STESCRIPTS/for_desktops/startmyvnc_desk0
- $STESCRIPTS/for_desktops/x11vnc_config_desk0
Why all these scripts? Why not keeping everything in the same place? I did it this way because I thought it might be that I'll have to configure a second virtual screen if I want as well to watch movies - but we'll see if I manage to activate the hardware accelleration... .
I defined the variable $STESCRIPTS in /etc/env.d/99local (don't forget to run env-update after that and to log into a new session or reboot the machine, or your changes won't have any effect).
Now that we have X and enlightenment and VNC running, we can see if we can make the touchscreen working. I am using this and this guide to do it.
Go first of all into the kernel config under Device drivers => Input device support and say yes to the Event interface. Then go one level higher to the USB support and compile as module the USB Touchscreen Driver. Restart the machine and you should see with lsmod that the module usbtouchscreen has been loaded (try to load it with modprobe usbtouchscreen if you cannot see it) and that by issuing the command cat /proc/bus/input/devices you see an entry for an eGalax thing. You should see as well something like H: Handlers=mouse1 event2 - take note of the event number and make sure that it exists (e.g. ls /dev/input/event2 should return something) and if it doesn't do what the origial guide says.
Now run ./make_calibrator.txt which will compile and create the file calibrator. The drivers for X are contained in the file xf86-input-evtouch-0.8.3.tar.bz2 which you'll have to uncompress, untar, and run the usual commands ./configure, make and make install and you should get a message similar to Libraries have been installed in: /usr/local/lib/xorg/modules/input.
Now you can tell X that it should load an additional driver when starting up - insert the following lines into your /etc/X11/xorg.conf file:
Section "InputDevice"
Identifier "touchscreen"
Driver "evtouch"
Option "Device" "/dev/input/event2"
Option "DeviceName" "touchscreen"
Option "MinX" "98"
Option "MinY" "43"
Option "MaxX" "940"
Option "MaxY" "925"
Option "ReportingMode" "Raw"
Option "Emulate3Buttons"
Option "Emulate3Timeout" "50"
Option "SendCoreEvents" "On"
EndSection
Please note that I set the event number to 2, which was reported before.
Additionally, insert in the section ServerLayout the string InputDevice "touchscreen" "CorePointer", so that the driver will be loaded. Now digit the famous startx command and see what happens.
If your X is up and running we know at least that we didn't bring the system to crash. Have now a look at /var/log/Xorg.0.log (if your display is the 0) and search for the string touch. If it says something like Loading /usr/lib/xorg/modules/drivers/evtouch_drv.so everything is fine, but if it says something like
(WW) Warning, couldn't open module evtouch (II) UnloadModule: "evtouch" (EE) Failed to load module "evtouch" (module does not exist, 0)
than the files were probably installed at the wrong place (I am using the new modular X version 7.1). What I did was to search in the same file for the modules of my graphic card (via) which said Loading /usr/lib/xorg/modules/drivers/via_drv.so and copy all two files evtouch_drv.la and evtouch_drv.so from the directory where they were originally installed (in my case /usr/local/lib/xorg/modules/input) to the directory where the display driver modules are (/usr/lib/xorg/modules/drivers/) and after restarting X I got a nice...
(II) LoadModule: "evtouch"
(II) Loading /usr/lib/xorg/modules/drivers/evtouch_drv.so
(II) Module evtouch: vendor="Kenan Esau"
compiled for 4.3.99.902, module version = 0.8.3
Module class: X.Org XInput Driver
ABI class: X.Org XInput driver, version 0.6
...message.
If you now tap on the touchscreen with your fingers or a stick and move them/it, you should see that the cursor goes somewhere - of course to the wrong direction, otherwise the installation would be far too easy :o)
As I said, most probably it won't go where you want it to go as the screen hasn't been calibrated yet - and this was something that drove me crazy.
I initially ran the calibrator program that I compiled previously, but its results weren't reliable - especially on the Y-axis the movement was the opposite of what it was meant to be. If this happens as well to you, have a look at perhaps reverting the values of MinY and MaxY. Or, if moving the pen horizontally makes it move vertically and moving it vertically moves it horizontally have a look at the module options for swapping the Y axis with the X with cat /sys/module/usbtouchscreen/parameters/swap_xy and if there is a N, try to feed it with a Y with echo Y > /sys/module/usbtouchscreen/parameters/swap_xy and see if anything changes. After various attempts I'm now using for a 640x480 screen resolution the following coordinates:
Option "MinX" "72" Option "MinY" "65" Option "MaxX" "1965" Option "MaxY" "1901"
2d - Music please
It definitely makes sense for a Jukebox to be able to play music, right? Especially because the great VIA EPIA motherboard doesn't only have the normal audio connectors, but as well a digital (coaxial) S/PDIF out audio out.
The first thing to do is to have a look with lspci | grep -i audio at the name of the audio controller the motherboard is using, in my case the VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 60).
Afterwards I compiled in the kernel the support for it as described in the standard Gentoo alsa configuration guide. I compiled as module the driver snd-via82xx under Device Drivers => Sound => Advanced Linux Sound Architecture => PCI devices, installed it as the guide describes and that's it.
Now when I use mplayer to play mp3 files, I can send the output to the digital S/PDIF by issuing the command mplayer -ao alsa:device=spdif mysong.mp3, while by not entering the string -ao alsa:device=spdif the normal output is used. This might be handy in the future as I can play two different streams at the same time sending them to the two different outputs. If you have a different setup, have a look as well at the possibility I state about mplayer and the hw switch in the Linux notes page.
2e - Video in
As you can see on the picture of the interals of the case, I installed in the free PCI slot a video card - a Pinnacle PCTV 50I. That card is ideal as it's very small and doesn't occupy the space where the CDROM resides. I want to install that card to be able to read the NexTView program guide, broadcasted in the TV signal (europe only).
Have a look at this excellent guide about how to configure the Pinnacle card with saa7131 chip.
Update
It didn't work. I tried all possible tricks I knew, I read guides in the Web, but nothing - dead. The only thing I was able to do was to have nxtvepg to find the frequencies of the channels which broadcast the EPG, but nothing more than that. The most promising attempt was to load the saa7134 module with modprobe saa7134 card=77 tuner=54 but it didn't work either, so, bah, I dropped the stupid Pinnacle card and jumped a few times on it.
Second attempt
This time I'm using a Hauppauge WinTV PVR-150, which is a little bit larger than the Pinnacle one, but which still fits in the case - if it doesn't work with this one... .
So, I followed this guide to install the ivtv driver...and it worked!!! I inserted the ivtv module at the end of the /etc/modules.autoload.d/kernel-2.6, rebooted the machine, emerged and started xawtv and I can see TV with practically 0% CPU usage (perhaps because of the in-built Hauppauge MPEG encoder?).
In nxtvepg, i did an EPG provider scan, which found Kabel1, TSR1, SF1 and TV5 but at the beginning it didn't want to acquire the programs (I left the setup Acquire mode to follow browser, but did a merge of the four providers). The only solution I found was to start up nxtvepg twice - the first time it won't do a thing, the second time it will work:
nxtvepg & sleep 15 killall nxtvepg && nxtvepg
It's interesting to see that nxtvepg uses about 10% CPU while it is gathering the program guide data. Boh.
2e - And now... all together!
After restarting the PC, I tried to play a song with Mplayer and all it did was to tell me that it couldn't do something with pcm.cx88 blabla. I therefore went to the kernel configuration, deactivated the module cx88-alsa, recompiled the kernel, rebooted, and the sound was back.
Afterwards I tried the same with Amarok. No sign of life. Obviously the music wasn't being played through the digital-out connection, so I went in the menu to Settings => Configure Amarok => Engine and set all entries under ALSA Device Configuration to spdif, and the Output plugin of course to alsa.
Now I was able to hear the music, but about every 4 seconds there was a kind of hickup with a 1/2 a second interruption. So, I started XINE, went to Settings => Setup => Engine => Number of audio buffers (you'll see this entry only after setting GUI => Configuration experience level to Master of the known universe) to 500.
IMPORTANT: on my system, when skipping the track in Amarok, I used to get a message saying that Xine didn't find any available device, or that the device was busy. I solved this problem by setting Settings => Configure Amarok => Playback => Transition to no crossfading, so that no crossfading was done between songs.
After I did this, all the hickups and the error messages were gone. BUT: the touchscreen didn't work anymore!!! I can't believe it! You solve a problem, and another one just pops up! So, I gathered all the patience I had, drank a beer, did a cat /proc/bus/input/devices and guess what? The touchscreen was now using the event3 and not anymore event2 as it used to be! So, I changed the configuration in /etc/X11/xorg.conf, restarted X, and everything was back to normal.
I created in X 8 virtual displays and configured enlightenment to have Amarok on the first one, and nxtvepg on the fourth (to do this start the app, click with the right mouse button on its menu, go to remember and set what it is supposed to remember, like the desktop number, window position & size, etc...). Afterwards I modified /etc/X11/Sessions/enlightenment to have those apps started up each time - here the file as it looks now:
#![=/=]bin/sh xset s off & xset s noblank & $STESCRIPTS/for_desktops/desktop0 & $STESCRIPTS/for_desktops/nxtvepg_start & amarok & exec /usr/bin/e16
2f - Touchscreen gets lost
The fact that the event number of the touchscreen changed made me think that it could happen in the future again and again. And yes, after a few days it happened again - it changed from event3 back to 2, mmhh.
As I think that the system just picks up while booting the first event number it gets in its hands, I didn't try to solve the problem by hardcoding it somewhere in the kernel or reducing the total number to 1 (don't think it's possible to do it in an easy way), but I created some kind of workaround: set the event number dynamically in xorg.conf each time that X is started. This is what I've done:
- I created the directory /home/masterfiles/
- Copied /etc/X11/xorg.conf to /home/masterfiles/ and renamed the file to xorg.conf.master.
- Created the directory /home/shared/scripts/touchscreen and in there I wrote the script tchscreen_getevent which searches for the correct event number of the touchscreen:
#![=/=]bin/bash
#This script retrieves the event number of the touchscreen
#Change me - the place where the list of devices can be retrieved
DEVLIST=$(cat /proc/bus/input/devices)
#
#Change me - the device name
TOUCHSRCHSTR="EGALAX"
#
#Well, this shouldn't change, but you never know...
EVENTSRCHSTR="EVENT"
#Get the length of the event string
EVENTNBRCHAR=$(echo $EVENTSRCHSTR | wc -c)
EGALAXFOUND=0
EVENTNBRFOUND=0
EVENTNBR=0
#Go through each line of the list of devices you have in your system...
for LINE in $DEVLIST; do
#..search the your touchscreen...
echo $LINE | tr [a-z] [A-Z] | grep $TOUCHSRCHSTR > /dev/null
if [ $? = 0 ]
then
EGALAXFOUND=1
fi
if [ $EGALAXFOUND = 1 ]
then
#...now that I found the touchscreen, search for the line where
#the event number is mentioned...
echo $LINE | tr [a-z] [A-Z] | grep $EVENTSRCHSTR > /dev/null
if [ $? = 0 ]
then
#...and now that I found it extract the event number.
EVENTNBR=`expr substr $LINE $EVENTNBRCHAR 3`
EVENTNBRFOUND=1
#echo XXXXXXXxxEvent number is: $EVENTNBR
echo $EVENTNBR
exit 0
fi
fi
done;
if [ $EVENTNBRFOUND = 0 ]
then
#The event number wasn't found
exit 1
fi
- The script tchscreen_getevent is then called by another script I created in the same directory called tchscreen_replaceevent:
#![=/=]bin/bash
#This script replaces the event number in the xorg configuration
#Changeme - the place where the xorg.conf which is used by the X server is stored
#WILL BE OVERWRITTEN, SO YOU SHOULD BETTER FIRST TAKE A BACKUP!!!
XORGTARGET="/etc/X11/xorg.conf"
#
#Changeme - the place where you saved your master xorg.conf file - won't be changed
XORGSOURCE="/home/masterfiles/xorg.conf.master"
#
#Changeme - The identifier you placed in the master xorg.file to be swapped with
#the real event number
REPLACESTRING="TCHEVENT2REPLACE"
#
#Changeme - The place where you saved the other script
EVENTNBR=$(/home/shared/scripts/touchscreen/tchscreen_getevent)
if [ $? = 0 ]
then
cat $XORGSOURCE | sed 's/'$REPLACESTRING'/'$EVENTNBR'/g' > $XORGTARGET
if [ $? = 1 ]
then
echo ":oP Touchscreen ERROR - found the correct event number but wasn t able to write it!!!"
else
echo ":o) Touchscreen event number updated successfully."
fi
else
echo ":oP Touchscreen ERROR - didnt manage to find the correct event number!!!"
exit 1
fi
- As you can see above, I defined the string TCHEVENT2REPLACE to be the one to be replaced by the event number. Therefore, in the master xorg.conf.master I changed the event number line of the touchscreen from...
Section "InputDevice"
Identifier "touchscreen0"
Driver "evtouch"
Option "Device" "/dev/input/event3"
Section "InputDevice"
Identifier "touchscreen0"
Driver "evtouch"
Option "Device" "/dev/input/eventTCHEVENT2REPLACE"
- And finally I created in /etc/init.d/ the last script tchscreen_updevent...
#!/sbin/runscript
#Updates the event number of the touchscreen
start() {
/home/shared/scripts/touchscreen/tchscreen_replaceevent &
}
stop() {
echo ciao > /dev/null
}
rc-update add tchscreen_updevent default.Now, each time that the PC boots, the file /etc/X11/xorg.conf is overwritten by the master and the string is replaced with the correct event number.
It works.
2g - Remote control
As I don't want to stand up and go to the touchscreen each time I want to change the song or go forward with the movie I'm watching, I need a remote control, which means I have to install LIRC to be able to get the remote control events.
I tried to install it using the TV card PVR-150, but each time I started up the drivers I saw in /var/log/messages the string VIA lirc_i2c: probe 0x18 @ cx88[0]: no and the character devices in /dev/lirc/ number 0 was not created.
I didn't manage to solve this problem, so I exchanged the TV card with a PVR-350 (the card is very big, but it fit in as in the meanwhile I exchanged the 3.5 harddisk with a smaller 2.5). After this, I started up the PC and saw that nxtvepg was still working (uff... :o)) and that I didn't get any nasty error messages in the log. I configured LIRC this way:
- In /etc/make.conf I mentioned with...
LIRC_DEVICES="hauppauge"
- I emerged LIRC.
- I set up in /etc/conf.d/lircd the options as...
LIRCD_OPTS="-d /dev/lirc/0" - I downloaded a configuration file for the remote control - you can get it here - and saved it as /etc/lircd.conf.
- Rebooted the machine and checked afterwards with...
lsmod | grep lirc
modprobe -r lirc_i2c
modprobe -r lirc_dev
modprobe lirc_dev debug=1
modprobe lirc_i2c debug=1
- Started up the LIRC demon with...
/etc/init.d/lircd start - Started up irw and pushed on the buttons to see if the signal was being echoed on screen - it worked :o).
- Modified /etc/X11/Sessions/enlightenment and added the following lines...
irexec &irxevent &
Well, the hardware part and the initial configuration is now done - can't tell you how happy I am! All in all, the internals of the Silverstone case with the VIA Epia motherboard installed in it together with a Plextor Slimtray DVD reader, a 2.5 harddisk, a USB flashdrive (it's on the upper right corner - it might be that I'll use it to avoid accessing the harddisk), a PVR-350 TV card and 1GB of RAM look like this:
Chapter 1 - Theory & hardware
Chapter 2 - Initial setup <= You are here
Chapter 3 - Jukebox music setup
Chapter 4 - CPU throttling & Co.
Chapter 5 - Watch movies
Back to Soundstation main