AnsweredAssumed Answered

STM32F407 USB FS (MSC). Write hangs on USB flash drive

Question asked by antoshchenkov.roman on Dec 7, 2012
Latest reply on Dec 10, 2012 by antoshchenkov.roman
Hello! I am develop data aquisition system project on STM32F407. USB flash drive connected to USB host (OTG FS). Project based on sample from stm32_f105-07_f2_f4_usb-host-device_lib.zip. Ide is CooCox 1.6.0.

Data writes to drive by blocks 32kB each 300 ms.
After 3-11 writes to drives program hangs on next code:
file: usbh_msc_bot.c
void USBH_MSC_HandleBOTXfer (USB_OTG_CORE_HANDLE *pdev ,USBH_HOST *phost)
{
     ....
 case USBH_MSC_DECODE_CSW:
      URB_Status = HCD_GetURB_State(pdev , MSC_Machine.hc_num_in);
      /* Decode CSW */
      if(URB_Status == URB_DONE)
      {
        BOTStallErrorCount = 0;
        USBH_MSC_BOTXferParam.BOTStateBkp = USBH_MSC_RECEIVE_CSW_STATE;
        
        USBH_MSC_BOTXferParam.MSCState = USBH_MSC_BOTXferParam.MSCStateCurrent ;
        
        USBH_MSC_BOTXferParam.BOTXferStatus = USBH_MSC_DecodeCSW(pdev , phost);
      }
      else if(URB_Status == URB_STALL)     
      {
        error_direction = USBH_MSC_DIR_IN;
        USBH_MSC_BOTXferParam.BOTState  = USBH_MSC_BOT_ERROR_IN;
      }

HCD_GetURB_State(...) return URB_Status = URB_IDLE, which is not processed.
Is it USB Flash drive error? How can I solve the problem?

Outcomes