WordHord

Linux on the Sony Vaio FR415B

I bought a Sony Vaio laptop which came with Windows XP pre-installed. I have wanted a Linux based laptop for some time. XP had to go. This is my first experience of installing Linux on a laptop. I used Gentoo Linux 2004.1, kernel version 2.6.5. I've recorded the process here to try and save others from the trouble I had. I later upgraded to version 2.6.7.


The basic spec of the machine is as follows:

I also took the opportunity of upgrading the hard-drive from 40Gb to 60Gb. The cheapest drive I could find was 60GB Fujitsu 2.5" IDE 4200rpm Notebook Hard Drive (MHT2060AT).


The output of lspci is as follows:

0000:00:00.0 Host bridge: ATI Technologies Inc: Unknown device cbb2 (rev 02) 0000:00:01.0 PCI bridge: ATI Technologies Inc PCI Bridge [IGP 340M] 0000:00:03.0 Modem: ALi Corporation M5457 AC'97 Modem Controller 0000:00:04.0 Multimedia audio controller: ALi Corporation M5451 PCI AC-Link Controller Audio Device (rev 02) 0000:00:06.0 Bridge: ALi Corporation M7101 PMU 0000:00:07.0 ISA bridge: ALi Corporation M1533 PCI to ISA Bridge [Aladdin IV] 0000:00:0a.0 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev aa) 0000:00:0a.1 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev aa) 0000:00:0a.2 FireWire (IEEE 1394): Ricoh Co Ltd R5C552 IEEE 1394 Controller (rev 02) 0000:00:0c.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 50) 0000:00:0c.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 50) 0000:00:0c.2 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 51) 0000:00:0f.0 IDE interface: ALi Corporation M5229 IDE (rev c4) 0000:00:12.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10) 0000:01:05.0 VGA compatible controller: ATI Technologies Inc Radeon IGP 340M

I made a Gentoo Live CD and booted the laptop. This worked fine. The network worked and configured correctly via DHCP. The graphics card and mouse worked fine.

I followed the Gentoo install instructions and built a 2.6.5 kernel. I did an emerge gentoo-dev-sources to get the kernel source.


Grub

grub.conf file as follows:

default 0 timeout 30 splashimage=(hd0,0)/grub/splash.xpm.gz # Main boot title=Gentoo Linux 2.6.5 root (hd0,0) kernel /kernel-2.6.5-gentoo root=/dev/hda3 vga=791


Video

I initially had some problems with the video display. When the machine booted the active video area was a 640x480 box in the middle of the screen. To fix this enable:

Device drivers --> Graphics support --> Console display driver support <*> Framebuffer console support

and add the vga=791 line to the grub kernel line. The monitor output socket works fine. I have not tried the TV out.


Audio

The soundcard works out of the box with the 2.6 kernel installation. Use the trident drivers. After I added the hotplug driver, and the video hardware was therefore getting detected by the PCI code, I had to modify /etc/init.d/alsasound so that the hotplug code was run first, otherwise alsa cannot find the drivers. Add the following to the depend() function:

after hotplug


PCMCIA / CardBus slots and WiFi

I had considerable difficulty getting this working, partly because I needed it to work with a Belkin 802.11g WiFi card, which has a Broadcom chipset unsupported by Linux. I was new to most of this when I started, and the learning curve was painful. When I plugged the card into a Windows XP machine I had it working within a couple of minutes. It took me several days to get it working under Linux. If manufacturers provided proper Linux drivers with their products the situation would be improved.

Initialy I was confused by the fact that the PCMCIA drivers couldn't detect the card, although a 16-bit Xircom ethernet adapter that I tried showed up okay. It turned out that PCMCIA is a 16-bit only standard, and CardBus (32-bit) cards are handled by the hotplug driver, not the PCMCIA code. I only discovered this after placing printk statements in the PCMCIA drivers to see what was going on. I installed the hotplug driver and added it as a service using rc-update.

