Trying to get usbnet working to gumstix

Previous thread: Querías Fiesta ??? by CITY HALL on Thursday, March 13, 2008 - 4:09 am. (1 message)

Next thread: Re: malloc revisited by Brandon Mercer on Thursday, March 13, 2008 - 6:55 am. (3 messages)
From: Leith Brandeland
Date: Thursday, March 13, 2008 - 6:52 am

All,

I'm trying to setup a usbnet connection to a gumstix.  I'm running OpenBSD
4.2 on a Soekris 4801.  I get the following message in /var/log/messages
when I plug the usb cable coming from the gumstix into the Soekris.

Mar 12 17:19:28 fw /bsd: cdce0 at uhub0 port 1 configuration 2 interface 0
Mar 12 17:19:28 fw /bsd:
Mar 12 17:19:28 fw /bsd: cdce0: Linux 2.6.18gum/pxa2xx_udc RNDIS/Ethernet
Gadget, rev 2.00/2.03, addr 2
Mar 12 17:19:33 fw /bsd: cdce0: interface alternate setting 0 failed

Looking at the man page for cdce(4) and it provides the following:

 cdce%d: interface alternate setting %d failed
     cdce%d: no descriptor for bulk endpoint %d
     cdce%d: could not find data bulk in/out  For a manually added USB ven-
     dor/product, these errors indicate that the bridge is not compatible
with
     the driver.

and

CAVEATS
     Many USB devices notoriously fail to report their class and interfaces
     correctly.  Undetected products might work flawlessly when their vendor
     and product IDs are added to the driver manually.

So, my questions are:  How can I determine what the vendor and product ID
is?   Once I find it, where in the OpenBSD code do I change it?

I did find the following snippet on the gumstix user wiki for applying a
patch to linux..

--- usbnet_orig.c       2004-11-12 22:55:56.000000000 +0100
+++ usbnet.c    2004-11-22 20:37:14.000000000 +0100
@@ -3320,6 +3320,10 @@
}, {
       USB_DEVICE (0x8086, 0x07d3),    // "blob" bootloader
       .driver_info =  (unsigned long) &blob_info,
+}, {

+       // Linux Ethernet/RNDIS gadget on pxa210/25x/26x

+       USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),

+       .driver_info =  (unsigned long) &linuxdev_info,

},
#endif


Is either the USB_DEVICE or USB_DEVICE_VER information what I need to bring
over to make this work?


Thanks.

From: Stuart Henderson
Date: Thursday, March 13, 2008 - 7:11 am

It's a different problem, those vendor/product IDs are already in
cdce(4) otherwise it wouldn't attach at all.

USB_VENDOR_NETCHIP, USB_PRODUCT_NETCHIP_ETHERNETGADGET

From: Stuart Henderson
Date: Thursday, March 13, 2008 - 7:28 am

..and while it's cdce(4) season, with zaurus, does anyone else
experience cdce not showing on the zaurus, but showing in dmesg
on the other device (as below, tried several i386/amd64,
kernels all <2w old, and a few different cables)..?

cdce0 at uhub2 port 2 configuration 1 interface 0 "OpenBSD.org CDC Ethernet Emulation" rev 1.01/1.00 addr 2
cdce0: address 2a:cb:90:42:70:00

From: Stuart Henderson
Date: Thursday, March 13, 2008 - 10:39 am

thanks William for pointing out cdcef which was enough to make me
realise why it doesn't show as a USB device...

From: Leith Brandeland
Date: Thursday, March 13, 2008 - 11:13 am

On Thu, Mar 13, 2008 at 9:11 AM, Stuart Henderson <stu@spacehopper.org>

Fair enough.  How do I address the "cdce0: interface alternate setting 0
failed" then?.  I'm not sure on the next step.  Is it still within cdce?

From: Leith Brandeland
Date: Thursday, March 13, 2008 - 12:03 pm

On Thu, Mar 13, 2008 at 1:13 PM, Leith Brandeland <leith@brandeland.com>


Stuart replied to me off list (Thanks!) and suggested I install the
usbutils.  I did and here is some selected output:

$ usbdevs -v
Controller /dev/usb0:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000),
Compaq(0x0e11), rev 1.00
 port 1 addr 2: full speed, self powered, config 2, RNDIS/Ethernet
Gadget(0xa4a2), Linux 2.6.18gum/pxa2xx_udc(0x0525), rev 2.03
 port 2 powered
 port 3 powered



$ usbctl -n -f /dev/usb0
DEVICE addr 1
DEVICE descriptor:
bLength=18 bDescriptorType=device(1) bcdUSB=1.00 bDeviceClass=9
bDeviceSubClass=0
bDeviceProtocol=0 bMaxPacketSize=64 idVendor=0x0e11 idProduct=0x0000
bcdDevice=100
iManufacturer=1(Compaq) iProduct=2(OHCI root hub) iSerialNumber=0()
bNumConfigurations=1

CONFIGURATION descriptor 0:
bLength=9 bDescriptorType=config(2) wTotalLength=25 bNumInterface=1
bConfigurationValue=1 iConfiguration=0() bmAttributes=40 bMaxPower=0 mA

