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_host_msc

I am porting the starterWare usb_host_msc over to my own bare metal platform. I use the RVDS4.1 compiler. Anyway, it is all ported and my platform gets to the NODEV>  prompt but when I insert a thumb drive the call back function, MSCCallback, is not called. Is there some sort of OS Timer or something running when I load the CCS version of usb_host_msc through JTAG that I am missing? My platform works great if I load usb_host_msc through JTAG under CCS.

Thanks for any hints,  Brad

  • Sorry brad, i am not clear on your exact problem. the last line says that your application works with CCS. Can you please clarify.

    Regards

    Baskaran

  • I got usb_host_msc to work on my platform (GNSS receiver) using CCS and loading through JTAG. I then moved all required libraries over to the compiler we use for production (RVDS4.1). I merged usb_host_msc into my application on my platform. This platform runs our own boot code also. In the process, after much debugging, I have found what appears to be some sort of race condition or a need to check some kind of status. I assume this does not show up under JTAG since many clocks are running slower than my production board. I modified usbhostenum.c as follows:

    USBHCDPipeWrite(unsigned int ulIndex, unsigned int ulPipe,
                          unsigned char *pucData, unsigned int ulSize)
    {
        unsigned int ulEndpoint;
        unsigned int ulRemainingBytes;
        unsigned int ulByteToSend;
        unsigned int ulPipeIdx;

    #ifdef DMA_MODE
        unsigned int txBuffer;
        unsigned int nBlocks;
        unsigned int ulLength;
    #endif

    #if defined(USB_DELAY_HACK)
    //    TxString(2,"PipeWrite\r\n"); //Seems to insert a critical delay
        delay(1);  //delay 1 ms
    #endif

    AND usbhscsi.c as follows:

    USBHSCSISendCommand(unsigned int ulIndex, unsigned int ulInPipe,
                                  unsigned int ulOutPipe, tMSCCBW *pSCSICmd,
                                  unsigned char *pucData, unsigned int *pulSize)
    {
        tMSCCSW CmdStatus;
        unsigned int ulBytes;

        //
        // Initialize the command status.
        //
        CmdStatus.dCSWSignature = 0;
        CmdStatus.dCSWTag = 0;
        CmdStatus.bCSWStatus = SCSI_CMD_STATUS_FAIL;

        //
        // Set the CBW signature and tag.
        //
        pSCSICmd->dCBWSignature = CBW_SIGNATURE;
        pSCSICmd->dCBWTag = CBW_TAG_VALUE;

        //
        // Set the size of the data to be returned by the device.
        //
        pSCSICmd->dCBWDataTransferLength = *pulSize;

        //
        // Send the command.
        //
    #if defined(USB_DELAY_HACK)
    //    TxString(2,"SCSI_2\r\n");  //seems to insert a critical delay
        delay(1);  //delay 1 ms
    #endif

    static unsigned int
    USBHSCSISendCommand(unsigned int ulIndex, unsigned int ulInPipe,
                                  unsigned int ulOutPipe, tMSCCBW *pSCSICmd,
                                  unsigned char *pucData, unsigned int *pulSize)
    {
        tMSCCSW CmdStatus;
        unsigned int ulBytes;

        //
        // Initialize the command status.
        //
        CmdStatus.dCSWSignature = 0;
        CmdStatus.dCSWTag = 0;
        CmdStatus.bCSWStatus = SCSI_CMD_STATUS_FAIL;

        //
        // Set the CBW signature and tag.
        //
        pSCSICmd->dCBWSignature = CBW_SIGNATURE;
        pSCSICmd->dCBWTag = CBW_TAG_VALUE;

        //
        // Set the size of the data to be returned by the device.
        //
        pSCSICmd->dCBWDataTransferLength = *pulSize;

        //
        // Send the command.
        //
    #if defined(USB_DELAY_HACK)
    //    TxString(2,"SCSI_2\r\n");  //seems to insert a critical delay
        delay(1);  //delay 1 ms
    #endif

    I HAVE NOT TRIED USING LESS THAN 1ms yet and I am using DMA_MODE. Not using DMA_MODE made no difference.

    Further, I went through the same porting procedure with usb_dev_serial and had NO PROBLEMS doing that at all, it worked great right away.

  • Brad,

                There can be 2 possibilities

              1. Your bootloader is missing something which is done by gel file

              2. Race condition as you mentioned- to confirm this after loading your application try "free run" (menu->run->free run)  instead of "run". This should not induce any delay, so you should see the problem here too.

    Regards

    Baskaran

  • I reduced the 3 delays I mentioned from 1ms to 1us. This greatly improved the initial response time on the file system ls command. Anyway, I am sure with some work the problem can be narrowed down further.

    In my GEL file I run my CPU at 500MHz --- in my boot loader I am set up to run at 720MHz, so I could slow down my cpu and see what that does.

  • The problem seems to be related to USBHSCSISendCommand in usbhsci.c. I put a 1 micro-second delay before each call to USBHSCSISendCommand (8 places in usbhsci.c) and I do not have any problems.

    Lowering my cpu speed to 500MHz from 720MHz was of no help.

  • oops --- the file I modified is usbhscsi.c NOT usbhsci.c

  • So I fixed a handful of warnings that popped up when migrating from CCS to RVDS4.1 and the problem went away.