I developed usb host driver for MSD by BF527 Analog Device.
I guess you can try work without getting string descriptor, cause this descriptor is not so important. Besides, some flash is not supported string request.
This is a part of my enumeration code)
static s32_t GetOtgStringDescriptor (USB_OTG_STRING_INFO *pUsbStringInfo)
{
USB_EP_INFO *pEpInfo = &pUsbCoreData->pDeviceHead->pEndpointZeroObj->EPInfo;
s32_t ret;
PDEVICE_OBJECT pDevO = pUsbCoreData->pDeviceHead;
memset (pUsbOtgHostData->pSetupPkt, 0, sizeof(SETUP_PACKET));
pUsbOtgHostData->pSetupPkt->bmRequestType = USB_DIR_DEVICE_TO_HOST | USB_TYPE_STANDARD | USB_RECIPIENT_DEVICE;
pUsbOtgHostData->pSetupPkt->bRequest = USB_STD_RQST_GET_DESCRIPTOR;
pUsbOtgHostData->pSetupPkt->wValue = (((TYPE_STRING_DESCRIPTOR << 0x08) & 0xffff) | (pUsbStringInfo->dwStringIndex & 0xff) );
pUsbOtgHostData->pSetupPkt->wIndex = ((pUsbOtgHostData->dwLanguageID >> 16) & 0xffff);
pUsbOtgHostData->pSetupPkt->wLength = 255;
pEpInfo->EpState = EP_STATE_IDLE;
/* Puts the EpZero endpoint state machine in EP_STATE_SETUP_RQST_PHASE */
pEpInfo->EpStateMachineHandler (pDevO, 0, (void*)pUsbOtgHostData->pSetupPkt);
ret = SendEpZeroDataEx (pUsbCoreData->pDeviceHead, (u8*)pUsbOtgHostData->pSetupPkt, SETUP_PACKET_LEN);
pDevO->pSetupData = pDevO->pSetupDataArea;
pEpInfo->TransferSize = 255;
pUsbOtgHostData->eDepState = DEP_GET_STRING_DESCRIPTOR;
/* Move from SETUP RQST phase to data phase. Send IN token in case you are expecting data */
pEpInfo->EpStateMachineHandler (pDevO, 0, (void*)pUsbOtgHostData->pSetupPkt);
return (ret);
}
// That is a little bit of Enumeration Process code
case DEP_GET_CONFIG_DESCRIPTOR_1:
{
.....
memset(pUsbOtgHostData->pSetupPkt,0,sizeof(SETUP_PACKET));
pUsbOtgHostData->pSetupPkt->bmRequestType = USB_DIR_DEVICE_TO_HOST | USB_TYPE_STANDARD | USB_RECIPIENT_DEVICE;
pUsbOtgHostData->pSetupPkt->bRequest = USB_STD_RQST_GET_DESCRIPTOR;
pUsbOtgHostData->pSetupPkt->wValue = ((TYPE_STRING_DESCRIPTOR << 0x08) & 0xffff);
/* Index 0 implies we are getting the default language descriptor 0409 - English - United States
* For more information about language descriptors ref:
http://www.usb.org/developers/docs/USB_LANGIDs.pdf */
pUsbOtgHostData->pSetupPkt->wIndex = 0x0000;
pUsbOtgHostData->pSetupPkt->wLength = 255;
pEpInfo->EpState = EP_STATE_IDLE;
/* Puts the EpZero endpoint state machine in EP_STATE_SETUP_RQST_PHASE */
pEpInfo->EpStateMachineHandler(pDevO,0,(void*)pUsbOtgHostData->pSetupPkt);
ret = SendEpZeroDataEx(pDevO,(u8*)pUsbOtgHostData->pSetupPkt,SETUP_PACKET_LEN);
pUsbOtgHostData->eDepState = DEP_GET_STRING_DESCRIPTOR;
pDevO->pSetupData = pDevO->pSetupDataArea;
pEpInfo->TransferSize = 0x04;
/* Move from SETUP RQST phase to data phase. Send IN token in case you are expecting data */
pEpInfo->EpStateMachineHandler(pDevO,0,(void*)pUsbOtgHostData->pSetupPkt);
/* Set the current string index to zero */
dwCurrentStringIndex =0;
}
break;
/*
* Get all string descriptors. String descriptor indexs are stored from the previous get
* device, configuraiton descriptor data.We stay in this state until we get all string
* descriptors.
*/
case DEP_GET_STRING_DESCRIPTOR:
{
pEpInfo->EpNumTotalBytes = pEpInfo->TransferSize = *((u8_t*)pBuffer->Data);
/* Request has been sent now move to Status phase */
pEpInfo->EpStateMachineHandler(pDevO,0,(void*)pBuffer);
/* move from data phase to IDLE */
pEpInfo->EpStateMachineHandler(pDevO,0,(void*)pBuffer);
/* We got the LANGID */
if(!dwCurrentStringIndex)
{
// copy the language ID
memcpy ((char*)&pUsbOtgHostData->dwLanguageID,(char*)pBuffer->Data, 4);
if (pUsbOtgHostData->dwMaxStringIndex > 0)
{
GetOtgStringDescriptor (&pUsbOtgHostData->StringInfo[dwCurrentStringIndex]);
dwCurrentStringIndex++;
break;
}
}
else if (dwCurrentStringIndex <= pUsbOtgHostData->dwMaxStringIndex)
{
// we have a string descriptor to process
memcpy((u8_t*)&pUsbOtgHostData->StringInfo[dwCurrentStringIndex-1].StringData,(u8_t*)pBuffer->Data,pBuffer->ProcessedElementCount);
if(dwCurrentStringIndex < pUsbOtgHostData->dwMaxStringIndex)
{
GetOtgStringDescriptor(&pUsbOtgHostData->StringInfo[dwCurrentStringIndex]);
dwCurrentStringIndex++;
break;
}
}
pUsbOtgHostData->eDepState = DEP_DEV_ENUMERATED;
pEpInfo->EpState = EP_STATE_IDLE;
}