INTERFACE descriptor 0:
bLength=9 bDescriptorType=interface(4) bInterfaceNumber=0
bAlternateSetting=0
bNumEndpoints=1 bInterfaceClass=9 bInterfaceSubClass=0
bInterfaceProtocol=0 iInterface=0()

ENDPOINT descriptor:
bLength=7 bDescriptorType=endpoint(5) bEndpointAddress=1-in
bmAttributes=interrupt wMaxPacketSize=8 bInterval=255

current configuration 1

HUB descriptor:
bDescLength=11 bDescriptorType=41 bNbrPorts=3 wHubCharacteristics=01
bPwrOn2PwrGood=1 bHubContrCurrent=0 DeviceRemovable=0

Hub status 0000 0000

Port 1 status=0103 change=0000

Port 2 status=0100 change=0000

Port 3 status=0100 change=0000

----------
DEVICE addr 2
DEVICE descriptor:
bLength=18 bDescriptorType=device(1) bcdUSB=2.00 bDeviceClass=2
bDeviceSubClass=0
bDeviceProtocol=0 bMaxPacketSize=16 idVendor=0x0525 idProduct=0xa4a2
bcdDevice=203
iManufacturer=1(Linux 2.6.18gum/pxa2xx_udc) iProduct=2(RNDIS/Ethernet
Gadget) iSerialNumber=0() bNumConfigurations=2

CONFIGURATION descriptor 0:
bLength=9 bDescriptorType=config(2) ...
From: Sean Kennedy
Date: Friday, March 14, 2008 - 5:59 am

For what it's worth, I'm interested too in a tech@ tutorial on (How to add
Unknown, or Semi-Known USB) devices.

I have had success with adding commonly defined things (Keyboards Mice, and
the occasional USB wireless/wired Network adapter)

But for something that has little or no description, (and no blobs) and
FreeBSD or NetBSD support (L*nux documentation too, but avoiding GPL)
It would be nice to see if I could add in USB support.

There really is no RT*M reference I could find at the best of times, to direct
where to begin.


_________________________________________________________________
Create a handy button so your friends can add U to their buddy list. Try it
now!
http://g.msn.ca/ca55/211

From: Stuart Henderson
Date: Friday, March 14, 2008 - 6:15 am

First you need to check the device ID (usbdevs -v) and make sure
there's a relevant entry in sys/dev/usb/usbdevs. If necessary, add
one and run 'make'.

Then look at an existing driver that you think might be a reasonably
close match and see how USB_VENDOR_xx and USB_PRODUCT_xx are matched,
you can then try adding the device.

*If* it's sufficiently similar it might just work...

From: Leith Brandeland
Date: Thursday, March 27, 2008 - 2:40 pm

On Thu, Mar 13, 2008 at 2:03 PM, Leith Brandeland <leith@brandeland.com>
I'm still digging into this, but not making a whole lot of headway.  I'm
hoping there are still some folks out there with some insight into this
little problem that can help.

So, again, the /var/log/messages error that I'm seeing is:

Mar 26 16:27:37 fw /bsd: cdce0: interface alternate setting 0 failed

looking into the code (sys/dev/usb/if_cdce.c), I think that this is where
the error is coming from:

for (j = 0; j < numalts; j++) {
            if (usbd_set_interface(sc->cdce_data_iface, j)) {
                printf("%s: interface alternate setting %d failed\n",
                    sc->cdce_dev.dv_xname, j);
                return;
            }

So, looking at the usbd_set_interface function (in usbdi.c)

usbd_set_interface(usbd_interface_handle iface, int altidx)
{
        usb_device_request_t req;
        usbd_status err;
        void *endpoints;

        if (LIST_FIRST(&iface->pipes) != 0)
                return (USBD_IN_USE);

        endpoints = iface->endpoints;
        err = usbd_fill_iface_data(iface->device, iface->index, altidx);
        if (err)
                return (err);
....<snip>....

I don't know if perhaps the error is farther down the code, but I forked my
investigation to look at the usbd_fill_iface_data in "usb_subr.c"

usbd_status
usbd_fill_iface_data(usbd_device_handle dev, int ifaceidx, int altidx)
{
        usbd_interface_handle ifc = &dev->ifaces[ifaceidx];
        usb_interface_descriptor_t *idesc;
        char *p, *end;
        int endpt, nendpt;

        DPRINTFN(4,("usbd_fill_iface_data: ifaceidx=%d altidx=%d\n",
                    ifaceidx, altidx));
        idesc = usbd_find_idesc(dev->cdesc, ifaceidx, altidx);
        if (idesc == NULL)
                return (USBD_INVAL);


First of all, can anyone say if I'm going down the right path?  Where can I
find some more information on this?

Thanks.

Previous thread: Querías Fiesta ??? by CITY HALL on Thursday, March 13, 2008 - 4:09 am. (1 message)

Next thread: Re: malloc revisited by Brandon Mercer on Thursday, March 13, 2008 - 6:55 am. (3 messages)