8

I have an HTC Android phone.

Every time I connect it to computer I get a message:

Android Phone: Could not open MTP device "[usb:002,003]"

The numbers may be different. But the phone connects correctly.

usb-devices output

T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 28 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0bb4 ProdID=0f91 Rev=02.33
S:  Manufacturer=HTC
S:  Product=Android Phone
S:  SerialNumber=FA41BWB00560
C:  #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=06(still) Sub=01 Prot=01 Driver=usbfs
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=00 Driver=(none)

lsusb

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 048d:1336 Integrated Technology Express, Inc. SD/MMC Cardreader
Bus 002 Device 004: ID 0bb4:0f91 HTC (High Tech Computer Corp.) 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 04b8:0898 Seiko Epson Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

lsusb -t

/:  Bus 07.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/2p, 12M
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/3p, 12M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/3p, 12M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/3p, 12M
    |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/3p, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
    |__ Port 1: Dev 4, If 0, Class=Imaging, Driver=usbfs, 480M
    |__ Port 1: Dev 4, If 1, Class=Vendor Specific Class, Driver=, 480M
    |__ Port 3: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
    |__ Port 2: Dev 2, If 0, Class=Vendor Specific Class, Driver=, 480M
    |__ Port 2: Dev 2, If 1, Class=Printer, Driver=usblp, 480M
    |__ Port 2: Dev 2, If 2, Class=Mass Storage, Driver=usb-storage, 480M

udevadm info -q all -n /dev/bus/usb/002/004

P: /devices/pci0000:00/0000:00:13.2/usb2/2-1
N: bus/usb/002/004
S: libmtp-2-1
E: BUSNUM=002
E: COLORD_DEVICE=1
E: COLORD_KIND=camera
E: DEVLINKS=/dev/libmtp-2-1
E: DEVNAME=/dev/bus/usb/002/004
E: DEVNUM=004
E: DEVPATH=/devices/pci0000:00/0000:00:13.2/usb2/2-1
E: DEVTYPE=usb_device
E: DRIVER=usb
E: GPHOTO2_DRIVER=PTP
E: ID_BUS=usb
E: ID_FOR_SEAT=usb-pci-0000_00_13_2-usb-0_1
E: ID_GPHOTO2=1
E: ID_MEDIA_PLAYER=1
E: ID_MODEL=Android_Phone
E: ID_MODEL_ENC=Android\x20Phone
E: ID_MODEL_ID=0f91
E: ID_MTP_DEVICE=1
E: ID_PATH=pci-0000:00:13.2-usb-0:1
E: ID_PATH_TAG=pci-0000_00_13_2-usb-0_1
E: ID_REVISION=0233
E: ID_SERIAL=HTC_Android_Phone_FA41BWB00560
E: ID_SERIAL_SHORT=FA41BWB00560
E: ID_USB_INTERFACES=:060101:ffff00:
E: ID_VENDOR=HTC
E: ID_VENDOR_ENC=HTC
E: ID_VENDOR_FROM_DATABASE=HTC (High Tech Computer Corp.)
E: ID_VENDOR_ID=0bb4
E: MAJOR=189
E: MINOR=131
E: PRODUCT=bb4/f91/233
E: SUBSYSTEM=usb
E: TAGS=:seat:uaccess:
E: TYPE=0/0/0
E: USEC_INITIALIZED=611981507

dmesg

[   40.632283] usb 2-1: new high-speed USB device number 3 using ehci-pci
[   40.765458] usb 2-1: New USB device found, idVendor=0bb4, idProduct=0f91
[   40.765469] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[   40.765475] usb 2-1: Product: Android Phone
[   40.765480] usb 2-1: Manufacturer: HTC
[   40.765485] usb 2-1: SerialNumber: FA41BWB00560
[   40.766646] usb-storage 2-1:1.1: USB Mass Storage device detected
[   40.767102] scsi host10: usb-storage 2-1:1.1
[   40.864690] usb 2-1: USB disconnect, device number 3
[   41.613079] usb 2-1: new high-speed USB device number 4 using ehci-pci
[   41.746616] usb 2-1: New USB device found, idVendor=0bb4, idProduct=0f91
[   41.746626] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4
[   41.746633] usb 2-1: Product: Android Phone
[   41.746638] usb 2-1: Manufacturer: HTC
[   41.746643] usb 2-1: SerialNumber: FA41BWB00560
[  101.942087] usb 2-1: reset high-speed USB device number 4 using ehci-pci