I copied the /etc/init.d/net.eth0 file to /etc/init.d/net.wlan0 so that the driver would have some config code to run when it started the card.

As there are no Linux drivers for my card, I tried installing ndiswrapper-0.8- rc2 from here and built it manually. Gentoo's ndiswrapper-0.3 is blocked in the portage.

Ndiswrapper is a project to provide a driver that can use native windows binary drivers and provide the interface code to allow them to be called from Linux. It gets around the problems caused by card manufacturers failing to provide Linux drivers for their products. Hopefully this project will not be required in the future, but credit must be given to the people who developed this useful driver. I copied across the driver and .inf files from a windows machine and used ndsiwrapper to install them. This appeared to work okay. However, nothing happened when I plugged in the card other than the power LED coming on.

The Broadcom card showed up in lspci, so I was able to determine the 32-bit identifier used by hotplug to select the correct driver software. The file /lib/modules/2.6.5-gentoo-r1/modules.pcimap contains a series of mappings of card ids to drivers. I felt that this file (created by depmod) should have an entry for my card in it. By manually editing the file, adding a line associating the ndiswrapper driver with the card id, I was able to get the driver to load when the card was inserted. But still no life.

I then discovered that the .inf file I had copied over from my windows machine was a unicode file. This was a stupid mistake on my part, but it is a shame that the ndiswrapper code didn't warn me about this when I first tried to install the drivers. It is clearly there in the documentation, but it would not take much to detect invalid inf files. I copied across the ascii version instead, then uninstalled and re- installed the windows driver. I built ndiswrapper with debug enabled. Watching the output of dmesg, I saw that when the module was loaded it added a series of card-id - driver associations to the PCI map. This performed the same function as my manual edits of the pcimap file. Therefore simply by loading the module at boot time, the PCI map would be set-up, allowing hotplug to associate the ndiswrapper driver with my card. So, I added ndiswrapper to /etc/modules.autoload/kernel-2.6 and rebooted. Bingo; the card was detected and the driver loaded.

Well, the light came on, and cardctl ident now showed the card as being present. I then added a function to net.wlan0 to handle the connection and configuration of the card. This created further problems.

preup() { einfo "configuring ${IFACE} interface" MATCH_ESSID="\"${wireless_essid}\"" for count in 1 2 3 4 5 do ESSID="`iwgetid ${IFACE} | sed s/.*ESSID://g`" einfo $ESSID "-" $MATCH_ESSID if [[ $ESSID = $MATCH_ESSID ]]; then einfo "Connected to station ${wireless_essid}" return 0 fi iwconfig ${IFACE} mode ${wireless_mode} iwconfig ${IFACE} key ${wireless_key} iwconfig ${IFACE} essid ${wireless_essid} sleep 0.5 done eerror "Failed to connect to station ${wireless_essid}" return 1 }

Note: This code will only connect to a named station. Setting wireless_essid to "any" will not work, as iwgetid will return the actual station name, not "any", so the match will fail. I will post some better code when I have to solve the problem. Suggestions welcome.

You can find the available station names with:

iwlist wlan0 scanning

I also added the following parameters to /etc/conf.d/net:

iface_wlan0="dhcp" wireless_essid="your station name here" wireless_mode="Managed" wireless_key="open"

I discovered that the iwconfig wlan0 essid XXX command didn't always seems to work. Having experimented with this for a while I realised that iwgetid did not return the required station id until the card had finished connecting to the access point. If the access point was not available then this would never happen, and the command would fail. I wanted to use DHCP to configure the card, and obviously this also requires the card to be connected to the AP. The code therefore makes several attempts to connect to the AP, checking the status with the iwgetid command.

I can now boot the laptop and the card will get detected, the driver loaded, preup() is called, the card initialised with the correct configuration, wait until the AP connects and then start the DHCP client. This all works fine. It also works when you plug in or unplug the card.

I couldn't get the WEP encryption to work and don't know why. I'm not too bothered about this, as WEP is a weak standard and should not be relied on to provide security. Any sensitive communication across the network should be encryted using ssh, or some other secure method. See network security for suggestions on how to secure your network.

