MTP device and libusb problem

I’m trying to get my iRiver T10a MP3 player connected to openSUSE 11.4 (it worked fine in 11.3), but for some reason there seems to be something wrong with permissions. This is what I get:

$ mtp-detect
libmtp version: 1.0.6

Listing raw device(s)
libusb couldn't open USB device /dev/bus/usb/003/002: Permission denied.
libusb requires write access to USB device nodes.
libusb couldn't open USB device /dev/bus/usb/004/002: Permission denied.
libusb requires write access to USB device nodes.
Device 0 (VID=4102 and PID=1117) is a iRiver T10a.
   Found 1 device(s):
   iRiver: T10a (4102:1117) @ bus 2, dev 2
Attempting to connect device(s)
ignoring usb_claim_interface = -16ignoring usb_claim_interface = -22PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
inep: usb_get_endpoint_status(): Input/output error
outep: usb_get_endpoint_status(): Input/output error
usb_clear_halt() on IN endpoint: Numerical result out of range
usb_clear_halt() on OUT endpoint: Numerical result out of range
usb_clear_halt() on INTERRUPT endpoint: Numerical result out of range
LIBMTP libusb: Attempt to reset device
libusb:error [op_reset_device] reset failed error -1 errno 9
ignoring usb_claim_interface = -16ignoring usb_claim_interface = -22LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0
OK.

I’ve read about the error, and multiple sites recommend to add a rules files into /etc/udev/rules.d. I did exactly that - copied the file from this site:
Media
I saved it as 51-libmtp.rules. However, it had no effect whatsoever. So why is libusb not able to access the device?

On Mon, 20 Jun 2011 21:36:03 GMT, GreatEmerald
<GreatEmerald@no-mx.forums.opensuse.org> wrote:

>
>I’m trying to get my iRiver T10a MP3 player connected to openSUSE 11.4
>(it worked fine in 11.3), but for some reason there seems to be
>something wrong with permissions. This is what I get:
>
>
>Code:
>--------------------
> $ mtp-detect
> libmtp version: 1.0.6
>
> Listing raw device(s)
> libusb couldn’t open USB device /dev/bus/usb/003/002: Permission denied.
> libusb requires write access to USB device nodes.
> libusb couldn’t open USB device /dev/bus/usb/004/002: Permission denied.
> libusb requires write access to USB device nodes.
> Device 0 (VID=4102 and PID=1117) is a iRiver T10a.
> Found 1 device(s):
> iRiver: T10a (4102:1117) @ bus 2, dev 2
> Attempting to connect device(s)
> ignoring usb_claim_interface = -16ignoring usb_claim_interface = -22PTP_ERROR_IO: failed to open session, trying again after resetting USBinterface
> inep: usb_get_endpoint_status(): Input/output error
> outep: usb_get_endpoint_status(): Input/output error
> usb_clear_halt() on IN endpoint: Numerical result out of range
> usb_clear_halt() on OUT endpoint: Numerical result out of range
> usb_clear_halt() on INTERRUPT endpoint: Numerical result out of range
> LIBMTP libusb: Attempt to reset device
> libusb:error [op_reset_device] reset failed error -1 errno 9
> ignoring usb_claim_interface = -16ignoring usb_claim_interface = -22LIBMTP PANIC: failed to open session on second attempt
> Unable to open raw device 0
> OK.
>--------------------
>
>
>I’ve read about the error, and multiple sites recommend to add a rules
>files into /etc/udev/rules.d. I did exactly that - copied the file from
>this site:
>‘Media Device:MTP - Amarok Wiki’
>(http://amarok.kde.org/wiki/Media_Device:MTP)
>I saved it as 51-libmtp.rules. However, it had no effect whatsoever. So
>why is libusb not able to access the device?

Maybe you are having an issue with PolicyKit. It has been mixed in some
funky problems i have had.

Any ideas about what I can do about it?

Also, lsusb says that /dev/bus/usb/003/002 and /dev/bus/usb/004/002 are actually my keyboard and mouse, which is odd. My MTP device is on /002/002, as it says two lines below. So it might not be libusb permissions that are wrong. Probably the line “inep: usb_get_endpoint_status(): Input/output error” is what’s important here. Which is odd, since like I’ve said, it worked fine in 11.3.

Hi GreatEmerald. It does appear that a udev rule is repsosible for the incorrect ownership of the usb device here. I don’t have MTP hardware to play with, so can only offer general adivce, but maybe this will be enough…

With your device plugged in, please capture output of

lsusb

If your device is listed as ‘Bus 003 Device 002…’ for example, then you could type the following to determine ownership. I’m guessing it might return ‘root root’ ownership like this

 ls -l /dev/bus/usb/003/002
crw-rw-r-- 1 root root 189, 257 2011-06-26 07:50 /dev/bus/usb/003/002

We may need to add a rule to take care of the group ownership, and then make sure that your user is a member of that group. (Maybe the rules you added already don’t do this, or are getting beaten by another rule somewhere).

I have libghoto2 installed (because its required for PTP cameras and similar devices) and the gphoto2 utility can be used to generate a rules file containing a number of device rules, (including one for the the iRiver T10a). So, I note that I have this entry in my 90-libghoto2.rules file

ATTRS{idVendor}=="4102", ATTRS{idProduct}=="1117", ENV{ID_MEDIA_PLAYER}="1", MODE="0660", GROUP="lp"

As you can see, one needs to be a member of the ‘lp’ group in order to have access to devices listed here (if these rules are present). Is it possible that you have /etc/udev’rules.d/90-libghoto2.rules present? If not, disregard this. (Otherwise we need to ensure that your mtp rules are honoured and not overridden).

You may need to adjust your 51-libmtp.rules, so that your device has the desired group ownership eg ‘audio’ group.

# iRiver T10a
ATTR{idVendor}=="4102", ATTR{idProduct}=="1117", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio"

Then reload the updated udev rules with

udevadm control --reload-rules

Add yourself as a member of the ‘audio’ group via YaST>>Security and Users>>User and Group Management

Now see if ‘mtp-detect’ behaves…

All right, so first things first:

linux-vljc:~$ ls -l /dev/bus/usb/002/002
crw-rw-rw-+ 1 root root 189, 129 Bir 26 09:36 /dev/bus/usb/002/002

Seems you’re right about that.

linux-vljc:~$ ls /etc/udev/rules.d/
10-vboxdrv.rules  51-libmtp.rules  52-usx2yaudio.rules  55-libsane.rules  70-kpartx.rules  70-persistent-cd.rules  70-persistent-net.rules  71-multipath.rules  77-network.rules  81-mount.rules  99-qemu_tablet.rules

I don’t have libghoto2 rules.

I’ll see if setting a group works shortly.

No, that didn’t work either. Still gives me the exact same error message. I’ve reloaded the rules and relogged into my user and it’s still the same.

linux-vljc:~$ cat /etc/udev/rules.d/51-libmtp.rules | grep GROUP
SYSFS{idVendor}=="4102", SYSFS{idProduct}=="1117", SYMLINK+="libmtp-%k", MODE="666", GROUP="audio"
  1. Can you verify ‘audio’ group ownership with ‘ls -l /dev/bus/usb/…’ ? (Post command output here). I want to make sure that the rule is at least working.

  2. When mtp-detect is run with root privileges, do you get the same error?

I just found this Gentoo thread which may be relevant to your situation. The OP found that another process (hald) was claiming the device, causing ‘mtp-detect’ to fail. When ‘mtp-detect’ was executed at runlevel 3 (X not running), the errors were absent. Now, since you mention you’re using openSUSE 11.4, ‘hald’ should not be the problem here (as I understand its been deprecated), but you could use the same methodology outlined in the thread to find the culprit.

Which desktop environment are you using BTW? (It may make a difference in the context above).

Interesting ideas. It seems that the rules work, but even the root user can’t do anything:

linux-vljc:~$ ls -l /dev/bus/usb/002/004
crw-rw-rw-+ 1 root audio 189, 131 Bir 26 12:19 /dev/bus/usb/002/004
linux-vljc:~$ sudo mtp-detect
Slaptažodis: 
libmtp version: 1.0.6

Listing raw device(s)
Device 0 (VID=4102 and PID=1117) is a iRiver T10a.
   Found 1 device(s):
   iRiver: T10a (4102:1117) @ bus 2, dev 4
Attempting to connect device(s)
ignoring usb_claim_interface = -16ignoring usb_claim_interface = -22PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
inep: usb_get_endpoint_status(): Input/output error
outep: usb_get_endpoint_status(): Input/output error
usb_clear_halt() on IN endpoint: Numerical result out of range
usb_clear_halt() on OUT endpoint: Numerical result out of range
usb_clear_halt() on INTERRUPT endpoint: Numerical result out of range
LIBMTP libusb: Attempt to reset device
Segmentavimo klaida (core dumped)

I’m using KDE. And yes, HAL is not running here. I guess I can try it with X off, although I doubt it will do anything, especially since the error message in the other thread says “Device or resource busy”, while in my case it’s mostly I/O errors.

EDIT: Wait, that led me on track! It was Amarok. For some reason it locked the device. The problem is, I’m trying to get Amarok to put things on the device, and Amarok itself reports that it can’t see the device. So that’s really puzzling.

All right, so it’s fixed. Amarok locks the device in, and it in fact works, but given the complexity of Amarok 2 it’s difficult to operate it. In order to use it, you have to go to Local Music from the left pane, then wait a little until the device appears, then go to Files and choose the file or right-click on the right pane -> Show in Media Sources, then right-click on a track, then Copy To Collection -> Device.

So thanks! This is now fixed!

EDIT: Wait, that led me on track! It was Amarok. For some reason it locked the device. The problem is, I’m trying to get Amarok to put things on the device, and Amarok itself reports that it can’t see the device. So that’s really puzzling.

You might want to check out recent threads and bug reports concerning amarok, hal, and libmtp. These may (or may not) be relevant:

https://bugzilla.redhat.com/show_bug.cgi?id=666173

MTP device doesn’t show up on amarok • KDE Community Forums

I wonder if amarok would work for you if hald was installed (and running)?

All right, so it’s fixed. Amarok locks the device in, and it in fact works, but given the complexity of Amarok 2 it’s difficult to operate it. In order to use it, you have to go to Local Music from the left pane, then wait a little until the device appears, then go to Files and choose the file or right-click on the right pane -> Show in Media Sources, then right-click on a track, then Copy To Collection -> Device.

So thanks! This is now fixed!

Thanks for the update. Well done in persevering with this. It will no doubt be helpful to others with MTP devices.

On Sat, 25 Jun 2011 21:06:03 GMT, GreatEmerald
<GreatEmerald@no-mx.forums.opensuse.org> wrote:

>
>Any ideas about what I can do about it?

I wish i did. i have has some small successes by editing the permissions
files and rebooting a few times (^(%T^(% for big vendor$ making that
acceptable). If i thought i had anything reliable i would bring it here
now. IMPO policykit was a very bad misstep.
>
>Also, lsusb says that /dev/bus/usb/003/002 and /dev/bus/usb/004/002 are
>actually my keyboard and mouse, which is odd. My MTP device is on
>/002/002, as it says two lines below. So it might not be libusb
>permissions that are wrong. Probably the line “inep:
>usb_get_endpoint_status(): Input/output error” is what’s important here.
>Which is odd, since like I’ve said, it worked fine in 11.3.

On Sun, 26 Jun 2011 10:06:03 GMT, GreatEmerald
<GreatEmerald@no-mx.forums.opensuse.org> wrote:

>
>All right, so it’s fixed. Amarok locks the device in, and it in fact
>works, but given the complexity of Amarok 2 it’s difficult to operate
>it. In order to use it, you have to go to Local Music from the left
>pane, then wait a little until the device appears, then go to Files and
>choose the file or right-click on the right pane -> Show in Media
>Sources, then right-click on a track, then Copy To Collection -> Device.
>
>So thanks! This is now fixed!

Congratulations. I could almost follow the discussion.

?*-)