[SOLVED] Getting a device recognized: custom udev rule?
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.
we have a little smart-phone (Huawei Ideos) bearing a SD card, which used to be recognized as mass storage in a trouble-free way when attached to a Linux PC (running debian/testing and KDE 4.13.1) via usb cable.
Some months ago it wasn't detected automatically anymore, but we found some easy clue (albeit unhandsome, because it requires root privileges) to workaround that: starting gparted manually triggered something that caused the system to recognize the partition.
Meanwhile even this little trick doesn't work anymore.
After the device is connected, "tail -f /var/log/messages" shows:
Code:
Jun 20 15:17:22 mybox kernel: [...] usb 1-1.2: new high-speed USB device number 27 using ehci-pci
Jun 20 15:17:22 mybox kernel: [...] usb 1-1.2: New USB device found, idVendor=12d1, idProduct=1037
Jun 20 15:17:22 mybox kernel: [...] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 20 15:17:22 mybox kernel: [...] usb 1-1.2: Product: Android Adapter
Jun 20 15:17:22 mybox kernel: [...] usb 1-1.2: Manufacturer: Huawei Incorporated
Jun 20 15:17:22 mybox kernel: [...] usb 1-1.2: SerialNumber: (...)
Jun 20 15:17:22 mybox kernel: [...] usb-storage 1-1.2:1.0: USB Mass Storage device detected
Jun 20 15:17:22 mybox kernel: [...] scsi41 : usb-storage 1-1.2:1.0
Jun 20 15:17:23 mybox usb_modeswitch: switch device 12d1:1037 on 001/027
That seems okay, but there is no additional block device on the linux side. After enabling USB usage on the Android side, nothing more happens.
However, we found the following (reloading the usb_storage driver) to be sufficient:
Hence, all we miss is a sensible way to automate this. We thought, /etc/udev/rules.d/ should be the right place to deposit a small script, but nothing worked.
After some hours of unavailingly searching for inspiring examples, I dare to ask whether someone with deeper expertise has any suggestion...?
Last edited by devdol; 06-25-2014 at 03:26 AM.
Reason: found a wokraround
Here is an article from android.com on how to create a udev rule to automate the connection. You will have to edit the command which is given to change the vendor id number from a list at the bottom of the article. http://developer.android.com/tools/device.html
After that, in fact two block devices (representing the smartphone's built in memory an its SD card) show up when plugged...
UDEV [501.038346] add /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:0/block/sdd (block)
UDEV [501.038382] add /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:2/block/sde (block)
UDEV [501.043141] change /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:0/block/sdd (block)
UDEV [501.044182] remove /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:0/block/sdd (block)
UDEV [501.044965] remove /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:0 (scsi)
UDEV [501.051113] change /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:2/block/sde (block)
UDEV [501.051862] remove /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/host11/target11:0:0/11:0:0:2/block/sde (block)
... but are "changed" and "removed" immediately after. So, we suppose, to clear up the sequence of events, one should be able to monitor not only the results (by udevadm monitor) but also the sequence of rules that control them. Because maybe we don't have to add additional rules but comment out (or modify) existing ones?
(Our system does not know an udevtrigger command, nor udevtest nor udevcontrol reload_rules. We suppose udevadm trigger, udevadm test are the successors of the first ones.)
But at the moment, we are dazed puzzled about the whole confusing scenario.
UPDATE
Amongst many others, we found a rule in /lib/udev/rules.d/40-usb_modeswitch.rules that is without counterpart on an Ubuntu system (12.04), where mass storage is detected and enabled as expected:
Code:
# Generic entry for all Huawei devices
ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
If we comment this line out on our Debian System, block devices do appear:
Thanks to nopes from ther german forum, who pointed me to a relevant posting from thatguychuck (read that for details), I tried
to enable kernel polling for the current uptime by:
Even when 40-usb_modeswitch.rules (see above) is reverted to its original state (that is, "Generic entry for all Huawei devices" re-enabled), so kernel polling seems to be the only thing to change.
Just enabling kernel polling triggers the usual automatism, e.g. updating KDE's device notifier.
While I feel like happily declaring this problem as solved, I am quite sure, that this is just one of different solutions and certainly not the most elegant one (the fact that the ubuntu reference system mentioned above has 0 kernel polling, too, lends colour to this hypothesis).
However, at least within a couple of hours, I have not experienced side-effects.
So, if you can propose an even better approach, please post it here!
Last edited by devdol; 06-25-2014 at 04:33 AM.
Reason: clarification
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.