Up until recently, udev, was a mystery to me, but I’m starting to learn. Udev is a service you probably want running with recent kernels. What it does is to create a node in the /dev directory whenever a new device is recognized. So, if you plug your m500 Palm Pilot and press the sync button, hotplug will recognize the device and udev should create the node in /dev for you with whatever naming convention you prefer.

First, before we name it, we want to figure out how the device looks to Linux, to do so press the sync button and do
lsusb -v | more

You should see something like this (but more verbose):

Bus 001 Device 014: ID 0830:0001 Palm, Inc.
Device Descriptor:
idVendor 0x0830 Palm, Inc.
idProduct 0x0001
iManufacturer 1 Palm, Inc.
iSerial 5 00TPP123A4KG

What is interesting is the serial number. This is a unique identifier for the device we can use to tell udev what to do with this device in particular. Not all USB devices have a serial number, but they have plenty of information to help you identify them. So we will add a new rule to tell udev what to do with this particular device, assuming you a vim-lover, do this:

cd /etc/udev/rules.d
vim 10-udev.rules

and enter the following line:

SYSFS{serial}="00TPP123A4KG",NAME="m500",
OWNER="lemire",GROUP="tty",MODE="0660"

This tells udev to create a node called m500 in /dev whenever this serial number is encountered. For extra points, I specify the ownership and permissions on the device. The device will appear as “/dev/m500″. You might have to type “udevstart” for the new rule to take effect, though I’m unclear about this. Anyhow, press the sync button and check that /dev/m500 is created.

Because /dev/m500 is created only when I press on the sync button and not before, software such as jpilot has a hard time because it doesn’t want to wait on a non-existing device. To fix this problem, we simply create a symbolic link:

ln /dev/m500 /dev/pilot

And voilà! Launch jpilot and you should be all set.

This whole approach is generally applicable to usb devices. Suppose you have a device such as /dev/sound/dsp1 and you want to know how to select it using udev rules, type the following:

udevinfo -n /dev/sound/dsp1 -q path | xargs udevinfo -a -p

This will give you interesting ways to select your device using an udev rule:

SYSFS{manufacturer}=="AKM "
SYSFS{product}=="AK5370 "

By the way, if you are using gentoo, the directory /sys automatically lists all the devices on your machine. It isn’t friendly, but it is good to know.

1 Comment

  1. This was very helpful thanks a lot. But instead of creating symbolic link I just tell jpilot to look at : /dev/zire

    this is what I put under name in udev. I was looking for an easy solution to the permission problems because before I could only run jpilot as root which I wasn’t happy about. Thanks again.

    Comment by Robert Spencer — 14/12/2005 @ 16:01

Sorry, the comment form is closed at this time.

« Blog's main page

Powered by WordPress