Thursday, July 31, 2008

Of CDs and DVDs, IDEs, SATAIIs and Kernels

The lfs standard udev rules result in the unwanted links cdrom and dvd for my DVD, and the links cdrom1 and cdrw1 for my read/write CD. I prefer the links cdrom and cdrw for the CD and dvd for the DVD. So I could modify 70-persistent-cd.rules to get the desired result. However, when I compile a new 2.6.26 kernel, the links get cdrom2 and dvd1 for the DVD, and the links cdrom3 and cdrw3 for the CD. In part, this is due to syntax changes documented in Documents/ide/ide.txt in the kernel source tree. On my very old system, I use the noprobe kernel parameter to avoid 2 minutes of probing the old motherboard ide controller which has no hard drives attached. The syntax changed from "ide0=noprobe" to "ide_core.noprobe=0.0 ide_core.noprobe=0.1"

In any event, I found a solution in /usr/share/doc/udev-113/index.html#example-cdrom which shows how much simpler rules can be used when the KERNEL names are known. In my case hdc is the DVD and hdd is the CD. So, I removed 70-persistent-cd.rules and 75-cd-aliases-generator.rules and replaced them with 70-my-cd.rules which does what I want on both the new and the old kernel:

BUS=="ide", KERNEL=="hdc", SYMLINK+="dvd", GROUP="cdrom"
BUS=="ide", KERNEL=="hdd", SYMLINK+="cdrom", GROUP="cdrom"
BUS=="ide", KERNEL=="hdd", SYMLINK+="cdrw", GROUP="cdrom"


Now, SATAII is the affectionate name for the sata_promise driver for Promise Technology, Inc. PDC40718 which was developed for the SATA 300 TX4 card. My card for sata drives is SATA 300 TX4302 which has 2 internal and 2 external sata ports (very handy). Both cards are detected exactly the same by the kernel. The history is that the ports get mapped in a peculiar order and some admins convinced the SATAII kernel driver developer that the ports should get mapped in an order that is consistent with the ports that are marked on the physical card. This make sense. However, on my SATA 300 TX4302 card, with the remapping, the externel ports get reversed when changing from kernels prior to 2.6.22 and kernels 2.6.22 and later. What this does to my system is to reverse sda and sdb which creates endless headaches. I use a script I call REMAP_HUNT to locate the code that remaps the ports:

base=
[ -n "$1" ] && [ -d "$1" ] && base=$1/
grep -C 4 -n remap ${base}drivers/ata/sata_promise.c

Then I created a patch for linux-2.6.26 to modify the remapping in such a way that sda and sdb on the external ports will be consistent with kernels earlier than 2.6.22:

*** orig/drivers/ata/sata_promise.c 2008-07-28 16:31:33.000000000 -0400
--- new/drivers/ata/sata_promise.c 2008-07-28 16:31:50.000000000 -0400
***************
*** 597,599 ****
{
! static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
--- 597,599 ----
{
! static const unsigned char sataii_tx4_port_remap[4] = { 1, 3, 0, 2};
return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;


I think I would be more likely to win the lottery than to get the kernel fixed to suit my particular card, so I'll just keep patching it. It works for SATA 300 TX4302 card. I like having 2 fast sata external drives.

To compile a new kernel, I more-or-less made a copy of lfs-commands/chapter08/132-kernel changing the kernel version to the one I wanted and added the patch that I wanted.

Next time I build lfs from the beginning, maybe I'll modify that file to get a newer kernel.

2 Comments:

Blogger linux fan said...

udev tutorial helps me make simple rules to create symlink and group for cdrom and dvd.

The rules in LFS-6.6 cannot handle my ancient genuine ide cdrom and dvd.

March 25, 2010 at 7:03 PM  
Blogger jet2006 said...

Hi linux fan, i have been reading and learning from your site, and have setup a lfs system, you have a lot of experience and good with programming i gather, could u do a page with some newer step by step details of setting up system with files listed accordingly ie. build lfs system - run build.sh, build Xorg - run script xorg.sh, build xfce - xfce.sh script, with links to the appropriate programs, since some of your earlier experiments u have got them to work, but i cannot get them to work exactly, ie. make the scripts build xorg, it downloads the files but cant make the files, it crashes no config file or something, am i missong something, does it all have to be done with jhalfs 2.3.1 or what ? please could u put all that info on one page with clear instructions, thank you very much.
I look forward to hearing from u. also is it possible to meet u i live near manchester, please email on that, thanks

May 4, 2010 at 5:06 AM  

Post a Comment

Subscribe to Post Comments [Atom]

Click blog title for the latest post