2014-06-19 09:02 AM
Hi guys, looking for some help with a USB device I have which has 2 interfaces. The first interface is HID, and the second is MSC. I've modified the USB Host library so that it doesn't it doesn't fail in the MSC Interface Init. It's originally setup just to look at interface 0 here so I added a line to get it to look at interface 1 as well so that it didn't fail. This allowed me to mount the device with chan's FATFS. I can read from the device but I can't write to it. Debugging my way through it, the ep descriptors for interface 1 never seem to be there and I'm guessing that might be an issue. Not completely sure. Has anyone encountered this kind of thing before?
2014-06-20 10:56 AM
> Debugging my way through it, the ep descriptors for interface 1 never seem to be there and I'm guessing that might be an issue.
Are you working on STM32_USB-Host-Device_Lib_V2.1.0? USBH_MSC_InterfaceInit() parses the interface descriptor set, and it opens pipes for the bulk IN/OUT EPs. The original code assumes that the MSC sits on interface 0. For other interface number, you have to modify this routine as follows - add ''if_num'' parameter for the target interface number. - in the routine, Itf_Desc[0] --> Itf_Desc[if_num] Ep_Desc[0] --> Ep_Desc[if_num]usbh_msc_core.c
static USBH_Status USBH_MSC_InterfaceInit ( USB_OTG_CORE_HANDLE *pdev, void *phost, uint32_t if_num)
{
USBH_HOST *pphost = phost;
if((pphost->device_prop.Itf_Desc[if_num].bInterfaceClass == MSC_CLASS) && \
(pphost->device_prop.Itf_Desc[if_num].bInterfaceProtocol == MSC_PROTOCOL))
{
if(pphost->device_prop.Ep_Desc[if_num][0].bEndpointAddress & 0x80)
{
MSC_Machine.MSBulkInEp = (pphost->device_prop.Ep_Desc[if_num][0].bEndpointAddress);
MSC_Machine.MSBulkInEpSize = pphost->device_prop.Ep_Desc[if_num][0].wMaxPacketSize;
}
else
{
MSC_Machine.MSBulkOutEp = (pphost->device_prop.Ep_Desc[if_num][0].bEndpointAddress);
MSC_Machine.MSBulkOutEpSize = pphost->device_prop.Ep_Desc[if_num][0].wMaxPacketSize;
}
if(pphost->device_prop.Ep_Desc[if_num][1].bEndpointAddress & 0x80)
{
MSC_Machine.MSBulkInEp = (pphost->device_prop.Ep_Desc[if_num][1].bEndpointAddress);
MSC_Machine.MSBulkInEpSize = pphost->device_prop.Ep_Desc[if_num][1].wMaxPacketSize;
}
else
{
MSC_Machine.MSBulkOutEp = (pphost->device_prop.Ep_Desc[if_num][1].bEndpointAddress);
MSC_Machine.MSBulkOutEpSize = pphost->device_prop.Ep_Desc[if_num][1].wMaxPacketSize;
}
...
Tsuneo
2014-06-23 02:20 AM
Hi Tsuneo,
No, I'm working with library v.2.0.0. Are there significant changes in 2.1.0 that would help me? I made the changes you had suggested ( I had done something similar but it wasn't as tidy as yours :P) but the End point descriptors for interface 1 are still blank,and I can't even get to the point of mounting FAT now. The only change I had made was to modify the USBH_MSC_InterfaceInit so that instead of the first if statement just asking about itfdesc[0], it also checked itfdesc[1] :if((pphost->device_prop.Itf_Desc[0].bInterfaceClass == MSC_CLASS) && (pphost->device_prop.Itf_Desc[0].bInterfaceProtocol == MSC_PROTOCOL) \
|| (pphost->device_prop.Itf_Desc[1].bInterfaceClass == MSC_CLASS) && (pphost->device_prop.Itf_Desc[1].bInterfaceProtocol == MSC_PROTOCOL))
With that as the only modification, I can mount and read files. So I’m not quite sure why your mods won’t work. To call your modified function i modified usbh_core.c so that it was like this:
case HOST_USR_INPUT:
/*The function should return user response true to move to class state */
if ( phost->usr_cb->UserInput() == USBH_USR_RESP_OK)
{
if(phost->device_prop.Itf_Desc[0].bInterfaceClass == 0x08){
interface = 0;
}
else if(phost->device_prop.Itf_Desc[1].bInterfaceClass == 0x08){
interface = 1;
}
if((phost->class_cb->Init(pdev, phost, interface))== USBH_OK)
{
phost->gState = HOST_CLASS_REQUEST;
}
}
break;
Within the enumeration stuff, there's the switch statement that calls on the USBH_Get_Cfg_Desc function (approx line 479 of usbh_core.c) and then has the user callback for cofiguration descriptors which just inculdes end point 0. Should that be modified too?
Cheers!
2014-09-01 03:02 PM
I've successfully now managed to get the library working with my dual interface device and fat seems to be mounting fine onto the second interface (MSC), but as previously, I only seem to be able to read from the device and not write to it. All the fatfs functions return a FR_OK though even when writing. Does anyone know what might be happening?
Cheers!2015-02-24 07:35 AM
I had put this project to the side for the past year, but now back onto it. Latest update is that I've discovered that the interface I need uses the same endpoint address(0x81,0x01) for in and out. All other devices I've tried with my USB host seem to use different addresses (usually 0x81, 0x02). I'm starting to think this might be the issue. Has anyone else encountered anything similar or able to confirm my hypothesis?