USB generic driver problems

admin2 at forkthepenguin.com admin2 at forkthepenguin.com
Tue Mar 16 15:18:17 PST 2004


Repost...

As a followup, I modified the /usr/src/sys/dev/usb/ugen.c source to
provide some additional debugging output in the ugen_set_config() function
(relevant code at bottom). This is the code responsible for creating the
device structure for the USB device endpoints after retrieving the
endpoint addresses from the USB device (i.e. /dev/ugen0.EE). The
make_dev(9) call fails (see log entries below) with a non zero status.
Given the endpoints returned by the device were valid, I'm at a loss as to
why. The device works correctly under Windows 2000 (fyi). Is this a
problem with the my device, a bug, or ???

Chris

Mar 12 14:09:46 cosmo /kernel: usbd_reset_port: port 2 reset done, error=NORMAL_COMPLETION
Mar 12 14:09:46 cosmo /kernel: usbd_new_device bus=0xc0d2e800 port=2 depth=1 lowspeed=512
Mar 12 14:09:46 cosmo /kernel: usbd_setup_pipe: dev=0xc0ec3f80 iface=0 ep=0xc0ec3f9c pipe=0xc0ec3f84
Mar 12 14:09:46 cosmo /kernel: usbd_new_device: adding unit addr=2, rev=110, class=0, subclass=0, protocol=0, maxpacket=8, len=18, ls=1
Mar 12 14:09:46 cosmo /kernel: usbd_new_device: new dev (addr 2), dev=0xc0ec3f80, parent=0xc0d30c80
Mar 12 14:09:46 cosmo /kernel: usbd_probe_and_attach: trying device specific drivers
Mar 12 14:09:46 cosmo /kernel: usbd_probe_and_attach: no device specific driver found
Mar 12 14:09:46 cosmo /kernel: usbd_probe_and_attach: looping over 1 configurations
Mar 12 14:09:46 cosmo /kernel: usbd_probe_and_attach: trying config idx=0
Mar 12 14:09:46 cosmo /kernel: usbd_set_config_index: (addr 2) attr=0x80, selfpowered=0, power=100
Mar 12 14:09:46 cosmo /kernel: usbd_set_config_index: set config 1
Mar 12 14:09:46 cosmo /kernel: usbd_probe_and_attach: no interface drivers found
Mar 12 14:09:46 cosmo /kernel: ugen0: LabJack Labjack U12, rev 1.10/5.f6, addr 2
Mar 12 14:09:46 cosmo /kernel: usbd_set_config_index: free old config
Mar 12 14:09:46 cosmo /kernel: usbd_set_config_index: (addr 2) attr=0x80, selfpowered=0, power=100
Mar 12 14:09:46 cosmo /kernel: usbd_set_config_index: set config 1
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: ugen0 to configno 1, sc=0xc0ebf000
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: ifaceno 0
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: endptno 0, endpt=0x01(1,1), sce=0xc0ebf264
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: endptno 1, endpt=0x02(2,0), sce=0xc0ebf328
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: Configuring Additional Endpoints
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: Calling make_dev for ugen0.1
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: make_dev returned -1058926464
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: Calling make_dev for ugen0.2
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: make_dev returned -1058926592
Mar 12 14:09:46 cosmo /kernel: ugen_set_config: Endpoint -1058796112 is null, can't call make_dev

#if defined(__FreeBSD__)
        /* the main device, ctrl endpoint */
        make_dev(&ugen_cdevsw, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0),
                UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev));

DPRINTFN(1,("ugen_set_config: Configuring Additional Endpoints\n"));

        for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) {
                if (sc->sc_endpoints[endptno][IN].sc != NULL ||
                    sc->sc_endpoints[endptno][OUT].sc != NULL ) {
                        /* endpt can be 0x81 and 0x01, representing
                         * endpoint address 0x01 and IN/OUT directions.
                         * We map both endpts to the same device,
                         * IN is reading from it, OUT is writing to it.
                         *
                         * In the if clause above we check whether one
                         * of the structs is populated.
                         */
                        DPRINTFN(1,("ugen_set_config: Calling make_dev for %s.%d\n",USBDEVNAME(sc->sc_dev), endptno));
                        myerr = make_dev(&ugen_cdevsw,
                                UGENMINOR(USBDEVUNIT(sc->sc_dev), endptno),
                                UID_ROOT, GID_OPERATOR, 0644,
                                "%s.%d",
                                USBDEVNAME(sc->sc_dev), endptno);
                        DPRINTFN(1,("ugen_set_config: make_dev returned %d\n", myerr) );
                } else {
                        DPRINTFN(1,("ugen_set_config: Endpoint %d is null, can't call make_dev\n", USBDEVNAME(sc->sc_dev), endptno))
;
                }
        }
