By: Chris Atkinson
This section describes how to set up a Palm Pilot USB cradle to synch on a pure udev system.
I'll assume that you have properly configured your system to work with your Palm Pilot.
The Palm Pilot only exists in sysfs after HotSynch button is pressed and prior to completion, cancellation or expiration of the synch. This means that you will be pressing the synch button a lot of times before you're sorted.
First, plug the cradle into your USB port. Press the hotsynch button on the cradle. Then run dmesg.
The result should be similar to:
usb 2-1: new full speed USB device using address 2
Now we need to burrow into sysfs to find this new full speed USB device. Try in /sys/class/tty. While the hotsynch is active, change to the /sys/class/tty directory and run a listing, as follows.
bash-2.05b# cd /sys/class/tty bash-2.05b# ls console tty12 tty19 tty25 tty31 tty38 tty44 tty50 tty57 tty63 ttyS3 ptmx tty13 tty2 tty26 tty32 tty39 tty45 tty51 tty58 tty7 ttyS4 tty tty14 tty20 tty27 tty33 tty4 tty46 tty52 tty59 tty8 ttyS5 tty0 tty15 tty21 tty28 tty34 tty40 tty47 tty53 tty6 tty9 ttyS6 tty1 tty16 tty22 tty29 tty35 tty41 tty48 tty54 tty60 ttyS0 ttyS7 tty10 tty17 tty23 tty3 tty36 tty42 tty49 tty55 tty61 ttyS1 ttyUSB0 tty11 tty18 tty24 tty30 tty37 tty43 tty5 tty56 tty62 ttyS2 ttyUSB1
The entry we're interested in is the last one, ttyUSB1. (Both USB links are created by the Palm Pilot, but only the latter does anything, so we'll disregard ttyUSB0.)
Let's double check, though. Wait until the hotsynch has timed out and then rerun the list command. The two ttyUSB entries should have vanished.
Now that we know which entry in sysfs we care about, let's use udevinfo to track down the data we'll need for our udev rules, as follows:
bash-2.05b$ udevinfo -p /sys/class/tty/ttyUSB1 -a
One of the entries is of interest:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1' :
BUS="usb"
ID="2-1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}=" 2mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0100"
SYSFS{bmAttributes}="c0"
SYSFS{detach_state}="0"
SYSFS{devnum}="4"
SYSFS{idProduct}="0001"
SYSFS{idVendor}="0830"
SYSFS{manufacturer}="Palm, Inc."
SYSFS{maxchild}="0"
SYSFS{product}="Palm Handheld"
SYSFS{serial}="123456789ABC"
SYSFS{speed}="12"
SYSFS{version}=" 1.00"
With this information we can create a udev rule in the /etc/udev/rules.d/10-udev.rules file which will create an entry in /dev for the Palm Pilot. There are a variety of ways to do this, the one I is use is as follows:
#Chris Palm Pilot
BUS="usb", SYSFS{serial}="123456789ABC", NAME="pilot"
Now we need to set the permissions for the new pilot device. Since it is better practice to leave the default settings in the /etc/udev/permissions.d/50-udev.permissions file alone, we need to create a /etc/udev/permissions.d/10-udev.permissions file containing the following entry to make the device world read/write:
#set Palm Pilot rw pilot*:root:usb:0666
Now let's check to see if it worked. First, press the hotsynch button. Now issue a nice, harmless command to the Palm to list its files:
bash-2.05b$ pilot-xfer -p /dev/pilot -L
You should get a nice list of your Palm Pilot's files. Now, just make sure that whatever GUI interface you use with your Palm is looking at the /dev/pilot device (rather than, say, TTYUSB), and you're ready to go.
By: Chris Atkinson
One common device type about which questions are frequently asked is the USB drive/thumbdrive/keychain drive. This is a finger-sized device which can be inserted into a USB port and mounted as a harddrive.
This
just covers the udev.
aspects of using such a
drive. I'd recommend reviewing a more general tutorial on these drives,
to make sure that you've covered the non-udev
issues as well.
One non-udev
issue to note is that, starting in some of the 2.6.9 kernels, an
option to compile in support for usb block drives rather than using
SCSI emulation. Since this is pretty new, I'll give examples using both
the old sd* devices and the new ub* devices.
To start, let's insert the drive and run a dmesg. Using SCSI emulation, the last line of the output should look like
usb 1-2: new high speed USB device using address 2
Initializing USB Mass Storage driver...
scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: 128MB Model: USB2.0FlashDrive Rev:
Type: Direct-Access ANSI SCSI revision: 02
USB Mass Storage device found at 2
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
SCSI device sda: 251904 512-byte hdwr sectors (129 MB)
sda: Write Protect is off
sda: Mode Sense: 03 00 00 00
sda: assuming drive cache: write through
sda: sda4
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Or, if you are using the 2.6.9+ usb block device support, like:
usb 1-2: new high speed USB device using address 2
ub: sizeof ub_scsi_cmd 60 ub_dev 924
uba: device 2 capacity nsec 256000 bsize 512
uba: was not changed
uba: uba1
usbcore: registered new driver ub
We now hunt for this device in /sys. The tricky piece is that you are not looking for the device sda (or uba) but rather for its partition sda4 (or uba1). So we run the command
udevinfo -p /sys/block/sda/sda4 -a
Or, for the new ub* devices:
udevinfo -p /sys/block/uba/uba1 -a
The interesting part of the output might look similar too:
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-1':
BUS="usb"
ID="1-1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}=" 84mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0100"
SYSFS{bmAttributes}="80"
SYSFS{detach_state}="0"
SYSFS{devnum}="2"
SYSFS{idProduct}="0117"
SYSFS{idVendor}="0117"
SYSFS{manufacturer}="Power by USB"
SYSFS{maxchild}="0"
SYSFS{product}="USB 2.0 Flash Drive "
SYSFS{serial}="A083014282978"
SYSFS{speed}="480"
SYSFS{version}=" 2.00"
We
then create a rule in /etc/udev/rules.d/10-udev.rules
as follows:
#Black USB Thumb Drive
BUS="usb", SYSFS{serial}="A083014282978", NAME="blackthumb"
We check to make sure that the
thumbdrive is now present as a device in /dev
with the we assigned it:
ls
-la /dev | grep thumb
If it is there, we now add an entry to the /etc/fstab file to allow it to be mounted.
The following shows the entry for a single-partitioned vfat-formatted drive set up to be mountable by any user. Change as you see fit for your situation.
/dev/thumb /mnt/thumbdrive vfat noauto,user,umask=000 0 0
Now, lets mount it and make sure it's where we expect it to be.
mount /dev/thumb
cd /mnt/thumbdrive
ls