Running Debian on a Sony Vaio PCG-V505BX

Standard Disclaimer: These notes are a work in progress, use them at your own risk ;-)

My new notes on setting up Gentoo on this machine are here - they are much more recent.

pic of the vaio

Hardware

Function Hardware Comments Status
Processor: Intel P4 2.0Ghz - Mobile Ok
RAM: 512 MB Ok
Display: 12.1in TFT; 1024x768 Nice and small! Ok
Video: ATI Radeon "Mobility" (M6 LY), 16MB Using the radeon driver Ok
Audio: Intel 82801CA/CAM AC'97 Audio Intel ICH (i8xx) Driver Works (CONFIG_SOUND_ICH) Ok
Optical: MATSHITA UJDA745 DVD/CDRW Works Great! Ok
HardDisk: HITACHI_DK23EA-40, ATA DISK drive (40GB) Ok
Ethernet: Integrated Intel Pro Works fine with driver eepro100 Ok
Wifi: Built-in LAN-Express 802.11b Works with a modified orinoco_pci driver. Thanks to Matt for the patch. Ok
Firewire: Ricoh Co Ltd R5C551 IEEE 1394 Controller A single connection on left side Untested
PCMCIA: Ricoh Co Ltd RL5c475 Use the Yenta driver Ok
USB: USB Controller: NEC Corporation USB Use the OHCI Controller Driver Ok
Media: "MagicSlot" Sony Memory Stick Reader Enable USB Mass Storage and SCSI Disk Support Ok

Installation

The machine came with WindowsXP preinstalled. I used Sony's recovery tool to burn the 7 cd's that will let you re-install Windows if anything goes awry. The 40GB Disk was partitioned into 3 parts: 8GB for windows recovery, 14GB for WindowsXP and the remaining 18GB as the 'D' disk. I decided to leave XP on the machine and use the 'D' partition to install Debian.

As there is no floppy drive, I had to use the CDROM to boot a Debian install disk. I used Jigdo to download the Debian stable (woody) install iso (woody-i386-1). This disk booted just fine; then I used the integrated ethernet card to do a network install. About 10 minutes after installation I did a dist-upgrade to unstable (to get the new gnome/kde, etc).

Configuration

The basics are in the Hardware section above, but let me detail some things below. Note, I am using kernel 2.4.21 with the relevent ACPI patch as well as a couple patches to the orinoco wifi drivers.

ACPI

ACPI is a more flexible alternative to APM and it is necessary to get some of the hardware to work. You will need to patch the kernel to get full ACPI support - and then install and use a user-land daemon. The daemon (acpid) responds to power-management events (hitting the power button, closing/opening the lid, plugging in/out the AC power cable) by running a script of your choosing. For instance, when I unplug the AC power cable, acpid runs my script to dim the LCD and set the hard drive spin down to a shorter interval.

Get the kernel patches at acpi.sourceforge.net. Configure the kernel to run ACPI (CONFIG_ACPI) and use the fan, battery, processor, button, ac and thermal modules. Add those modules to your /etc/modules file so they are started on boot-up.

My /etc/acpi/events directory has 3 files:

/etc/acpi/events/battery:

event=ac_adapter.*
action=/etc/acpi/battery 
/etc/acpi/events/lidbtn:
event=button/lid
action=/etc/acpi/lidbtn.sh
/etc/acpi/events/powerbtn:
event=button[ /]power.*
action=/etc/acpi/powerbtn.sh
My /etc/acpi directory holds the 3 scripts called by events:

/etc/acpi/battery:

#!/bin/sh

status=`sed "s/state: *//" /proc/acpi/ac_adapter/ACAD/state`

case $status in
        "on-line")
                echo "Setting HD spindown to 10"
                /sbin/hdparm -S 10 /dev/hda > /dev/null 2>&1
                /usr/bin/spicctrl -b 220
                exit 0
        ;;
        "off-line")
                echo "Setting HD spindown to 1"
                /sbin/hdparm -S 1 /dev/hda > /dev/null 2>&1
                /usr/bin/spicctrl -b 100
                exit 0
        ;;
esac
/etc/acpi/lidbtn.sh:
#!/bin/sh

# I've closed the lid.  Shutdown gracefully 
# (unless I can figure out how to sleep).

# Only shutdown if running on battery

grep discharging /proc/acpi/battery/BAT1/state
if [ $? == 0 ]; then
        /sbin/init 0
fi
/etc/acpi/powerbtn.sh:
#!/bin/sh

# Heh, I pressed the power button, so shutdown gracefully
# called from /etc/acpi/events/rules.conf

/sbin/init 0
FYI: You can run the acpid daemon in debug mode to verify it is running your scripts on the proper events.

SonyPI

