Tuesday, November 15, 2005

Linux tips: Recompiling Kernel 2.6.14.2 to enable DMA support in SIS 5513 IDE controller in AsRock 939S56M motherboard

On the very same day I successfully installed my first linux kernel 2.6.14.1. I notice from kernel.org that 2.6.14.2 is released. Another 2 days later, Fedora Core 4's live update is ready to update kernel to 2.6.14 while strangely Fedora Core 3's live update is still stuck at 2.6.12.

Nevertheless, that does not warrant a recompile of my kernel from 2.6.14.1 to 2.6.14.2. However the info from this thread here actually prompted me to do so.

Basically, the device ID of the SIS 5513 IDE controller is not identified correctly. And it rendered the kernel to turn off the DMA support for the harddisk.

To check the kernel boot log, I did the following.

vi /var/log/dmesg

It indeed reveal that the detection of the SIS 5513 IDE controller returned a -1. And from the very same thread, user sinthetek found that the problem can very well be fixed by adding the following entry in /usr/src/linux-2.6.14.2/drivers/ide/pci/sis5513.c

{ "SiS5513", PCI_DEVICE_ID_SI_5513, ATA_100 },

It was added right after the entry

{ "SiS551x", PCI_DEVICE_ID_SI_5511, ATA_16 },

Seemingly, the 'SIS551x' isn't the same reference for the SIS5513 controller.

Since I need to recompile the kernel to include the SIS5513 support, I downloaded the latest 2.6.14.2 kernel & made the modification above in sis5513.c & had the kernel recompiled.

Upon rebooting & from /var/log/dmesg, now I can see my sSIS5513 is DMA enabled now. To check disk access speed, I use

hdparm -t /dev/hda

output is as follow

/dev/hda:
Timing buffered disk reads: 176 MB in 3.00 seconds = 58.66 MB/sec

prior to that with DMA disabled, the output reads

/dev/hda:
Timing buffered disk reads: 176 MB in 3.00 seconds = 2.90 MB/sec

Hopefully, this glitch is fixed in the next kernel release. Looks like I can start to like this linux os more now.

Extract of my new /var/log/dmesg with DMA enabled as follow:

------------------------------------------------------------------------------------------------------------------------
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
SIS5513: IDE controller at PCI slot 0000:00:02.5
PCI: IRQ 0 for device 0000:00:02.5 doesn't match PIRQ mask - try pci=usepirqmask
SIS5513: chipset revision 1
SIS5513: not 100% native mode: will probe irqs later
SIS5513: SiS5513 ATA 100 (2nd gen) controller
ide0: BM-DMA at 0xffa0-0xffa7, BIOS settings: hda:DMA, hdb:DMA
ide1: BM-DMA at 0xffa8-0xffaf, BIOS settings: hdc:DMA, hdd:DMA
Probing IDE interface ide0...
hda: WDC WD800JB-00FMA0, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
Probing IDE interface ide1...
hdc: HL-DT-ST DVDRAM GSA-4167B, ATAPI CD/DVD-ROM drive
ide1 at 0x170-0x177,0x376 on irq 15
hda: max request size: 128KiB
hda: Host Protected Area detected.
current capacity is 156299375 sectors (80025 MB)
native capacity is 156301488 sectors (80026 MB)
hda: Host Protected Area disabled.
hda: 156301488 sectors (80026 MB) w/8192KiB Cache, CHS=65535/16/63, UDMA(100)
hda: cache flushes supported
hda: hda1 hda2 <>
hdc: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache, UDMA(33)
Uniform CD-ROM driver Revision: 3.20
ide-floppy driver 0.99.newide

Extract of my old /var/log/dmesg with DMA disabled as follow:

------------------------------------------------------------------------------------------------------------------------
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
SIS5513: IDE controller at PCI slot 0000:00:02.5
PCI: IRQ 0 for device 0000:00:02.5 doesn't match PIRQ mask - try pci=usepirqmask
SIS5513: chipset revision 1
SIS5513: not 100% native mode: will probe irqs later
SIS5513: IDE controller at PCI slot 0000:00:02.5
PCI: IRQ 0 for device 0000:00:02.5 doesn't match PIRQ mask - try pci=usepirqmask
SIS5513: chipset revision 1
SIS5513: not 100% native mode: will probe irqs later
SIS_IDE: probe of 0000:00:02.5 failed with error -1
Probing IDE interface ide0...
hda: WDC WD800JB-00FMA0, ATA DISK drive
Probing IDE interface ide1...
hdc: HL-DT-ST DVDRAM GSA-4167B, ATAPI CD/DVD-ROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
hda: max request size: 128KiB
hda: Host Protected Area detected.
current capacity is 156299375 sectors (80025 MB)
native capacity is 156301488 sectors (80026 MB)
hda: Host Protected Area disabled.
hda: 156301488 sectors (80026 MB) w/8192KiB Cache, CHS=65535/16/63
hda: cache flushes supported
hda: hda1 hda2 <>
hdc: ATAPI 79X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache
Uniform CD-ROM driver Revision: 3.20
ide-floppy driver 0.99.newide

