Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
USB Device # incrementing
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
jsharrad
n00b
n00b


Joined: 20 Apr 2005
Posts: 10

PostPosted: Tue Jun 12, 2007 8:29 am    Post subject: USB Device # incrementing Reply with quote

Is there a way to stop the device # of a USB device from incrementing every time the device resets?
Quote:

Jun 12 02:53:36 goober usb 1-2: new high speed USB device using ehci_hcd and address 3
Jun 12 02:53:36 goober usb 1-2: configuration #1 chosen from 1 choice
Jun 12 02:54:11 goober usb 1-2: USB disconnect, address 3
Jun 12 02:54:14 goober usb 1-2: new high speed USB device using ehci_hcd and address 4
Jun 12 02:54:14 goober usb 1-2: configuration #1 chosen from 1 choice
Jun 12 02:55:20 goober usb 1-2: USB disconnect, address 4
Jun 12 02:55:31 goober usb 1-2: new high speed USB device using ehci_hcd and address 5
Jun 12 02:55:31 goober usb 1-2: configuration #1 chosen from 1 choice
Jun 12 02:56:10 goober usb 1-2: USB disconnect, address 5
Jun 12 02:56:13 goober usb 1-2: new high speed USB device using ehci_hcd and address 6
Jun 12 02:56:13 goober usb 1-2: configuration #1 chosen from 1 choice

and so on...
I am running a program that requires it to stay the same to re-establish connection with the device after it's done resetting.
Back to top
View user's profile Send private message
mjbjr
Guru
Guru


Joined: 02 Mar 2003
Posts: 301

PostPosted: Tue Jun 12, 2007 9:11 pm    Post subject: Reply with quote

You can never be sure what /dev/xx a device will be assigned, particularly with usb.
You can resolve this type of issue by abstraction using a custom udev rule.

Sort of like saying:

if you see a usb device that has a model name of abc and a serial number of xyz make the device /dev/my_usb_camera.

With that kind of rule, that specific device, if it exists, will always be assigned to /dev/my_usb_camera
in addition to whatever /dev/xxx the system assigns it.

Yes, you can have mulktiple /dev's pointing to the same device.

Then you use /dev/my_usb_camera in your mounts, scripts, etc., because it will always "point" to the proper device.

Here are a couple of examples of my udev rules:

Note: in typical programming language convention,
"=" means assignment (c = 4)
"==" means test (does c == 4 ?)

BUS=="usb", SYSFS{product}=="Palm Handheld", NAME="%k", SYMLINK="treo", GROUP="uucp", MODE="0666"

in udev rules, typically,

the "NAME" parameter is the dev the kernel (notice the '%k') assigns and is subject to change
the "SYMLINK" parameter is what you want to *always* assign that particular device to... in the above udev creates /dev/treo

'/dev/treo' is what I use for the device to be accessed in my applications that need to communicate with the phone.

.
here's another example where you have two of the same devices and use the serial number to distinguish between them:
.

# ***** my personal Kingston Traveller USB Memory Stick ***** **********************************
BUS=="usb", SYSFS{manufacturer}=="Kingston", SYSFS{serial}=="5B680F8C74CE", NAME="%k", SYMLINK="my_kingston", MODE="0777"


# ***** my work data Kingston Traveller USB Memory Stick ***** **********************************
BUS=="usb", SYSFS{manufacturer}=="Kingston", SYSFS{serial}=="5B680F8C75GF", NAME="%k", SYMLINK="work_kingston", MODE="0777"

.
for more info see:

http://www.gentoo.org/doc/en/udev-guide.xml

and there's another link at the bottom of that article
.
.
Back to top
View user's profile Send private message
Mgiese
Veteran
Veteran


Joined: 23 Mar 2005
Posts: 1630
Location: indiana

PostPosted: Wed Nov 28, 2007 2:18 pm    Post subject: Reply with quote

hi there, i use udev-115-r1, i got some problems using your command line :
Code:
BUS=="usb", SYSFS{manufacturer}=="Kingston", SYSFS{serial}=="5B680F8C75GF", NAME="%k", SYMLINK="work_kingston", MODE="0777"


i looked with "udevinfo -a -p /sys/block/sdb/sdb1" for my device data, this is what comes out :

Code:
  looking at parent device '/devices/pci0000:00/0000:00:02.1/usb1/1-9':
    KERNELS=="1-9"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{serial}=="0002F685D8FE4605"
    ATTRS{product}=="_USB PRODUCT_"
    ATTRS{manufacturer}=="_USB MF_"
    ATTRS{quirks}=="0x0"
    ATTRS{maxchild}=="0"
    ATTRS{version}==" 2.00"
    ATTRS{devnum}=="4"
    ATTRS{busnum}=="1"
    ATTRS{speed}=="480"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bcdDevice}=="1001"
    ATTRS{idProduct}=="8000"
    ATTRS{idVendor}=="066f"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bmAttributes}=="80"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{configuration}=="USB/MSC LCD Player"
    ATTRS{dev}=="189:3"


do i have to use ATTRS or SYSFS ?

with the given data i added the following line into /etc/udev/rules.d/50-udev.rules :

Code:
BUS=="usb", SYSFS{manufacturer}=="_USB MF_", SYSFS{serial}=="0002F685D8FE4605", NAME="%k", SYMLINK="ustick", MODE="0777"


but even after a restart, i do not have a /dev/ustick device ... what could cause my trouble ? THX A LOT[/code]
_________________
I do not have a Superman complex, for I am God not Superman :D

Ryzen9 7950x (powersave governor) ; Radeon 7900XTX ; kernel 6.11.3 ; XFCE
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
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