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/AM5718: USB Mass Storage Device Issue

Part Number: AM5718


Tool/software: Linux

Hello,

I have an AM5718 custom board similar to AM57xx-EVM and I'm trying to provide a mass storage device to a host linux machine over the USB2 port, configured as device.

In addition, I need to enable both rndis and ecm (ethernet over usb) using the same physical USB connection.

The mass storage device works fine if I enable it by itself or if I enable either of the ethernet over usb interfaces, but it does not work if enable both rndis and ecm. On the host machine the USB mass storage is detected, but the device /dev/sdX is not present. I attached log files from the host machine for both the failing and passing cases.

I also attached the script for setting up libcomposite and the drive image I'm using for testing. To make the mass storage device work properly it's enough to comment out one of the ln commands enabling the ethernet over usb interfaces:

#ln -s functions/ecm.usb0 configs/c.1/

I tested this with the rootfs image included in SDK 05.02.00.10 (tisdk-rootfs-image-am57xx-evm.tar.xz) with a modified bootloader and device tree to match my board configuration.

I also tried the BeagleBone X15 with the latest debian image and the problem happens there as well so I don't think it's limited to my hardware. The functionality (rndis + ecm + mass storage) works fine on the BeagleBone Black with its latest debian image, though.

Do you have any advice on how to proceed on this?

--Tavi0726.files.tar.gz

  • Hi,

    Do you mean the composite device (rndis+ecm+msc) created by your setup.sh script on BeagleboneBlack is enumerated successfully on Linux Host, but failed if replaced BeagleboneBlack with AM5718 board?

    I will first try to use your setup.sh script to replicate the issue then look into it.
  • Thanks for looking into this.

    The setup script will not run on the BeagleBoneBlack because the environment is slightly different (e.g. different USB port naming).

    The script should run fine on the AM57xx-EVM with the rootfs from the SDK 05.02.00.10, though.

    I mentioned the BeagleBoneBlack as an example where the rndis+ecm+mass storage works fine and BeagleBone x15 as a case where the functionality is also broken although it's enabled and should work. Both these cases use a script similar to what I attached to my original message. Along with my board not working it seems like the problem is affecting AM57xx but not AM335x.
  • Hi,

    I can reproduce the problem on my board with your setup script.

    I also found it will work if ln mass_storage function prior rndis and ecm. Will it be a solution for you?

    +     ln -s functions/mass_storage.usb0 configs/c.1/
          ln -s functions/rndis.usb0 configs/c.1/
          ln -s functions/ecm.usb0 configs/c.1/
    -     ln -s functions/mass_storage.usb0 configs/c.1/
  • I tried your suggestion, and after moving the ln command, the mass storage device shows up and works fine on the linux host.

    However, I'm having issues on a Windows 10 host now.

    If I put the mass_storage ln command before rndis ln command, the mass storage shows up but the rndis network adapter does not work on the win10 host (In device manager it's listed as "not started").

    If I put the mass_storage ln command after the rndis ln command, the rndis adapter works fine but the mass storage does not show up in device manager.

    The behavior above happens even if the ecm ln command is commented out and both mass storage and rndis show up fine on the linux host.

    Again, the rndis and mass storage from a BeagleBone Black work fine on both Linux and Win10 hosts.

    Any suggestion on how to debug this issue?
  • Understood the problem. I will try to debug the kernel to see what causes the failure. I will keep you posted.
  • Hello,

    Is there any update on this issue?

  • Hi,

    I did some initial debug, the mass storage IN endpoint doesn't communicate to the USB host. I reported the failure to the dwc3 driver owner on the Linux community and am waiting for hist comments.
  • Hi Tavi,

    The issue is that there is by default no enough available usb endpoints for this use case. The following kernel patch adjust TX FIFO layout so that more endpoints are available. Please test it with your use case and let me know.

    diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
    index a08ff96b41e7..129534c8d1e3 100644
    --- a/drivers/usb/dwc3/gadget.c
    +++ b/drivers/usb/dwc3/gadget.c
    @@ -2127,6 +2127,16 @@ static int dwc3_gadget_init_endpoints(struct dwc3 *dwc, u8 total)
                            /* MDWIDTH is represented in bits, we need it in bytes */
                            mdwidth /= 8;
     
    +                       if (num <= 13) {
    +                               int buf0_size = 0x42;
    +                               int buf_size = 0x84;    /* 1K buffer */
    +                               int offset;
    +
    +                               offset = buf0_size + buf_size * (num - 1);
    +                               size = offset << 16 | buf_size;
    +                               dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), size);
    +                       }
    +
                            size = dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(num));
                            size = DWC3_GTXFIFOSIZ_TXFDEF(size);
    
  • Hi Bin,

    The patch resolved the issue. Thank you!

    --Tavi

  • Tavi,

    Great! Thanks for the update.