Why is my USB device not recognized in host mode?

Hello!
I’m having trouble getting my device, which is RP2040-based with the TinyUSB stack, to be seen via USB host with a FEZ Feather.
I plugged in a couple other random devices and they are seen, but for some reason this device isn’t triggering OnConnectionChangedEvent.

Here’s an LSUSB dump of the device, but for clarification the device isn’t even enumerating–haven’t gotten to data transfer yet.

Bus 001 Device 015: ID 2e8a:f00a Generic RP2040
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239 
  bDeviceSubClass         2 
  bDeviceProtocol         1 
  bMaxPacketSize0        64
  idVendor           0x2e8a 
  idProduct          0xf00a 
  bcdDevice            1.00
  iManufacturer           1 Generic
  iProduct                2 RP2040
  iSerial                 3 C8695C98DB29262F
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x006b
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 
      bFunctionSubClass       2 
      bFunctionProtocol       0 
      iFunction               0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 
      bInterfaceSubClass      2 
      bInterfaceProtocol      0 
      iInterface              4 TinyUSB Serial
      CDC Header:
        bcdCDC               1.20
      CDC Call Management:
        bmCapabilities       0x00
        bDataInterface          1
      CDC ACM:
        bmCapabilities       0x02
          line coding and serial state
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              16
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass        10 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              5 Indiemark USB
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      32
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)

is the rp2040 recognized by a PC?

Yep! That’s how I was able to do the LSUSB dump :smiley:

Just tried quick seems the event raise on mine.

Maybe I could send you my RP2040 UF2 firmware to test on your end?
I’m using a FEZ Feather with the latest FW

yes
dat.tran@ghie…

We see, we tested on the fixed version, it raises event as well. When back to official version then no event. Does below seem correct? Is there 3 interfaces?

-------------------Unknow Device-------------------
DeviceStatus 00000001
Id 24058f50
Type 0000000c
ProductId 0000f00a
VendorId 00002e8a
Connected
-------------------Unknow Device-------------------
DeviceStatus 00000001
Id 24058f50
Type 00000000
ProductId 0000f00a
VendorId 00002e8a
Connected
-------------------Unknow Device-------------------
DeviceStatus 00000001
Id 24058f50
Type 00000002
ProductId 0000f00a
VendorId 00002e8a

Yes, that seems correct!
When you say fixed version–is this a fix you just made, or is there another FW version that I should use?

Thanks!

We are working on the new release, there was an issue with USB host that we fixed it. When I tested your issue, I used this version so I could not reproduce, but when I get back to official release 2.2.0.5100 then I was able to reproduce.

Would you like to have this version for testing purpose only?

Yes, that would be great. Thank you :slight_smile:

Thanks for the help Dat. I can see the device now. However, the application seems to be hanging at the var devDesc = rawDevice.GetDeviceDescriptor(); call, if that is commented then var cfgDesc = rawDevice.GetConfigurationDescriptor(0); also stops it. Any thoughts on that?

EDIT: If I just comment those lines out, I’m getting “Exception thrown: ‘System.InvalidOperationException’ in GHIElectronics.TinyCLR.Devices.UsbHost.dll
An unhandled exception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.TinyCLR.Devices.UsbHost.dll” on the pipe transfer. Seems like it might not be opening the pipe properly?

Sample code, but it’s basically just the example code:

 switch (e.DeviceStatus)
        {
            case DeviceConnectionStatus.Connected:
                if (e.InterfaceIndex == 2)
                {
                    var rawDevice = new RawDevice(e.Id, 2, BaseDevice.DeviceType.HID);
                    //var devDesc = rawDevice.GetDeviceDescriptor(); //Stops here if uncommented
                    //var cfgDesc = rawDevice.GetConfigurationDescriptor(0); //Stops here if uncommented
                    var endpointData = new byte[7];
                    endpointData[0] = 7;        //Length in bytes of this descriptor.
                    endpointData[1] = 5;        //Descriptor type (endpoint).
                    endpointData[2] = 0x83;     //Input endpoint address.
                    endpointData[3] = 3;        //Transfer type is interrupt endpoint.
                    endpointData[4] = 0;        //Max packet size LSB.
                    endpointData[5] = 63;        //Max packet size MSB.
                    endpointData[6] = 1;       //Polling interval.

                    var endpoint = new Endpoint(endpointData, 0);

                    var pipe = rawDevice.OpenPipe(endpoint);//System.InvalidOperationException here
                    pipe.TransferTimeout = 10;

                    var data = new byte[64];

                    var read = pipe.Transfer(data);

                    if (read > 0)
                    {
                        Debug.WriteLine("Raw Device has new data "
                            + data[0] + ", " + data[1]);
                    }

                    else if (read == 0)
                    {
                        Debug.WriteLine("No new data");
                    }

                    Thread.Sleep(500);
                }



                break;

            case DeviceConnectionStatus.Disconnected:
                Debug.WriteLine("Device Disconnected");
                //Unmount filesystem if it was mounted.
                break;

            case DeviceConnectionStatus.Bad:
                Debug.WriteLine("Bad Device");
                break;
        }

Yes, I am not sure why the error is not support the device with interface 2. Any special with this interface?

Nope, nothing special. All just default values.