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.

RTOS/PROCESSOR-SDK-AM335X: RTOS/PROCESSOR-SDK-AM335X: USB access to SD card has something wrong

Part Number: PROCESSOR-SDK-AM335X

Tool/software: TI-RTOS

Hi Experts,

Based on the 

We found that sometimes the host (Android) cannot mount the MSC device (AM335x) via USB.

And we have reproduced this issue with SKAM335x board & sample code, provied by FAE Luke.

Please help us to solve this issue. Thank you !! 

Note : The following files are usb records captured by the usb analyzer.

USB_TI_NG_01.usb

USB_TI_NG_02.usb

USB_TI_NG_02_USB_Plug_Out.usb

Regards,
Eten

  • Here I added more detail description about this issue.

     

    [Device]

    Hardware: AM335x Starter Kit

    Software: PROCESSOR-SDK-RTOS-AM335X 05_02_00_10

    Running this example: USB_DevMsc_mmcsd_evmAM335x_armExampleProject

    With below patch(mentioned in this post ):

    C:\ti\pdk_am335x_1_0_13\packages\ti\drv\mmcsd\src\v1\MMCSD_v1.c @line 721
    
    original:
       MMCSD_osalDeleteBlockingLock(object->transferComplete);
       memset(object, 0, sizeof(MMCSD_v1_Object));  
    
    modified:
       MMCSD_osalDeleteBlockingLock(object->transferComplete);
    #ifdef MMCSD_EDMA_ENABLED
       MMCSD_osalDeleteBlockingLock(object->writeSem);
       MMCSD_osalDeleteBlockingLock(object->readSem);
    #endif
       memset(object, 0, sizeof(MMCSD_v1_Object));    

     

    [Host]

     ARM Cortex A7 IVI (In Vehicle Infotainment) running Android 4.4.4

     

    [Steps]

    1. Use CCS to load USB_DevMsc_mmcsd_evmAM335x_armExampleProject.out to AM335x SK.

    2. Connect then Plug/Unplug USB cable between AM335x SK and the Android Host.

    3. Everytime after cable plugged, check if Android Host successfully enumerates AM335x’s SD as MSC(mass storage class).

      

    [Result]

     Occasionally Android Host is unable to enumerate MSC successfully. The possibility is about 7% (2 failures observed in 30 tests).

     The USB capture (by LeCroy Advisor T3) of failure cases has been provided in the beginning of this post. Normally a transaction is IN-DATA-ACK. It seems AM335x replys strange data (512bytes) while receiving HOST’s IN, HOST did not recognize the data so HOST did not send ACK in the transaction.

    For your convenience to compare, hereunder is the successful case.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/USB_5F00_TI_5F00_OK.7z
     

    [PS]

    1. A similar issue was reported before, but this one is different. Previous issue is not recoverable, once it occurs, AM335x needs power cycle to recover. This issue is recoverable. Once it happens, unplug/plug usb cable again can make Android HOST re-enumerate MSC successfully.

    2. This issue can NOT be reproduced if using a Windows PC as host (no issue found during 60 tests)

    3. This issue can be reproduced if the host is Android 5.1.1 or 6.0.1. Can NOT be reproduced if the host in Android 8.x

  • And we found that the source code of the file.

    pdk_am335x_1_0_6\packages\ti\drv\usb\src\usb_func\device\usbdmsc.c

    static void
    HandleDisconnect(void *pvInstance)
    {
        const tUSBDMSCDevice *psDevice;
    
        memset(&g_sSCSICSW, 0, sizeof(g_sSCSICSW));
    
        /*
         * Create the instance pointer.
         */
        psDevice = (const tUSBDMSCDevice *)pvInstance;
        psDevice->psPrivateData->ucSCSIState = STATE_SCSI_IDLE;
    
            debug_pf("USBdmsc disconnect. Tx Size:%d\n", psDevice->psPrivateData->ulBytesToTransfer);
       psDevice->psPrivateData->ulBytesToTransfer = 0;
        psDevice->psPrivateData->ulCurrentLBA = 0;
    

    In normal case, the value, psDevice->psPrivateData->ulBytesToTransfer, is zero ( when to unplug the USB cable and to re-plug it )

    But in abnormal case, this value is not zero.

    Regards,
    Eten

  • Hi Eten, Luke

    We wanted to let you know that we are working on this at high priority and will keep you posted on the progress.

    Status from today's debug 

    1.We tried an old Android phone (OS 5.0.1) and was not able to reproduce issue

    2.  We analyzed the USB good and failure case traces: After received data in, in the working case device sends 36 bytes to host after some data preparation (~8 ms), then get ACK from host. The failure case the device sends 512 bytes of 00 instantly to host and host can't recognize it. It appears that the TX packet ready bit not cleared properly and garbage data sent out right away.

    We are currently working on following : 

    - Find more Android phones/hosts (Preferred 5.1.1, 6.0.1 OS) to reproduce the issue

    - USB driver code review with driver developers (already involved in the debug) on USB disconnection, CPPI DMA clean up parts of the code.

    Regards

    Mukul 

     

  • Hi Eten, Luke:

    We have been able to reproduce the problem and are debugging this. We will update you the progress.

    Regards, Eric
  • Hi Eric,

    We are requested to fix the issue by 3/6 by our customer. Now the fix date is late.
    We need to feedback to our customer when TI can fix the issue.
    Could you provide the fix and verification schedule?
    Thanks!

    Best Regards,
    Benson
  • Benson,

    Our engineers worked hard on this and fixed the issue! We tested locally and shared the code with local FAE, he was also able to build and verify the fix. The FAE will contact you with the code change needed for you verification.

    Regards, Eric

  • Benson,

     

    The fix is attached. It’s on top of PDK 1.0.13 (processor_sdk_rtos_am335x_5_02_00_10). Please give it a try and give us feedback.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/pdk_5F00_am335x_5F00_1_5F00_0_5F00_13.mod.with_5F00_orig.7z

    Best Regards,

  • Hi Eric, Mukul, and Luke,

    We have tested the fix more than 100 times successfully so far.

    Thanks for your support.

    Regards,
    Eten