Enable kernel option CONFIG_SONYPI (Sony Vaio Programmable I/O Control Device Support) as a module under the Character Devices menu. This will allow you to use the 'spicctrl' program to control the backlight of your LCD (very handy if used in conjunction with ACPI; eg. dim the LCD when you remove the AC power cable). spicctrl is available via apt-get.

Create a file called /etc/modutils/sonypi and add these lines:

alias char-major-10-250 sonypi
options sonypi minor=250
Then run update-modules. For more details, see the SonyPI Page.

Wireless

Applying the patch to the kernel sources allows the orinoco_pci driver to recognize this card.

This driver lacks of support for 'monitor' mode and scanning funtions. To see if your card supports monitoring, check the output of iwpriv for a line that says 'monitor'. Monitor mode is necessary to sniff wireless traffic via programs like kismet. Scanning can be done via "iwlist eth1 scan" and will list all the available Access Points. If you only connect to a networks with known SSIDs, ignore the next bits.

Monitoring: The newest orinoco sources 13e can be patched to add a monitor function -- which works! -- but after switching the card out of monitor mode I am unable to set the SSID and rejoin my regular wifi network. Reloading modules hermes, orinoco and orinoco_pci fixes this. But hey, kismet works! If you use the newer orinoco sources, don't forget to add the 1st patch.
Scanning: The only patch I could find to add the scanning capability was against orinoco sources 13d. Yes, this means that if you want to both scan and monitor, you will have to rmmod your modules and insmod new ones. I'm sure both patches will be in the same code someday soon.
Update: Using the patches available from http://dev.gentoo.org/~latexer/orinoco-stuff.html, I'm able to scan and monitor from the same driver! Thanks latexer!

CD-ROM

Linux finds the cdrom as "hdc: UJDA745 DVD/CDRW, ATAPI CD/DVD-ROM drive". To use this drive as a CD-R/W you need to have the following kernel setup. Also, add append="hdc=ide-scsi" to your lilo.conf

CONFIG Description State
CONFIG_BLK_DEV_IDESCSI IDE SCSI Emulation M or Y
CONFIG_BLK_DEV_IDECD IDE CDROM Support N
CONFIG_SCSI SCSI Support Y
CONFIG_CHR_DEV_SG Generic SCSI Support M or Y
CONFIG_BLK_DEV_SR SCSI CDROM Support M or Y

I compiled these drivers as modules; the modules that need to be loaded for the CDROM to work are: sr_mod, cdrom, sg, ide-scsi.

USB

Note that this machine's USB Controller uses the OHCI driver, not the UHCI driver. During boot, it will detect 3 USB ports: the 2 USB ports and the Sony Memory Stick slot ("Magic Gate").

I can mount a USB keychain drive via:

mount -t auto /dev/sdb /usbkey

Memstick

The memory stick will be detected as a scsi device if your have SCSI emulation, basic SCSI support, USB Mass Storage (CONFIG_USB_STORAGE) and SCSI Disk (CONFIG_BLK_DEV_SD) in your kernel. Note that this machine's USB Controller uses the OHCI driver not the UHCI driver. Add an entry in /etc/fstab:
/dev/sda1     /memstick    vfat     noauto,rw,user    0     0 
Then do "mount /memstick" or "mount -t vfat /dev/sda1 /memstick".

Network Profile Switching

Use QuckSwitch to flip between unique LAN and Wifi configurations (eg. Home, Work, Roaming).

XFree86

I'm using the radeon driver. My XF86Config-4 looks like such:
Section "Module"
   Load  "GLcore"
   Load  "dbe"
   Load  "ddc"
   Load  "dri"
   Load  "freetype"
   Load  "glx"
EndSection

Section "Device"
   Identifier   "Generic Video Card"
   Driver       "radeon"
EndSection

Section "Screen"
   DefaultDepth	24
   SubSection "Display"
      Depth	24
      Modes	"1024x768"
   EndSubSection
EndSection

Section "Monitor"
   Identifier  "Generic Monitor"
   HorizSync   31-50
   VertRefresh 43-75
   Option      "DPMS"
EndSection
I am unable to get GLX to work correctly unless I set the MESA_NO_3DNOW enviroment variable to Y. Then I can run glxgears or tuxracer without getting a "Illegal Instruction" error. Mesa was trying to use AMD's 3DNow! extensions (which don't exist in our hardware). Also, GLX seems a bit slow. Other people have made the same complaint ... apparently X is at fault. Update: Having upgraded to XFree86 version 4.2.1, glxgears runs a bit faster. I used to get about 220 FPS, now its around 330 FPS.

Conclusion

Overall I'm pretty pleased with this machine. It was a bit of an adventure getting a orinoco driver that recognized the card and worked properly but all's well that ends well.

Enjoy!