I also found that for a short period of time after the phone is connected a usb-storage device is declared

I:  If#= 0 Alt= 0 #EPs= 3 Cls=06(still) Sub=01 Prot=01 Driver=usbfs
I:  If#= 1 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

Then it disconnects and class is changed to ff.

I:  If#= 0 Alt= 0 #EPs= 3 Cls=06(still) Sub=01 Prot=01 Driver=usbfs
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=00 Driver=(none)
  • Please do the following for me: 1) lsusb and find your device or your devices (Bus and Device). 2) Start the command udevadm info -q all -n /dev/bus/usb/your_bus_id/your_device_id and use Bus and Device. Add the output of the command in step 2 into your question. – A.B. Sep 3 '15 at 19:12
  • Ok and the output of lsusb too, I need only the part of your Phone – A.B. Sep 3 '15 at 19:14
  • I will add it, but you can see VID & PID in usb-devices. @A.B. – Pilot6 Sep 3 '15 at 20:28
  • I did not see the first comment. Added that too. – Pilot6 Sep 3 '15 at 20:35
  • 1
    I'm not sure that those are really two USB devices. – A.B. Sep 4 '15 at 6:12
6
+100

From dmesg output, it is clear that the phone connected twice.

  • [ 40.632283] 1st connected as USB bus 2 dev 3
  • [ 40.864690] disconnected
  • [ 41.613079] 2nd connected as USB bus 2 dev 4

The problem is:

  • Both phone connection modes are using same attributes idVendor/idProduct/bcdDevice.

  • libmtp udev rules use only idVendor/idProduct to filter devices in addition to non-important/common attributes ACTION!="add", ENV{MAJOR}!="?*" and SUBSYSTEM=="usb"

  • libmtp udev rules use ATTR (not ATTRS), it does target exactly this device node /devices/pci0000:00/0000:00:13.2/usb2/2-1. So we can't use interfaces nodes details as they are children nodes to this one.

To get what going on, use udevadm monitor. To see just events without details.

  1. Unplug the phone
  2. Open terminal and run udevadm monitor -u , -u to show UDEV events only (for clean output)
  3. Plug the phone and wait till things settle down
  4. Ctrl+C to stop monitoring

To get details (Environment properties) use udevadm monitor -u -p instead and compare output at that node:

  • UDEV [107.024195] add /devices/pci0000:00/0000:00:13.2/usb2/2-1 (usb)
  • UDEV [107.998137] add /devices/pci0000:00/0000:00:13.2/usb2/2-1 (usb)

Notice the difference in ID_USB_INTERFACES

Another cleaner way, using a udev rule to collect only what we need:

  1. Add a rule to /lib/udev/rules.d/69-libmtp.rules just after LABEL="libmtp_usb_rules":

    ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0f91", RUN+="/bin/sh -c 'env >> /home/username/udev-phone-mtp_%E{SEQNUM}.log'"
    
  2. Reload rules

    sudo udevadm control -R
    
  3. Replug the phone once.

  4. This rule should be triggered twice. Comparing output at that node:

    diff udev-phone-mtp_*.log

    should bring: (this is just the interesting portion)

    < ID_USB_INTERFACES=:060101:080650:
    ---
    > ID_USB_INTERFACES=:060101:ffff00:
    

Exactly what Pilot6 (OP) could catch it using usb-devices before it reconnected.


I suggest adding this rule to /lib/udev/rules.d/69-libmtp.rules, just after LABEL="libmtp_usb_rules":

ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0f91", ENV{ID_USB_INTERFACES}==":060101:080650:", GOTO="libmtp_rules_end"
  • This chat discussion chat.stackexchange.com/rooms/28790/… related to this . Reported that: First time it worked well A second time after unplug there was an error then opened after a delay. – user.dz Sep 5 '15 at 11:33
  • 1
    I do not see any errors now. But the delay is still there. It is up to a minute to get the device mounted. I get the error if I do not wait till it gets auto mounted and try to open it in nautilus. – Pilot6 Sep 5 '15 at 11:46
  • 1
    But this does not seem related, because I commented out your line and the delay is still there. The phone appears in the launcher but it can't mount for some time. – Pilot6 Sep 5 '15 at 11:48
  • The delay is not Ubuntu related. It is an Android bug. I plugged of the phone from one computer and connected to another. There is the same delay. – Pilot6 Sep 5 '15 at 12:32
  • 1
    It was really an Android problem with the delay. I reinstalled firmware for another reason and the delay disappeared. – Pilot6 Sep 18 '15 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.