This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB Pipe stalls on certain USB sticks

Hi,

       On certain USB sticks when the USB lib goes to read to stick size (i think it is command 12), I end up with a pipe stall. The command does get sent out but when the code goes to read the sticks response, the pipe goes into a stalled state. We do not have DMA_MODE enabled. Do certain sticks require DMA ? What else could be going wrong?

Thanks,

     John C.

  • Hello John,

    No you do not need DMA_MODE enabled for usb sticks to work.Setting the  DMA_MODE flag enables the internal USB DMA( to AM335x) and this module takes care of moving data in and out of the ( Mentor USB )USB Host/device controller. 

    Now I am assuming you have used the satrerware usb_host_msc example to verify this . The command that you have indicated is a SCSI command used to fetch device details during the SCSI initialization and should not be failed by the device. Are you using a standard USB stick? 

    Also please use the latest revision of the starterware code base (02.00.00.07).

  • Hello John,

    To add to that which pipe got stalled the BULK IN pipe ?

  • Hi Vineeth,

                     Thanks for getting back to me. Here is some more info.

    - We are using AM335X_StarterWare_02_00_00_07

    - We have seen this in several standard usb sticks (other usb sticks have no problem) and also if you use a ScanDisk SD Card via a USB adapter.

    - When it reads the USBHSCSIReadCapacity() the same sequence can be seen:

        *((unsigned int *)&SCSICmd.CBWCB[0]) = SCSI_READ_CAPACITY;
        *((unsigned int *)&SCSICmd.CBWCB[4]) = 0;
        *((unsigned int *)&SCSICmd.CBWCB[8]) = 0;
        *((unsigned int *)&SCSICmd.CBWCB[12]) = 0;

    USBHSCSISendCommand(unsigned int ulIndex, unsigned int ulInPipe,
                                  unsigned int ulOutPipe, tMSCCBW *pSCSICmd,
                                  unsigned char *pucData, unsigned int *pulSize)

    Data is sent, Pipe goes Idle.

    USBHCDPipeRead(unsigned int ulIndex, unsigned int ulPipe,
                          unsigned char *pucData, unsigned int ulSize)

    Pipe state gets set to Reading
            // Start a read request.
            g_sUSBHCD[ulIndex].USBINPipes[ulPipeIdx].eState = PIPE_READING; (~line#1364)

    Does not enter while loop on line #1369

    g_sUSBHCD[ulIndex].USBHTimeOut.Value.slNonEP0 ==> 0xbb8, Causes StopTimer() call line #1434

    Line #1439 Pipe is in Stalled state.

    g_sUSBHCD[ulIndex].USBINPipes[ulPipeIdx].eState

    ulIndex = 1, ulPipeIdx = 0

    Snip of USB data struct:

    Thanks,

         John C.

  • Hi John,

    Thanks for the detailed response. The Bulk IN Pipe  stalling could be due to the fact that the device in picture does not support the Read Capacity command.  This command returns  the capacity of he drive and the sector size. In order to nail the problem , could you comment out sending this command from the function USBHMSCDriveReady () defined in usbhmsc.c. You also would need to give 

    pMSCDevice->ulBlockSize = 0x200; // most drives have 512 byte sector size

    pMSCDevice->ulNumBlocks  = xxx // number of 512 byte sectors in the drive