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.

Linux/PROCESSOR-SDK-AM335X: USB questions

Part Number: PROCESSOR-SDK-AM335X

Tool/software: Linux

Hi

I have few queries on the USB subsystem and wanted a little clarification. My lInux kernel is 4.9.31.

1. USB DMA (USB_TI_CPPI_DMA) is enabled in my kernel configuration.. so my question is what size FIFO buffer is used? Is buffer size adequate for HS interface data transfer needs?

2. What will be the minimum time for detection of a USB flash drive (default musb controller mode is set to otg in the dtb file)

3. What is the maximum time required to switch between USB host and device modes? For instance, if I need to plug in a USB cable (for RNDIS connection) and quickly plug it out and plug in a USB flash drive then.. how much time do I need to give between for the mode switch to happen (from device to host mode or vice-versa)

4. Considering it is possible to change USB speed (full speed/high speed) using dtb.. if i use a dtb overlay file and then configure this.... i,e initially usb is configured for high speed and during the course of my test, I change it to full speed using dtb overlay. will this work or do I need to reset the USB subsystem (using a command) or reload drivers?

5. If USB device doesn't get detected and I need some info.. will there be any information that I can get from Linux kernel (other than the prints) via sysfs/procfs etc.

6. Finally, the ID pin status is detected in hardware and the information that a flash device is plugged in/a usb cable (RNDIS) is given to the USB driver via an interrupt I suppose. Please confirm.

Regards,

Fariya 

  • Hi Fariya,

    Fariya Fatima said:
    1. USB DMA (USB_TI_CPPI_DMA) is enabled in my kernel configuration.. so my question is what size FIFO buffer is used? Is buffer size adequate for HS interface data transfer needs?

    Not sure which FIFO you meant to - you mentioned USB DMA but typically we don't user term FIFO in DMA context. the USB endpoint FIFO size typically is 512 bytes, which is suitable for high-speed bulk transfers, but some endpoints have 1K and 4K fifo, which are for Isoch transfers. The CPPI DMA date buffers are allocated in DDR by usb class or gadget functions, which size is typically much bigger based on the usecase in each usb function.

    Fariya Fatima said:
    2. What will be the minimum time for detection of a USB flash drive (default musb controller mode is set to otg in the dtb file)

    This is not a simple question :)

    First let's understand how the musb driver works. If the controller is set to otg mode, by default the controller works in peripheral mode waiting for connecting to a USB host. If there was a USB device is plugged in by now, there won't be an interrupt event to tell the controller to go to host mode. So there is a 2-seconds interval timer in the MUSB driver to periodically put the controller into host mode so that it can detect usb device insertion. So this will adds 0~2 seconds delay in USB device detection.

    Now let's look at an USB device. After a device is plugged into the USB host port, it detects the VBUS presence then enable its D+/D- pullup to notify the host. I don't remember the timing defined in the USB Specs, but some USB devices enable their D+/D- pullup very quickly, in milliseconds, while others are very slowly. I think I saw one USB device enable its D+ in about 7 seconds.

    Fariya Fatima said:
    3. What is the maximum time required to switch between USB host and device modes? For instance, if I need to plug in a USB cable (for RNDIS connection) and quickly plug it out and plug in a USB flash drive then.. how much time do I need to give between for the mode switch to happen (from device to host mode or vice-versa)

    Other than the timing mentioned above for Q2, the time also depends on the VBUS discharge time which varies due to the board design of the VBUS discharge path. As soon as VBUS is discharged to below VBUS_VALID threshold, the controller is ready to switch from one mode to another.

    Fariya Fatima said:
    4. Considering it is possible to change USB speed (full speed/high speed) using dtb.. if i use a dtb overlay file and then configure this.... i,e initially usb is configured for high speed and during the course of my test, I change it to full speed using dtb overlay. will this work or do I need to reset the USB subsystem (using a command) or reload drivers?

    I haven't experienced with dt overlay yet. But if the dt maximum-speed property is changed, you have to reload the musb_dsps driver to change the speed. You can either use modprobe to reload the driver, or just use the sysfs unbind/bind command.

    Fariya Fatima said:
    5. If USB device doesn't get detected and I need some info.. will there be any information that I can get from Linux kernel (other than the prints) via sysfs/procfs etc.

    First I would check some MUSB registers, which tells the state of the controller. 'cat /sys/kernel/debug/musb-hdrc.X/regdump'. DevCtl and Power registers are most important.

    Fariya Fatima said:
    6. Finally, the ID pin status is detected in hardware and the information that a flash device is plugged in/a usb cable (RNDIS) is given to the USB driver via an interrupt I suppose. Please confirm.

    Yes. When the controller is in host mode and an USB device is detected, the very first interrupt event received is MUSB_INTR_CONNECT. When the controller is in peripheral mode and is plugged into an USB host, the host will initiate the USB enumeration, the MUSB controller will receive many interrupts on endpoint0 for those SETUP transactions.

  • Thanks Bin Liu for your responses. Really appreciate!

    Regards,

    Fariya