Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need some help regarding the usb devices(Android based smartphones), more over i am new to linux. After googling a lot i heard there is trick using udev rule. Does this udev rule solved my problem?
how to create a rule for my below problem. Any help would really helpful..
I am testing some android based mobiles in linux machine. The automation script uses the device id under "/dev/bus/usb/001/"053" it will be always under bus 001 only.. But the dev id will be random like if i insert one mobile then the dev id will be 053, if remove and insert it again then the dev id will be 054..
The problem is, when some tests runs on the device and if device gets rebooted then new dev id is showing for the rebooted one and my scripts failing due to new dev id..
Is there any way to force usb devices to use same dev id instead of new one. So that there will be no issues to my tests even after device reboots.
This should make a symbolic link to the device when plugged under /dev/myphone
2) Try unplugging and pugging the phone and check if it worked.
3) If it did then change the automation script to point to "/dev/myphone".
For this case both SUBSYSTEMS=="usb" and ATTRS{busnum}=="1" means something like "/dev/bus/usb/001/*" (except it only matches the highest link_priority one). The bus number will change whenever you switch ports. You can try making a rule using other attribute, just use "udevadm monitor" to get udev events printed to the terminal as they happen, and then use "udevadm info -a -p <device>" for a device name udevadm just spout. ATTRS{idVendor} and ATTRS{idProduct} are very commonly used to match a single device, but a phone might act as many devices depending on the mode it is connected: eg. modem, storage device, flash mode, etc. all of this usually have different idProduct attributes.
Good luck and try not to write over a raw disk partition.
Last edited by fbianconi; 10-31-2012 at 06:46 PM.
Reason: guides are old and maybe inaccureate.
Using a different ID type for the filesystem may work.
Select one that is constant such as the UUID of the filesystem.
You may not even need to use udev rules. The KDE devices applet may be enough. The same may be true for Gnome. Also if you use the UUID of the filesystem, it can be used in an fstab entry. The user, uid, gid, noauto, fmask and dmask options will allow you to fix the mount location, ownership and permissions.
On some distros the udev rules have been migrated to polkit and systemd targets. A user ACL is used to grant permission rather than changing the group ownership.
I'd suggest researching how your disto and desktop handle devices now before jumping in and creating udev rules. There may be an easier way that doesn't fight with the system.
@fbianconi - Thank you for the detailed info and it'a valuable suggestion for me as a biggner in linux. I'll make a try and let you know the output.. Here i am connecting 14 devices to a linux box. Do i need to append 14 entries to the same rule with corresponding values?
@jschiwal - I am totally new to linux environment. I don't know much about the types of destros and Gnome/kde etc..
This should make a symbolic link to the device when plugged under /dev/myphone
2) Try unplugging and pugging the phone and check if it worked.
3) If it did then change the automation script to point to "/dev/myphone".
For this case both SUBSYSTEMS=="usb" and ATTRS{busnum}=="1" means something like "/dev/bus/usb/001/*" (except it only matches the highest link_priority one). The bus number will change whenever you switch ports. You can try making a rule using other attribute, just use "udevadm monitor" to get udev events printed to the terminal as they happen, and then use "udevadm info -a -p <device>" for a device name udevadm just spout. ATTRS{idVendor} and ATTRS{idProduct} are very commonly used to match a single device, but a phone might act as many devices depending on the mode it is connected: eg. modem, storage device, flash mode, etc. all of this usually have different idProduct attributes.
Good luck and try not to write over a raw disk partition.
Thank you for the detailed info and it'a valuable suggestion for me as a biggner in linux. I'll make a try and let you know the output.. Here i am connecting 14 devices to a linux box. Do i need to append 14 entries to the same rule with corresponding values?
fbianconi - When i used the below rule. It was created lots of myphone1/2/3/4/5 etc.. but i want to refer only to /dev/bus/usb/001/XXX.. the symlink is also not point to /dev/bus/usb/001/XXX
Making udev rules is one of the things that you never should have to do, unless you're dealing with experimental hardware and/or software. I don't think we can help you further without you explaining what are you trying to do. Can we see the script you are using?
Quote:
Do i need to append 14 entries to the same rule with corresponding values?
That depends on what you're doing and the rules you write, eg. if you are trying to connect more than one device at the time you might want to look at PROGRAM and %result.
Quote:
When i used the below rule. It was created lots of myphone1/2/3/4/5 etc.. but i want to refer only to /dev/bus/usb/001/XXX..
The numbering should be expected, since you added %n to the symlink string.
Quote:
the symlink is also not point to /dev/bus/usb/001/XXX
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.