#endif

On Thu, 11 Mar 2004 admin2 at forkthepenguin.com wrote:

>
> I'm attempting to interface with a usb based data acquisition device
> called a Labjack (http://labjack.com) under FreeBSD 4.9. The Labjack is a
> USB1.1 compliant HID device with a single configuration and two
> "interrupt" endpoints (in/out) not including the control endpoint.
>
> Initially I tried to use the uhid driver, but due to lack of functionality
> needed in this case I removed the uhid driver from the kernel in favor of
> the ugen driver. The ugen driver happily accepts the device and I can
> talk to it with a variety of utilities such as usbctl (from usbutil) and
> get a complete description of the device (bottom). After much research and
> fiddling around, I can up with a reasonable way to communicate with the
> device using libusb-0.1.8 (http://libusb.sourceforge.net/). Unfortunately
> the two endpoints are not being configured by the ugen driver on
> /dev/ugen0.1 and /dev/ugen0.2. From the debugging output of libusb, I get
> the following error when attempting to write to the endpoint :
>
> USB error: error writing to interrupt endpoint /dev/ugen0.2: Device not
> configured
>
> In theory these devices should get configured to the endpoints when the
> device is enumerated as they belong to interface 0 (the only interface)
> so it's not a matter of explicitly having to attach to an alternate
> interface.  After turning on debugging in the usb and ugen modules, I
> confirmed the ugen driver knows about the endpoints (see below).
>
> To write to the endpoint, I'm using the usb_interrupt_write function
> provided by libusb-0.1.8 for writing to "interrupt" type endpoints. I
> believe everything would work just fine if the /dev/ugen0.EE devices
> were configured by the driver properly, but at this point I'm stumped.
> Any ideas?
>
> Thanks in advance.
>
> Chris
>
>
> USB_DEBUG info :
>
> Attaching the unit :
>
> Mar 11 01:21:36 cosmo /kernel: usbd_reset_port: port 1 reset done,
> error=NORMAL_COMPLETION
> Mar 11 01:21:36 cosmo /kernel: usbd_new_device bus=0xc0d31800 port=1
> depth=1 lowspeed=512
> Mar 11 01:21:36 cosmo /kernel: usbd_setup_pipe: dev=0xc0d33a80 iface=0
> ep=0xc0d33a9c pipe=0xc0d33a84
> Mar 11 01:21:36 cosmo /kernel: usbd_new_device: adding unit addr=2,
> rev=110, class=0, subclass=0, protocol=0, maxpacket=8, len=18, ls=1
> Mar 11 01:21:36 cosmo /kernel: usbd_new_device: new dev (addr 2),
> dev=0xc0d33a80, parent=0xc0d33c80
> Mar 11 01:21:36 cosmo /kernel: usbd_probe_and_attach: trying device
> specific drivers
> Mar 11 01:21:36 cosmo /kernel: usbd_probe_and_attach: no device specific
> driver found
> Mar 11 01:21:36 cosmo /kernel: usbd_probe_and_attach: looping over 1
> configurations
> Mar 11 01:21:36 cosmo /kernel: usbd_probe_and_attach: trying config idx=0
> Mar 11 01:21:36 cosmo /kernel: usbd_set_config_index: (addr 2) attr=0x80,
> selfpowered=0, power=100
> Mar 11 01:21:36 cosmo /kernel: usbd_set_config_index: set config 1
> Mar 11 01:21:36 cosmo /kernel: usbd_probe_and_attach: no interface drivers
> found
> Mar 11 01:21:36 cosmo /kernel: ugen0: LabJack Labjack U12, rev 1.10/5.f6,
> addr 2
> Mar 11 01:21:36 cosmo /kernel: usbd_set_config_index: free old config
> Mar 11 01:21:36 cosmo /kernel: usbd_set_config_index: (addr 2) attr=0x80,
> selfpowered=0, power=100
> Mar 11 01:21:36 cosmo /kernel: usbd_set_config_index: set config 1
> Mar 11 01:21:36 cosmo /kernel: ugen_set_config: ugen0 to configno 1,
> sc=0xc0d34000
> Mar 11 01:21:36 cosmo /kernel: ugen_set_config: ifaceno 0
> Mar 11 01:21:36 cosmo /kernel: ugen_set_config: endptno 0,
> endpt=0x01(1,1), sce=0xc0d34264
> Mar 11 01:21:36 cosmo /kernel: ugen_set_config: endptno 1,
> endpt=0x02(2,0), sce=0xc0d34328
>
> When attempting to write to the endpoint :
>
> Mar 11 01:25:18 cosmo /kernel: usbd_setup_pipe: dev=0xc0d33a80
> iface=0xc0d279a0 ep=0xc0d32b78 pipe=0xcc5e3cfc
> Mar 11 01:25:18 cosmo /kernel: usbd_setup_pipe: dev=0xc0d33a80
> iface=0xc0d279a0 ep=0xc0d32b70 pipe=0xcc5e3cfc
>
> Killing program while hung on read :
>
> Mar 11 01:26:43 cosmo /kernel: usbd_ar_pipe: pipe=0xc0eb8d00
> Mar 11 01:26:43 cosmo /kernel: usbd_ar_pipe: pipe=0xc0eb8d00
> xfer=0xc0d33b00 (methods=0xc04aafe0)
> Mar 11 01:26:43 cosmo /kernel: usbd_ar_pipe: pipe=0xc0eb8280
> Mar 11 01:26:43 cosmo /kernel: usbd_ar_pipe: pipe=0xc0eb8280
> xfer=0xc0eb8200 (methods=0xc04aafe0)
>
> usbctl info :
>
> The Labjack is device 2 below.
>
> # usbctl
> USB device 1: 9
> USB device 2: 0
> 2 USB devices found
> DEVICE addr 1
> DEVICE descriptor:
> bLength=18 bDescriptorType=device(1) bcdUSB=1.00 bDeviceClass=9
> bDeviceSubClass=0
> bDeviceProtocol=0 bMaxPacketSize=64 idVendor=0x0000 idProduct=0x0000
> bcdDevice=100
> iManufacturer=1(SiS) 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=10 bDescriptorType=41 bNbrPorts=3 wHubCharacteristics=01
> bPwrOn2PwrGood=1 bHubContrCurrent=0 DeviceRemovable=0
>
> Hub status 0000 0000
>
> Port 1 status=0303 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=1.10 bDeviceClass=0
> bDeviceSubClass=0
> bDeviceProtocol=0 bMaxPacketSize=8 idVendor=0x0cd5 idProduct=0x0001
> bcdDevice=5f6
> iManufacturer=1() iProduct=2() iSerialNumber=0() bNumConfigurations=1
>
> CONFIGURATION descriptor 0:
> bLength=9 bDescriptorType=config(2) wTotalLength=41 bNumInterface=1
> bConfigurationValue=1 iConfiguration=0() bmAttributes=80 bMaxPower=100 mA
>
> INTERFACE descriptor 0:
> bLength=9 bDescriptorType=interface(4) bInterfaceNumber=0
> bAlternateSetting=0
> bNumEndpoints=2 bInterfaceClass=3 bInterfaceSubClass=0
> bInterfaceProtocol=0 iInterface=0()
>
> HID descriptor:
> bLength=9 bDescriptorType=cs_device(33) bcdHID=1.10 bCountryCode=0
> bNumDescriptors=1
> bDescriptorType[0]=cs_config(34), wDescriptorLength[0]=75
>
> Report descriptor
> Usage Page(1)
> Usage(0)
> Collection (Application)
>    Usage(0)
>    Usage(0)
>    Logical Min(128)
>    Logical Max(127)
>    Physical Min(19501)
>    Physical Max(17040385)
>    Report size(8)
>    Report count(8)
>    Input (Data, Variable, Absolute, No wrap, Linear, Preferred state, No
> null position, Bit field)
>    Usage(0)
>    Logical Min(128)
>    Logical Max(127)
>    Physical Min(50726916)
>    Physical Max(117703688)
>    Report size(8)
>    Report count(8)
>    Output (Data, Variable, Absolute, No wrap, Linear, Preferred state, No
> null position, Non volatile, Bit field)
>    Usage(0)
>    Logical Min(128)
>    Logical Max(127)
>    Physical Min(50463744)
>    Physical Max(117702918)
>    Report size(8)
>    Report count(128)
>    Feature (Data, Variable, Absolute, No wrap, Linear, Preferred state, No
> null position, Non volatile, Bit field)
> End Collection
>
>
> ENDPOINT descriptor:
> bLength=7 bDescriptorType=endpoint(5) bEndpointAddress=1-in
> bmAttributes=interrupt wMaxPacketSize=8 bInterval=10
>
> ENDPOINT descriptor:
> bLength=7 bDescriptorType=endpoint(5) bEndpointAddress=2-out
> bmAttributes=interrupt wMaxPacketSize=8 bInterval=10
>
> current configuration 1
>
> ----------
>


More information about the freebsd-questions mailing list