USB Host In Transfer Failure
Posted: Thu Aug 31, 2023 4:49 pm
Hi All
I am trying to setup a IN Transfer on a usb device in host mode.
The device looks as follows:
<code>
*** Device descriptor ***
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0x0
bDeviceSubClass 0x0
bDeviceProtocol 0x0
bMaxPacketSize0 8
idVendor 0x665
idProduct 0x5161
bcdDevice 0.00
iManufacturer 3
iProduct 1
iSerialNumber 0
bNumConfigurations 1
*** Configuration descriptor ***
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
bMaxPower 100mA
*** Interface descriptor ***
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 0x3
bInterfaceSubClass 0x0
bInterfaceProtocol 0x0
iInterface 0
*** Endpoint descriptor ***
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 0x3 INT
wMaxPacketSize 8
bInterval 12
</code>
But my code keep on crashing on usb_host_transfer_submit.
This is what I have
<code>
ESP_ERROR_CHECK(usb_host_interface_claim(driver_obj.client_hdl,driver_obj.dev_hdl,0x81,0));
uint8_t ep_ms = 1024;
usb_transfer_t *in_xfer;
ESP_ERROR_CHECK(usb_host_transfer_alloc(ep_ms, 0, &in_xfer) );
in_xfer->device_handle = driver_obj.dev_hdl;
in_xfer->callback = in_xfer_done;
in_xfer->context = &driver_obj;
in_xfer->timeout_ms = 10000;
in_xfer->bEndpointAddress = 0x81;
in_xfer->num_bytes = ep_ms;
ESP_ERROR_CHECK( usb_host_transfer_submit(in_xfer));
</code>
if I trace the code I can see it fails in usbh.c in the usbh_ep_get_context method. Specifically this line:
<code>
//Check if the EP was allocated to begin with
if (pipe_hdl == NULL) {
ret = ESP_ERR_NOT_FOUND;
goto exit;
}
</code>
but I have no idea why, or what I am missing, Any suggestions would be greatly appreciated.
PS. I can do a out control transfer using usb_host_transfer_submit_control on the same device, so at least the client and device handles seem to be ok
I am trying to setup a IN Transfer on a usb device in host mode.
The device looks as follows:
<code>
*** Device descriptor ***
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0x0
bDeviceSubClass 0x0
bDeviceProtocol 0x0
bMaxPacketSize0 8
idVendor 0x665
idProduct 0x5161
bcdDevice 0.00
iManufacturer 3
iProduct 1
iSerialNumber 0
bNumConfigurations 1
*** Configuration descriptor ***
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
bMaxPower 100mA
*** Interface descriptor ***
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 0x3
bInterfaceSubClass 0x0
bInterfaceProtocol 0x0
iInterface 0
*** Endpoint descriptor ***
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 0x3 INT
wMaxPacketSize 8
bInterval 12
</code>
But my code keep on crashing on usb_host_transfer_submit.
This is what I have
<code>
ESP_ERROR_CHECK(usb_host_interface_claim(driver_obj.client_hdl,driver_obj.dev_hdl,0x81,0));
uint8_t ep_ms = 1024;
usb_transfer_t *in_xfer;
ESP_ERROR_CHECK(usb_host_transfer_alloc(ep_ms, 0, &in_xfer) );
in_xfer->device_handle = driver_obj.dev_hdl;
in_xfer->callback = in_xfer_done;
in_xfer->context = &driver_obj;
in_xfer->timeout_ms = 10000;
in_xfer->bEndpointAddress = 0x81;
in_xfer->num_bytes = ep_ms;
ESP_ERROR_CHECK( usb_host_transfer_submit(in_xfer));
</code>
if I trace the code I can see it fails in usbh.c in the usbh_ep_get_context method. Specifically this line:
<code>
//Check if the EP was allocated to begin with
if (pipe_hdl == NULL) {
ret = ESP_ERR_NOT_FOUND;
goto exit;
}
</code>
but I have no idea why, or what I am missing, Any suggestions would be greatly appreciated.
PS. I can do a out control transfer using usb_host_transfer_submit_control on the same device, so at least the client and device handles seem to be ok