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.

USBLIB Custom Host Class

Other Parts Discussed in Thread: AM3359

Hi,

We need to have an example of the USBLIB used in StarterWare with plain Host control and bulk endpoints in order to communicate with our own external USB device.

Our solution will have the AM3359 as host and our USB external device.

Until now we have seen HID and MSC host class examples in usblib, yet a simple custom host implementation looks really perplexed in the way usblib is structured right now.

Is there any pointer or sample/example for us with a simple bulk endpoints host application where we can start with?

We need to do simple tasks from our host (AM3359) application, eg

1. Identify if our board is connected on the AM3359 USB controller and open a handle to it

2. Configure and open bulk endpoints/pipes

3. Read/Write on the endpoints/pipes

4. Close the handle when we finish

Thanks for any help.

Christos

  • It looks quite dissapointing to see the StarterWare so thin in that crucial part and nobody from TI to even give a reply here.

    Also in the Stellaris usblib (which is actually the USB module in StarterWare), that part is missing for a long time and is asked by many but nothing has been done from TI so far.

    I cant seem to recollect any similar tool from any vendor, not to have a plain bulk endpoints host example,  thats a usblib first and it caught me by surprise.

    It looks that developing in Sitara for anything with a commercial value appart from toying examples, cannot be done with the provided StarterWare, so we have to allocate budget for one of the three standalone third party solutions (QNX/Mentor/WinDriver) unless TI has the will to move towards strengthening the StarterWare.

    Regards,

    Christos

  • Hi Christos,

    My apologies for this late reply. Yesterday was a Holiday for us and hence the delay. 

    There is no example in StarterWare USB which directly fits your requirement and we would certainly consider this requirement for our future releases. Currently , the usb_host_msc example would need to be modified slightly to be used to suit your need. There are 2 ways you can go about this

    1. Write a custom driver on the lines of the MSC driver (..\usblib\host\usbhmsc.c) which is called when your device reports custom descriptors to the host. 

    Basically you would end up writing functions similar to USBHMSCOpen() and USBHMSCClose() .

    2. Hack the current usb_host_msc example to suit your needs. This involves your custom device reporting itself as a Mass storage device using the descriptors.

    The second is a quick and dirty solution and I believe you can try this first.Once you have got code flow the writing the custom driver would be easier . 

    Code flow in usb_host_msc example

    If you refer  ..\examples\evmAM335x\usb_host_msc\usb_host_msc.c  there is a function called as ReadLine(void) which repeatedly calls USBHCDMain()  to enumerate and bring up any device connected. 

    USBHCDMain( ) is defined in ..\usblib\host\usbhostenum.c. In this function the device state machine moves through the following states

    HCD_DEV_RESET -> HCD_DEV_CONNECTED -> HCD_DEV_ADDRESSED ->  HCD_DEV_CONFIGURED. After the device ( in your case your custom device) has been configured the code goes on to call USBHCDOpenDriver () defined in ..\usblib\host\usbhostenum.c . The purpose of this function is to open your class driver.

    In the current code USBHCDOpenDriver () opens the USBHMSCOpen () defined in (..\usblib\host\usbhmsc.c). It is this function which reads the endpoint descriptors ( as reported by your custom device) and sets up the pipes.  

    These pipes can be used to send data using the 2 BULK endpoints.

    After setting up the pipes the control comes back to the  ReadLine(void)  and ends up calling  the USBHMSCDriveReady() // line 1386. 

    This function is defined in ..\usblib\host\usbhmsc.c and goes on to send the initial SCSI commands.  Since your's is a custom device you need to stub this function and write your own.

    To read and write data to the device you would need to use

    unsigned int USBHCDPipeWrite()

     unsigned int USBHCDPipeRead ()

    In order to get the parameters for the pipe read/write functions please follow the call chain of any SCSI command being sent to the device

    as in USBHMSCDriveReady () 

    eg

    USBHSCSIRequestSense(pMSCDevice->ulIndex, pMSCDevice->ulBulkInPipe, pMSCDevice->ulBulkOutPipe, pBuffer, &ulSize) 

    hope this helps!

  • Thanks Vineeth for the reply and your effort on this.

    Its comforting at least to see that you do understand the situation and try to help.

    IMHO its a long shot, since there is nothing that assures us it will work without consuming excess time from us.

    Also, I did a bit of search nowadays and it looks that there could be more issues up ahead, eg DMA support in USB highspeed from usblib, which is something that is not so clear here.

    Anyway, your effort is appreciated indeed and thank you for this, your pointers shed some light, we are already trying in this general direction for a couple of weeks now but we havent reach a result yet.

    Thanks & regards,

    Christos