Saturday, November 12, 2005

Linux tips: Compiling & installing the linux kernel

In as many years as I've fiddle with the linux os, I've shun the ordeal of compiling my own kernel. I mean it's like rocket science to me more than anything else. I'm a hardware guy. I would rather overclock my cpu & if it failed, atleast I would know immediately. Rather than compiling codes for hours & only to find that it won't work cos I missed out something, hours later.

Today, however, I have finally taken that big step for once, to compile my own kernel. Not that I have suddenly amassed enough courage or what, but rather, I have no choice, cause I can't get linux work with my new hardwares.

Just so that I can remember what I did. I shall blog this down, as suggested by my friend yewfai.

Background:

To start it off. My hardwares are AMD64 3000+(Venice core) on a AsRock 939S56M mATX motherboard. So the first problem I encountered with linux is that the SIS 190 lan chip won't work with any existing version of kernel. I mean I've tried doing live update of kernel in Fedora Core 3 or 4, todate, they are only at 2.6.12 & 2.6.13 respectively & it looks as if I'm not going to get the chip working for a long while. From this thread. I learnt that I could actually get it working with a manual install of the 2.6.14 kernel .

Starting off: Resources & HowTo

After googling around, I found the Digital Hermit's guide to be comprehensive & so I used that. Kernel source was downloaded from www.kernel.org's mirror.

Working on it:


I supposed the procedure of installing kernel is documented in many sites & so I shall be brief. First go to /usr/src & do

tar xfvj /where/you/store/linux-2.6.14.1.tar.bz2

The tar command above will unzip the kernel source file into /usr/src/linux-2.6.14.1 After which, change directory to /usr/src/linux-2.6.14.1 & before we start, we do a

make mrproper

That will wipeout all previous configuration & resetting the source directory to a pristine state. The main reason for doing this is that some files do not automatically get rebuilt & resulting in buggy kernel. After which, we start by configuration what should be included into the kernel by doing

make menuconfig

That select the hardwares suitable for my system. Few things to note is to selecting the correct cpu type, like Opteron/AMD64 cpu & enabling the PREMPTIVE mode to speed up desktop response. And of course I made sure that the option of sis 190 lan chip is there. Just to make it even more idiot proof. I choose to built it into the kernel instead of as a loadable module. That is changing the option from 'M' to '*' in make menuconfig.

After that, I do the following to compile the kernel, make the modules, install the modules & generating initial ram disk, that pretty much concluded the work on 'compiling the kernel' . One thing to note that, I was confused with the need of ram disk & missed out the mkinitrd step. Ended up, I couldn't boot the the new kernel due to missing initrd-2.6.14.1.img file.


make clean
make bzImage
make modules
make modules_install
mkinitrd /boot/initrd-2.6.14.1.img 2.6.14.1

Installing the kernel.

The new compiled kernel is named bzImage & stored at arch/i386/boot/. The following steps are necessary to move it to the appropriate directory.

cp arch/i386/boot/bzImage /boot/bzImage-2.6.14.1
cp System.map /boot/System.map-2.6.14.1
ln -s /boot/System.map-2.6.14.1 /boot/System.map

Configuring grub bootloader


To start off grub.conf is at /etc directory. Edit it to include option to point to my newly install kernel at /boot/bzImage-2.6.14.1. You can see my grub.conf below. Note the locations of the root (hd0,6) & root=/dev/VolGroup00/LogVol00 rhgb quiet locations. It may vary depending on where you put the /boot partitions & which file system one uses. I just copied the same from the existing FC3 entried in grub.conf.

default=0
timeout=5
splashimage=(hd0,6)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.12-1.1381_FC3)
root (hd0,6)
kernel /vmlinuz-2.6.12-1.1381_FC3 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.12-1.1381_FC3.img
title Fedora Core (2.6.9-1.667)
root (hd0,6)
kernel /vmlinuz-2.6.9-1.667 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-1.667.img
title Test Kernel (2.6.14.1)
root (hd0,6)
kernel /bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet enforcing=0
initrd /initrd-2.6.14.1.img
title Other
rootnoverify (hd0,0)
chainloader +1

Rebooting:

On rebooting, I encountered 3 problems.

1, kernel file not found. That is resolved by changing

kernel /boot/bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet to
kernel /bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet

As grub assumed to read from /boot directory.

2, initrd-2.6.14.1.image file not found. That is resolved by running this

mkinitrd /boot/initrd-2.6.14.1.img 2.6.14.1

