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.

AM4372: USB Vendor class implementation on linux

Part Number: AM4372
Other Parts Discussed in Thread: AM4382, AM4378

Hi TI Team,

I am working on TI 438x processor board (TMDXEVM438X-EPOS). And it is running on linux os. Due to security reason i have to put part number am4372, I think for usb class there is no difference between am4732 and am4382.

I want to make this board as a usb device and want to implement usb vendor class on it.

So how can i achieve this?  Which driver i have to use? where i can find it?  I had installed BSP - "ti-processor-sdk-linux-am438x-epos-evm-05.02.00.10" into my system.

Regards,

Dhananjay

  • Hi Dhananjay,

    What is the USB vendor class you want to implement? Is it a standard class defined by USB-IF? The Linux kernel implements most (if not all) standard classes under folder drivers/usb/gadget/. If there doesn't have the gadget function you need, you can implement your own gadget driver there.

    By the  way, when you start a new project, please use the latest Processor SDK Linux release (currently v06.01.00.08) to get the best support.

  • Hi Bin Liu,

    >>What is the USB vendor class you want to implement? Is it a standard class defined by USB-IF? 

    --Usb vendor class is defined by USB-IF and class code is 0xFF. This base class is defined for vendors to use as they please. And the USB specification allows the creation of completely custom USB devices which do not conform to any other of the USB device class standards.

    >>The Linux kernel implements most (if not all) standard classes under folder drivers/usb/gadget/.

    --There is not example for vendor class.

    In  my vendor class, there are some command that device support and using control transfer. So how can I implement this functionality?

    Please provide example code.And where to implement this custom command??

    >>By the  way, when you start a new project, please use the latest Processor SDK Linux release (currently v06.01.00.08) to get the best support.

    --If I make a sd card using this sdk, if this will work on my board?? This sdk is for am65xx. This sdk's uboot and kernel will not work in my board. Please correct me if i am wrong. 

    Thanks,

    Dhananjay

  • Hi Bin Liu,

    Waiting for your reply. 

    Thanks,

    Dhananjay

  • The USB Vendor class is not a standard class. Specification and implementation of a vendor USB interface is up to the implementor (== you).

    So, you have to write your own vendor-specific gadget driver.

    Writing the gadget driver is only half of the work: someone will have to write the vendor-specific host driver, too. (Or you can use libusb and write your host driver in userspace).

    Hint: sometimes it is better to use a standard class like ACM (which is similar to a serial port) and implement your own protocol on top of it. Makes life easy.

    regards

    Wolfgang

  • Hi Wolfgang,

    Thanks for your response for helping this forum, appreciated it.

  • Dhananjay Chauhan said:

    >>The Linux kernel implements most (if not all) standard classes under folder drivers/usb/gadget/.

    --There is not example for vendor class.

    Please see Wolkgang's post above.

    Dhananjay Chauhan said:
    Please provide example code.And where to implement this custom command??

    Please use drivers/usb/gadget/* in kernel code as an example.

    Dhananjay Chauhan said:
    --If I make a sd card using this sdk, if this will work on my board?? This sdk is for am65xx. This sdk's uboot and kernel will not work in my board. Please correct me if i am wrong. 

    Very likely it won't. You have to do the same porting as you did when using SDK v5.02.

    You shouldn't use AM65xx SDK on AM4378. There is a SDK for AM437x which you can download from ti.com.

  • Hi Bin Liu and Wolkgang

    Thanks, this works for me. 

    I am using configfs and functionfs to make vendor specific driver and successfully configure gadget by the following script. And got detected gadget on host side.

    I am using ffs-test program for gadget app which is given in  (tools/usb/) directory. And using simple libusb command for testing as given in above pdf . But bulk transfer command keep failing. 

    This is my host side app:

    "

    unsigned char buf[64];

    int actual_length;

    do {
    /* Receive data from the device */
    res = libusb_bulk_transfer(handle, 0x81, buf,sizeof(buf), &actual_length, 100000);
    if (res < 0) {
    fprintf(stderr, "bulk transfer (in): %s\n",libusb_error_name(res));
    return 1;
    }
    } while (res >= 0);

    "

    And error is 

    "bulk transfer (in): LIBUSB_ERROR_OVERFLOW

    Is there is any more configuration needed on gadget side or any other changes on ffs-test or host app side??  

  • Please connect a USB protocol analyzer to capture the bus trace to see how the transfer looks like.

    I barely do libusb programming, what the libusb documentation says about "LIBUSB_ERROR_OVERFLOW"?

  • Hi,

    Thanks for your help, but today i finally made it work. I used aio-simple example and it worked succefully.

  • Thanks for sharing the solution. It will helps others who have the similar query,