ethernet eth0 problems

One remaining problem is the built-in eth0 port. This was working fine until I started work on the WiFi connection, but then I had problems. When I had the eth0 port unplugged on boot, the DHCP client takes 60 seconds to time out. I decided to set a static IP address for the interface, to prevent the DHCP client from being used. This is done by editing /etc/conf.d/net:

#iface_eth0="dhcp" iface_eth0="<a.b.c.d> broadcast <a.b.c.255> netmask 255.255.255.0" gateway="eth0/<gateway-ip-addr>"

Substituting the desired ip address and gateway. I then ran into a routing problem. netstat -rn gave the folowing output:

Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0 127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0

This results in local subnet traffic being sent via the (unplugged) eth0 interface. So I could ping an ip address on the internet over the WiFi connection, but subnet traffic all failed.

The root cause of this is that the eth0 interface says it is up when it is not.

The solution to this is ifplugd, a daemon which monitors the status of the [eth0] interface, and calls start / stop when the cable is plugged or unplugged. This will cause the routing table to be set up to include only those interfaces which are active.


DVD player

The DVD player worked straight away, but did not play DVDs fast enough - the pictures were jerky and disjointed. I made several changes to get this to work. I was using mplayer to play DVDs.

I had to create the following symbolic link:

ln -s /dev/hdc /dev/dvd

Add the USE flags mmx and sse to /etc/make.conf. I had to re-build mplayer and libmpeg2 after changing the USE flags so that they would make use of the processor extensions. This made a big difference to the speed at which the software ran.

The hard-drive and DVD drive settings can be optimised via the hdparm command. The hdparm settings can be included in /etc/conf.d/hdparm. I simply added the following line to this file:

all_args="-d1 -c3 -m16 -X66"

The flags are as follows:

The all_args parameter applies these settings to both the hard-drive and the DVD drive. Those that are not applicable are simply ignored. This gives around a 2x speed-up in data transfer times for both the hard-drive and DVD. To apply these settings at boot time, start the hdparm daemon as follows:

rc-update add hdparm default

The combined effect of these changes allowed DVDs to be played in real-time without any problems.

To play:

mplayer dvd://1

To eject:

eject /dev/dvd


CD writer

The 2.6 kernel removes the need for SCSI emulation to talk to CD writers. The drive's parameters can be seen with:

cdrecord dev=ATAPI -scanbus

Which showed me that the writer's bus parameters are 0,0,0 so the burn command is

cdrecord dev=ATAPI:0,0,0 -v speed=12 -data filename.iso


Desktop

I installed kde as my desktop. To get the video card working correctly I used the notes here on setting up the XF86Config file.


USB

Needs the usb-ohci drivers. I managed to get my camera communicating fine using gphoto2.

I've also tested this with a USB card reader and it seems to work fine.


Modem

Work in progress. Some success, but still not working.

The internal Modem shows up on lspci as an ALi Corporation M5457 AC'97, with device id 10b9:5457 subsystem 104d:8158. A bit of research showed that this is a Conexant HSF modem (softmodem). The only drivers I could find are the commercial drivers from Linuxant.

I downloaded the free version and installed it without trouble. The free version is bandwidth limited and lacks voice modem capabilities. I then started up minicom to see how the modem responded:

at+GMI +GMI: CONEXANT OK at+GMR +GMR: RC56OCTOPUS R0000 V0.1 9/2/99 OK

So I thought I had a working modem. However, when I next rebooted the laptop, it hung during the boot sequence, where the hotplug driver loads the pci drivers. Through trial and error, using a Knoppix Live CD, I found that removing (renaming) the kernel module /lib/modules/<version>/misc/hsfserial.ko allowed the kernel to boot correctly.

I still have no idea why the modem hangs on boot. I have uninstalled the linuxant driver. If anyone has any idea why this happens, please let me know.


Touchpad

