On 20-06-15 16:06:12, Arpad Kun wrote: > Hi Everyone, > > Seeking advice please on: if it was possible to run multiple USB devices within the same Linux system in device mode and use g_mass_storage to emulate different "volumes" through each. > > This is how far I got: > - Have two USB3380-EVB boards hooked up in a Linux machine (x86) > - I see both of them via `lspci`, net2280 module runs them. > > # lspci -nn |grep 3380 > 04:00.0 USB controller [0c03]: PLX Technology, Inc. Device [10b5:3380] (rev ab) > 65:00.0 USB controller [0c03]: PLX Technology, Inc. Device [10b5:3380] (rev ab) > > > - Loading the `g_mass_storage` to allow me to "insert" an image to to emulate: > > # modprobe g_mass_storage removable=y stall=0 nofua=1 > # find /sys/ -name "*gadget*" > [...] > /sys/devices/pci0000:64/0000:64:00.0/0000:65:00.0/gadget > /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget > > > - But when I look at sysfs, only one of them has `lun0/file` that I can echo into: > > # ls -1 /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget > lun0 <--- lun0 is here, looks good > power > suspended > uevent > > # ls -1 /sys/devices/pci0000:64/0000:64:00.0/0000:65:00.0/gadget > power > uevent > <-- lun0 is missing :( > > - The following works for one image, but I am trying to insert an another image to through the other controller: > > echo "/home/test.img" > /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget/lun0/file > > > In the kernel documentation I found the following in the USB Controller Driver section: "The controller driver can support any number of different gadget drivers, but only one of them can be used at a time." > It was not clear whether it means one driver at a time or one controller at a time. (https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kernel.org%2Fdoc%2Fhtml%2Flatest%2Fdriver-api%2Fusb%2Fgadget.html&data=02%7C01%7Cpeter.chen%40nxp.com%7Ca4bb128d95ee4dd9a99708d81180b5e3%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637278591787761356&sdata=uief9JhZbeV693ROZL2Oa4NbX4o5mFV8cqYucj9PcpU%3D&reserved=0) > > Questions please: > - Is there something I missed or oversee? modprobe gadget module is legacy way, please use configfs: Documentation/usb/gadget_configfs.rst > - Would you have any suggestions how to make it work? Is it possible? It should be possible. You could bind any UDCs to any gadget drivers, For your case, you need to create /sys/kernel/config/usb_gadget/g1 /sys/kernel/config/usb_gadget/g2 For your two UDCs. -- Thanks, Peter Chen