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.

PROCESSOR-SDK-AM335X: Use of USB as bulk mode in linux to exchange data with PC

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: AM3358

I have AM3358 based custom built board. I am using Linux SDK provided by TI.

I have to use USB in bulk mode to transfer data with PC. 

Is there any specific document. article etc available which explain configuration, modification in Linux kernel/drivers to use USB as bulk. 

  • Vivek,

    The linux kernel provides several USB gadget drivers which use bulk transfer. You can pick one which works for your use case.

    The kernel Documentation/usb/ has some details.

  • Bin Liu said:

    Vivek,

    The linux kernel provides several USB gadget drivers which use bulk transfer. You can pick one which works for your use case.

    The kernel Documentation/usb/ has some details.

    Bin Liu said:

    Vivek,

    The linux kernel provides several USB gadget drivers which use bulk transfer. You can pick one which works for your use case.

    The kernel Documentation/usb/ has some details.

    Hello

    I am also searching for the same. When I installed default linux available from TI and connected the device to PC, I observed that the device is not getting detected at all.
    Is there any where setting required so that the device gets detected?
    Also how can I use the gadget device as USB bulk device, I did not find any source file in kernel gadget device source which correspond to bulk device.
    There are other files which I believe relate to serial device.

    Bin Liu said:

    Vivek,

    The linux kernel provides several USB gadget drivers which use bulk transfer. You can pick one which works for your use case.

    The kernel Documentation/usb/ has some details.

  • Shailendrakumar Mehta said:
    When I installed default linux available from TI and connected the device to PC, I observed that the device is not getting detected at all.
    Is there any where setting required so that the device gets detected?

    You need to ensure a USB gadget driver is loaded otherwise the USB host won't be able to detect it.

    Shailendrakumar Mehta said:
    Also how can I use the gadget device as USB bulk device, I did not find any source file in kernel gadget device source which correspond to bulk device.

    This is no such thing called USB bulk device. Bulk is one of the USB transfers, which are used in USB devices, for example, g_mass_storage.

    As I mentioned in my first post, you either pick a USB gadget driver in the kernel which works for your use case, or implement your own gadget driver if you use a customized USB protocol.

  • Dear Bin Liu

    Thank you for the response.

    I went through Linux kernel documentation and loaded drivers g_zero and usb_f_ss_lb to test.

    I could see the drivers loaded but if I run testusb, it does not detect anything.

    Could you please direct me to proper documentation in this regards?

    Some more inputs

    1. When I loaded g_zero dmesg shows "udc-core: could not find an available UDC - added [g_zero] to list of pending drivers"

    2. I did not change recompile the kernel and using it as is.

    3. I tried the same on Linux host too for simplicity but getting similar error.

    4. Checked below thread but since I am new to Linux, I did not get what is being tried here.

    https://e2e.ti.com/support/processors/f/791/t/826346?tisearch=e2e-sitesearch&keymatch=gadget%25252525252525252520device

  • Hi,

    Shailendrakumar Mehta said:
    I went through Linux kernel documentation and loaded drivers g_zero and usb_f_ss_lb to test.

    This is a great progress!

    Shailendrakumar Mehta said:
    1. When I loaded g_zero dmesg shows "udc-core: could not find an available UDC - added [g_zero] to list of pending drivers"

    You have to have one AM335x USB port to be configured as USB peripheral port.

    Shailendrakumar Mehta said:
    3. I tried the same on Linux host too for simplicity but getting similar error.

    g_zero is for USB gadget, it will never run on USB host.

  • Dear Bin Liu

    You have to have one AM335x USB port to be configured as USB peripheral port.

    > How can I do this?

    g_zero is for USB gadget, it will never run on USB host.

    > Is it possible to configure host as a peripheral by any setting?

  • First please check your board design to ensure the USB port which you want to connect to USB host is designed as a USB peripheral port. Then you can follow the two wiki pages below for the kernel configuration.

    https://processors.wiki.ti.com/index.php/MUSB_Linux_Driver_Configuration

    https://processors.wiki.ti.com/index.php/MUSB_Linux_Porting_Guide

  • Thank you.

    I will go through this.

    last query

    1. How can I ensure that the USB port which you want to connect to USB host is designed as a USB peripheral port?

    2. Also you said that Host can not be configured as device. But then I am not clear why gadget driver is available in my Ubuntu?

    Is there any way to configure it somehow?

  • Shailendrakumar Mehta said:
    1. How can I ensure that the USB port which you want to connect to USB host is designed as a USB peripheral port?

    You can read the TRM USB chapter to understand what are required for peripheral port in the board design, and you can use the EVM schematics as a reference.

    Shailendrakumar Mehta said:
    2. Also you said that Host can not be configured as device. But then I am not clear why gadget driver is available in my Ubuntu?

    Ubuntu is a software, it doesn't know what platform you will run it on, so it will provide any software or kernel driver which is available. Does it make sense?

  • Dear Bin Liu

    Thank you for the clarification.

    Regarding point-2, you mean even though Ubuntu provides the driver doesn't mean that it "can not be" configured as peripheral.

    Am I right?

  • Yes, I meant that even if Ubuntu provides the USB gadget driver, but the USB port still cannot work in peripheral mode if the USB port is designed as host-only port in hardware design.

    It is like Ubuntu provides Nvidia card video driver, but loading the driver won't do anything if your PC only has Intel video card.

  • Thank you for your reply.

    Once I have gadget driver loaded and device is detected, can you please share information / link to the material for

    1. Application to access the gadget driver on board so that data can be exchanged with host 

    2. Host driver(preferably windows but Linux is fine)  to communicate with board

  • Hi,

    These queries are out of our support scope, they are generic LInux questions and are not related to TI devices.

    But I just want to point out that you probably won't be able to use the g_zero gadget driver do to what you want to do, since g_zero is meant for USB kernel stack testing, not for generic application use. You would either have to pick a different kernel USB gadget driver or implement a new one depending on the USB protocol you want to use.

  • Thank you.

    I understood that there is a different driver needed to achieve what I am trying to do. There is very limited documentation available on this topic. Can I at least know how the drivers provided with TI linux are intended to be used? I have seen many drivers like f_sourcesink.c, g_zero etc. in source tree but I didn't  find any documentation which points to how these drivers are intended to be used.

    Any help in this regards is welcome. Thank you.

  • Hi,

    Since the kernel internals change rapidly in everyday or every week, there is impossible to document it in details. So the best way to understand the Linux kernel is to read its source code and follow the discussions on the kernel mailing lists.

    Back to your specific question - how the USB gadget drivers are intended to be used? they are implementing the standard USB device classes defined by USB-IF (you can find the details on www.usb.org). For example, f_mass_storage.c implements the mass storage class. As its name - zero, g_zero driver is a kind of dummy driver, it is used for validating the USB stack in the Linux kernel.

  • Dear Bin Liu

    Thank you for your support so far.

    I will have a look at the information provided by you.

    Have a good day!

    Best regards

    Shailendra