This took me a long time to sort out. Out of the box the touchpad worked perfectly well as a PS/2 mouse, except it used to stall for the first few seconds after running X. But it left out some useful features, particularly the ability to vertical scroll using the right hand side of the touchpad area.

There is a synaptics driver available, which provides this functionality in X. You also need to ensure that certain kernel options are set. This is available in the gentoo portage, but it is worth looking at the documentation too:

Synaptics X driver

You will also need the evdev driver, which creates /dev/input/eventX devices.

I had a problem emerging the synaptics X driver. emerge -p synaptics showed that it wanted to build xorg-x11. I'm using XFree86 and definately didn't want to build xorg-x11. It turned out that emerge knew that my XFree86 version was out of date, so ignored it in favour of xorg-x11. The solution was to upgrade to the latest version of XFree86 and then emerge synaptics - which then did not think that it needed xorg-x11.

The kernel contains the mouse detection and driver code. To see what input devices your kernel thinks you have enter this command:

cat /proc/bus/input/devices

And you should see a list of devices and the event devices they report on. Mine had 3: PS/2 Mouse on event0, Keyboard on event1 and JogDial on event2. This VAIO does not have a jog dial, so I'm not sure why it appears. But the kernel clearly thought that I had a PS/2 mouse rather than a touchpad.

To see if the mouse is working you can cat the event device thus:

cat /dev/input/event0 | hexdump

And you should see a stream of data when you touch the mouse. Note: this must be done in a console, not in X.

The problem with the VAIO is that it does not have a synaptics touchpad, it has an ALPS one. The kernel's synaptics detection code fails, because the hardware responds differently. There are some kernel patches that allow for the detection of an ALPS touchpad, but I had some problems with these.

I emerged the gentoo synaptics X driver, which includes an alps.patch to apply to the kernel. Sadly, when I tried to apply the patch, it failed. The source code in my kernel tree did not match that expected by the patch. I then upgraded my kernel source from 2.6.5 to the latest 2.6.7 by doing an emerge gentoo-dev-sources. I could then apply the patch and reboot.

Note: I had a slight problem here. When I build the kernel I also have to rebuild the ndiswrapper drivers. These use uname -a to determine the kernel version to build against. If you are building a new kernel version, they will build against the old kernel and will therefore fail to load. You can fix this by booting into the new kernel and then rebuilding ndiswrapper.

Sadly the patch did not seem to do anything. cat /proc/bus/input/devices still reported a PS/2 mouse. I looked through the mouse driver source and couldn't find an alps_detect() function being called anywhere. It appeared that the patch was not working because it made no attempt to detect the ALPS hardware.

I then downloaded the latest synaptics X driver (version 0.13.4); not to build it, but to use it's accompanying alps.patch. When I applied this patch to the 2.6.7 tree and rebuilt the kernel, the mouse was correctly reported as an ALPS touchpad.

I conclude from all this that the ALPS touchpad support is still unstable and under development in the 2.6 tree.

I could then make the recommended changes to the XF86Config file, that allowed the synaptics X driver to provide the extra functionality available with the touchpad. Follow the instructions with the synaptics driver documentation, but use the following input definition:

Section "InputDevice" Identifier "Synaptics Mouse" Driver "synaptics" Option "Device" "/dev/psaux" Option "Protocol" "auto-dev" Option "LeftEdge" "120" Option "RightEdge" "830" Option "TopEdge" "120" Option "BottomEdge" "650" Option "FingerLow" "14" Option "FingerHigh" "15" Option "MaxTapTime" "180" Option "MaxTapMove" "110" Option "VertScrollDelta" "20" Option "MinSpeed" "0.2" Option "MaxSpeed" "0.5" Option "AccelFactor" "0.01" Option "EdgeMotionMinSpeed" "15" Option "EdgeMotionMaxSpeed" "15" Option "UpDownScrolling" "1" EndSection

So, a lot of hard work later, and I have a working touchpad.


ToDo


Configuration files etc.

The important configuration files are here:

The output of dmesg:


Links