View previous topic :: View next topic |
Author |
Message |
Vieri l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 18 Dec 2005 Posts: 907
|
Posted: Mon Aug 31, 2009 7:45 am Post subject: [SOLVED] custom udev rules for usb devices |
|
|
Hello,
I'd like to know how to write a custom udev rule so that a particular USB device is always assigned to a "custom-labeled" port, such as "RS-232-adapter-1" instead of a "variable" ttyUSB? (where ? usually changes).
I understand that the concept is to create a "RS-232-adapter-1" symlink in /dev through a custom udev rule. What's the correct way of doing this?
My USB device:
Code: |
# lsusb -D /proc/bus/usb/002/007
Device: ID 0403:6001 Future Technology Devices International, Ltd 8-bit FIFO
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x6001 8-bit FIFO
bcdDevice 4.00
iManufacturer 1 FTDI
iProduct 2 usb serial converter
iSerial 3 FTCTWS1T
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 44mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 2 usb serial converter
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)
|
Last edited by Vieri on Mon Aug 31, 2009 10:51 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
DawgG l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/141141986446bd852be0016.jpg)
Joined: 17 Sep 2003 Posts: 874
|
Posted: Mon Aug 31, 2009 9:04 am Post subject: |
|
|
you have to find out the one distinguishing property of your device (like manufacturer, serial, etc) and put it inside the udev-rule that creates the named symlink, then the device will always get that name.
you probably have to do some reading (it's worth it :wink: ) if you haven't already:
http://reactivated.net/writing_udev_rules.html#udevinfo
GOOD LUCK! _________________ DUMM KLICKT GUT. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Vieri l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 18 Dec 2005 Posts: 907
|
Posted: Mon Aug 31, 2009 9:40 am Post subject: |
|
|
Thanks.
I did the following:
Code: |
# udevinfo -a -p /sys/class/usb_device/usbdev2.7
looking at device '/class/usb_device/usbdev2.7':
KERNEL=="usbdev2.7"
SUBSYSTEM=="usb_device"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-2':
KERNELS=="2-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{serial}=="FTCTWS1T"
ATTRS{product}=="usb serial converter"
ATTRS{manufacturer}=="FTDI"
ATTRS{quirks}=="0x0"
ATTRS{maxchild}=="0"
ATTRS{version}==" 1.10"
ATTRS{devnum}=="7"
ATTRS{busnum}=="2"
ATTRS{speed}=="12"
ATTRS{bMaxPacketSize0}=="8"
ATTRS{bNumConfigurations}=="1"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceClass}=="00"
ATTRS{bcdDevice}=="0400"
ATTRS{idProduct}=="6001"
ATTRS{idVendor}=="0403"
ATTRS{bMaxPower}==" 44mA"
ATTRS{bmAttributes}=="a0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{configuration}==""
So I tried these udev rules:
DOES NOT WORK: KERNEL=="usb_device", SUBSYSTEMS=="usb", ATTRS{product}=="usb serial converter", ATTRS{manufacturer}=="FTDI", ATTRS{serial}=="FTCTWS1T", NAME="ttyUSB-GSM-630725830"
DOES NOT WORK: SUBSYSTEM=="usb_device", SUBSYSTEMS=="usb", ATTRS{product}=="usb serial converter", ATTRS{manufacturer}=="FTDI", ATTRS{serial}=="FTCTWS1T", NAME="ttyUSB-GSM-630725830"
works: SUBSYSTEMS=="usb", ATTRS{product}=="usb serial converter", ATTRS{manufacturer}=="FTDI", ATTRS{serial}=="FTCTWS1T", NAME="ttyUSB-GSM-630725830"
alternative (works):
SUBSYSTEMS=="usb", ATTRS{product}=="usb serial converter", ATTRS{manufacturer}=="FTDI", ATTRS{serial}=="FTCTWS1T", SYMLINK+="ttyUSB-GSM-630725830"
I tried this:
udevadm control --reload_rules
udevadm trigger --sybsystem-match=usb
to test my new udev rules without rebooting but that did not work. I had to force a reboot.
|
So, even if my problem is solved now, I'd like to know:
1) why are my first 2 rules invalid?
2) how can I correctly reload udev rules without rebooting a system?
Thanks. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
DawgG l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/141141986446bd852be0016.jpg)
Joined: 17 Sep 2003 Posts: 874
|
Posted: Mon Aug 31, 2009 10:11 am Post subject: |
|
|
glad it works now!
Quote: | why are my first 2 rules invalid? |
i think is neither part of KERNEL nor SUBSYSTEM in udev-rules.
Quote: | how can I correctly reload udev rules without rebooting a system? |
in my case (automounting usbdrives and executing a script on add and remove) (as root) did the trick. _________________ DUMM KLICKT GUT. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Vieri l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
Joined: 18 Dec 2005 Posts: 907
|
Posted: Mon Aug 31, 2009 10:51 am Post subject: |
|
|
Thanks! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|