AnsweredAssumed Answered

A patch for USB HOST Library Bug

Question asked by zuikov.dmitry on Jan 27, 2012

There is bug in USB Host library that causes to wrong behavior if the attached device has more that one interface. EP properties for interface 0 is overriding by the values for next interfaces.   

There is also a problem that if there are more interfaces that value of USBH_MAX_NUM_INTERFACES then library will not work at all. For me there is no reason for such behavior, it's perfect if it will fork with first USBH_MAX_NUM_INTERFACES ignoring rest of them (there is no patch for this yet).

--- a/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_HOST_Library/Core/src/usbh_stdreq.c
+++ b/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_HOST_Library/Core/src/usbh_stdreq.c
@@ -77,7 +77,7 @@ static void USBH_ParseDevDesc (USBH_DevDesc_TypeDef* , uint8_t *buf, uint16_t le
 static void USBH_ParseCfgDesc (USBH_CfgDesc_TypeDef* cfg_desc,
                                USBH_InterfaceDesc_TypeDef* itf_desc,
-                               USBH_EpDesc_TypeDef*  ep_desc,                                                          
+                               USBH_EpDesc_TypeDef  ep_desc[USBH_MAX_NUM_INTERFACES][USBH_MAX_NUM_ENDPOINTS], ^M
                                uint8_t *buf,
                                uint16_t length);
 static  USBH_DescHeader_t      *USBH_GetNextDesc (uint8_t   *pbuf,
@@ -156,7 +156,7 @@ USBH_Status USBH_Get_CfgDesc(USB_OTG_CORE_HANDLE *pdev,
     /* Commands successfully sent and Response Received  */      
     USBH_ParseCfgDesc (&phost->device_prop.Cfg_Desc,
-                       phost->device_prop.Ep_Desc[0],
+                       phost->device_prop.Ep_Desc, ^M
@@ -356,7 +356,7 @@ static void  USBH_ParseDevDesc (USBH_DevDesc_TypeDef* dev_desc,
 static void  USBH_ParseCfgDesc (USBH_CfgDesc_TypeDef* cfg_desc,
                                 USBH_InterfaceDesc_TypeDef* itf_desc,
-                                USBH_EpDesc_TypeDef*  ep_desc,
+                                USBH_EpDesc_TypeDef  ep_desc[USBH_MAX_NUM_INTERFACES][USBH_MAX_NUM_ENDPOINTS], ^M
                                 uint8_t *buf,
                                 uint16_t length)
@@ -409,7 +409,7 @@ static void  USBH_ParseCfgDesc (USBH_CfgDesc_TypeDef* cfg_desc,
                 pdesc = USBH_GetNextDesc((void* )pdesc, &ptr);
                 if (pdesc->bDescriptorType   == USB_DESC_TYPE_ENDPOINT)
-                  pep               = &ep_desc[ep_ix];
+                  pep               = &(ep_desc[if_ix][ep_ix]);^M
                   USBH_ParseEPDesc (pep, (uint8_t *)pdesc);