As mentioned above, that is what I missed ealier. It simply generates the ramdisk file for the new kernel.

3, kernel panic with 'Enforcing mode request but no policy loaded'. That is resolved by adding 'enforcing=0' in grub.conf.

kernel /bzImage-2.6.14.1 ro root=/dev/VolGroup00/LogVol00 rhgb quiet enforcing=0

Final words

There it goes. Now I have my SIS190 lan chip recognised & blogging it from the very same mahchine.

One may wonder, if my lan chip isn't working. How do I get all those resources from the net? Oh well, that's where a S$1 SMC network card came to the rescue. After the install, I just take out the SMC card & plug the cable into the SIS190 & viola.

Job done. Boy, all that trouble for a network card??? One wonders.

Monday, November 07, 2005

Best bang for buck socket 939 mATX motherboard recommendation, November 2005.


Please refer to table above for a list of shortlisted motherboards & some of their features for your consideration for your next upgrade.
  • PSU pins count is important for people upgrading & whether you have a 20 or 24 pins psu to go with them.
  • Max FSB in bios is important for people who like to have some basic overclocking feature to push their Venice 3000+.
  • Onboard 3D/VGA is important for people who don't game or light gaming & save some cost on a dedicated 3D card.
  • Onboard-TV out is important for people who want to turn their rig into inexpensive media pc.
  • Onboard-DVI is important to people who want to maximise their extra spending on a DVI-capable LCD.

For more details. Please refer to the original posting in this forum thread.

Friday, November 04, 2005

Running errand...

Finally taking a day off from work after months. Fully utilised the day to run my own errand that were long overdued.

1. Banked in a cheque that was atleast a month old.

2. Paid up a credit card bill, which the inter-bank giro(payment) facility is not approved & activated yet.

3. Renewed my Singapore re-entry permit today. Thanks to the very friendly staff at the Singapore immigration office, I had it renewed although I did not have all the required documents. I only found that I needed a company letter for reference to renew my permit, when I was given the form. The staff there suggested me to call my employer & ask them fax the company reference letter to their fax machine. And they can help to process the rest. Also thankfully, I had some CPF(central provident funds) & income tax assessment letters in my car. So after making some phone calls & getting some documents from my car. It took only about 10 mintues for the officer to issue me a renewed re-entry permit. That is something really commendable. Excellent services by the Singapore immigration department.

4. Also, two pieces of my Twinmos ram were causing some random crashes of games like a month or so back. Running a memtest diagnostic tools reveal that the ram is failing at test #5. And the best part about getting Twinmos ram, they have lifetime warranty. So this is the first time in many weeks do I have time to go back to Twinmos's office for RMA(return material authorization). And as I experienced before. The service is again excellent. The staff just took my rams without questions(no receipt needed by the way), and couple of minutes later, came back with two pieces of flashy & new rams. I told her probably only one of them is faulty & she gladly change both for me, so that I can run them in dual-channel still. Excellent service as usual.

5. Finally, bought a replacement flushing mechanism for my toilet which started creating problem a day ago. Took me like 20 minutes to fix it up & tighten everything to ensure nothing is leaking.

A very tired day indeed, but atleast got all of the long overdued tasks done in a day.

Thursday, November 03, 2005

Linux tips: enabling & disabling graphic boots

This may sound silly, but comes in handy when installing graphic card drivers in linux.

You will need to boot to native text mode to install say nVidia graphic card driver in linux.

Most linux dristibution will enable graphic boot during installation. To toggle between
graphic & text mode upon bootup.

edit /etc/inittab

change default runlevel from 5 to 3. As per extract from inittab below.
Level 5 is X11 graphic boot, level 3 is text mode.

#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg,
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

# System initialization.

Linux tips: accessing FAT partitions from Linux

For those dual-booting between Windows & Linux. It's very common that you have files you stored in your FAT partitions that you want to read from or write to, when you booted into linux.

Here is how you do it:

First, identify your fat partitions

The first partition in first harddisk should be identified as /dev/hda1.
The second partition in second harddisk should be identified as /dev/hda2.

So on & so forth.

My single harddisk is partition into 5 partitions

So my c: drive(primary partition) will be identified as /dev/hda1
My extended partition occupy /dev/hda2
My d: drive(1st logical partition) is identified as /dev/hda5
My e: drive(1st logical partition) is identified as /dev/hda6

To access my c:, d: & e: drives. I create 3 mount points under my linux
directory /home/coyote, and named them as cdrive, ddrive & edrive accordingly.

edit /etc/fstab & add the following lines. Upon reboot, you should have full
read & write acces to your fat partitions.

/dev/hda1 /home/coyote/cdrive vfat umask=0 0 0
/dev/hda5 /home/coyote/ddrive vfat umask=0 0 0
/dev/hda6 /home/coyote/edrive vfat umask=0 0 0