public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Arpad Kun <kun@arpad.me>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: Running multiple gadgets in mass storage mode?
Date: Tue, 16 Jun 2020 11:06:03 +0000	[thread overview]
Message-ID: <20200616110626.GA20515@b29397-desktop> (raw)
In-Reply-To: <8A08E690-674B-413C-BBC2-0B6A6B170871@arpad.me>

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&amp;data=02%7C01%7Cpeter.chen%40nxp.com%7Ca4bb128d95ee4dd9a99708d81180b5e3%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637278591787761356&amp;sdata=uief9JhZbeV693ROZL2Oa4NbX4o5mFV8cqYucj9PcpU%3D&amp;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

      reply	other threads:[~2020-06-16 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 23:06 Running multiple gadgets in mass storage mode? Arpad Kun
2020-06-16 11:06 ` Peter Chen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200616110626.GA20515@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=kun@arpad.me \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox