USB_OpenDevice failure for some USB devices

Post Reply
metafunk
Posts: 2
Joined: Mon Mar 21, 2011 4:47 pm

USB_OpenDevice failure for some USB devices

Post by metafunk » Mon Mar 21, 2011 4:59 pm

When using USB_OpenDevice(...) from ogc/usb.h some devices won't open correctly, even though they appear in the usb_device_entry array provided by USB_GetDeviceList(...). The call to USB_OpenDevice(...) returns -2.

I've seen it happen with 3 devices so far, a Microsoft mouse, an Apple keyboard and a Logitech gamepad. Below is the output of lsusb -v on a Linux machine:

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: USB_OpenDevice failure for some USB devices

Post by WinterMute » Tue Mar 22, 2011 1:04 am

This isn't really enough information to do anything with, I removed the huge lsusb report, it's not that helpful.

What would be helpful if you have the time, motivation and patience is to determine the failure point for these devices if you can. I'll see if I can point some of the USB experts towards this thread but unless they own these devices it's going to be difficult to pinpoint the problem and fix it.
Help keep devkitPro toolchains free, Donate today

Personal Blog

metafunk
Posts: 2
Joined: Mon Mar 21, 2011 4:47 pm

Re: USB_OpenDevice failure for some USB devices

Post by metafunk » Wed Mar 23, 2011 5:21 am

I've had a bit more of a look into it, trying IOS_Open(...) on each of the usb paths (/dev/usb/{oh0,oh1,ven,hid}) and the device specific paths for two attached USB devices: one that can be opened using USB_OpenDevice(...) and one that can't. Below is a list of the file descriptors (or errors) returned. The device which can be opened correctly is 0707:0201, the one that can't is 05ac:0204.

/dev/usb/oh0 4
/dev/usb/oh0/5ac/204 -2 #?
/dev/usb/oh0/707/201 5

/dev/usb/oh1 6
/dev/usb/oh1/5ac/204 -4 #IPC_EINVAL
/dev/usb/oh1/707/201 -4 #IPC_EINVAL

/dev/usb/ven -6 #IPC_ENOENT
/dev/usb/ven/5ac/204 -6 #IPC_ENOENT
/dev/usb/ven/707/201 -6 #IPC_ENOENT

/dev/usb/hid 7
/dev/usb/hid/5ac/204 8
/dev/usb/hid/707/201 9

Based on a quick look at USB_GetDeviceList(...) it looks like being able to list all the devices correctly with USBV0_IOCTL_GETDEVLIST, but performing an actual IOS_Open(...) further on in USB_OpenDevice(...) fails. You can see that both devices are openable via /dev/usb/hid.

Also, the return of -2 from IOS_Open(...) is quite confusing; it doesn't fit any of the pre-defined error scenarios.

I'm not sure if there is any further that I can dig into this, the response from the IPC queue request could give more information, but I don't think I could debug this (how does one debug a running Wii anyway?).

tueidj
Posts: 40
Joined: Thu Dec 10, 2009 9:26 am

Re: USB_OpenDevice failure for some USB devices

Post by tueidj » Thu Apr 28, 2011 9:27 am

/dev/usb/ven and /dev/usb/hid don't work like that; devices are accessed through them using ioctls. Given that all the failing devices are HIDs, it sounds like you're using one of the unsupported IOSes as mentioned in the comment at the top of usb.c. These IOSes implement an older version of /dev/usb/hid which grabs all HIDs and makes then inaccessible via /dev/usb/oh0 (they also don't implement /dev/usb/ven which is why the IOS_Open calls returned IPC_ENOENT). I have reverse-engineered this older /dev/usb/hid interface but chose not to add it to libogc since a) it's already messy enough trying to support both the V0 and V5 interfaces and b) there's not really a need for it when you can choose either of the other 2 implementations.

Solution: Use a different IOS, preferably 58.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests