How to use USB composite device?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to use USB composite device?

5,894 次查看
felixhsu
Contributor III

Hi All

Platform: i.MX6ULL

Software: Linux_4.9.11

The customer want to use USB composite device, one for HID and one for mass storage.

would you provide how to configuration USB driver for composite device?

Thanks.

标签 (3)
0 项奖励
回复
5 回复数

4,786 次查看
Rita_Wang
NXP TechSupport
NXP TechSupport

Hi,

You doesn't need to re-configure USB driver.  There are two USB port on i.mx6ulL evk board, one is USB OTG with microUSB connector, the other is USB Host.  For HID device, customer can connect it to USB host; for Mass storage, customer can use a USB OTG to HOST cable to connect microUSB connector, and the other side of the cable is used to connect mass storage, such as moble disk or U disk.

Hope this can do help for you.
Have a great day,
Rita

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

4,786 次查看
felixhsu
Contributor III

Hi Rita

The customer is want to use same USB port let PC recognize two USB type device, for example USB HID and USB mass storage.

Thanks.

0 项奖励
回复

4,786 次查看
marcomadrigal
Contributor III

Hi,

You can not modprobe two independent gadget drivers. For this, you need to use a composite driver that registers both functions. You can do this in two ways:

1.  To use a single legacy composite driver (actually you are already using the legacy drivers on your tests), this is, you need to create a custom kernel module instead of using g_mass_storage and g_hid separately. See drivers/usb/gadget/legacy/acm_ms.c for an example. 

2. You can configure the composite driver from userspace using configfs:

https://events.static.linuxfound.org/sites/events/files/slides/USB%20Gadget%20Configfs%20API_0.pdf 

Best Regards,

-Marco

GStreamer Development | Embedded Linux Development | Linux SDK 

0 项奖励
回复

4,786 次查看
alexkuo
Contributor I

Hi All

I have the same issue, too.

I found some article but still not solve the issue. I have trawled through many articles with no luck.

I post it.
g_multi.ko needs driver. Windows shows up as an unknow device "Multifunction Composite Gadget".  I need a HID and a mass storage.
HID is work OK. But mass storage is still not work at all. log as below:
root@imx6ull14x14evk:~# modprobe dummy_hcd
dummy_hcd dummy_hcd.0: USB Host+Gadget Emulator, driver 02 May 2005
dummy_hcd dummy_hcd.0: Dummy host controller
dummy_hcd dummy_hcd.0: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
2188000.ethernet supply phy not found, using dummy regulator
root@imx6ull14x14evk:~# pps pps0: new PPS source ptp0
alloc_contig_range: [8c058, 8c060) PFNs busy
2188000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
alloc_contig_range: [8c058, 8c060) PFNs busy
root@imx6ull14x14evk:~#
root@imx6ull14x14evk:~# modprobe g_hid
2188000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
alloc_contig_range: [8c058, 8c060) PFNs busy
g_hid gadget: HID Gadget, version: 2010/03/16
g_hid gadget: g_hid ready
root@imx6ull14x14evk:~# g_hid gadget: high-speed config #1: HID Gadget
root@imx6ull14x14evk:~#
root@imx6ull14x14evk:~# modprobe g_mass_storage file=/dev/mmcblk1
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
LUN: file: /dev/mmcblk1
Number of LUNs=1
g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
g_mass_storage gadget: userspace failed to provide iSerialNumber
g_mass_storage gadget: g_mass_storage ready
root@imx6ull14x14evk:~# usb 1-1: new high-speed USB device number 2 using dummy_hcd
g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
usb-storage 1-1:1.0: USB Mass Storage device detected
usb-storage 1-1:1.0: Quirks match for vid 0525 pid a4a5: 10000
scsi host0: usb-storage 1-1:1.0
2188000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
alloc_contig_range: [8c058, 8c060) PFNs busy
scsi 0:0:0:0: Direct-Access     Linux    File-Stor Gadget 0409 PQ: 0 ANSI: 2
2188000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
alloc_contig_range: [8c058, 8c060) PFNs busy
sd 0:0:0:0: [sda] 7405568 512-byte logical blocks: (3.79 GB/3.53 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sda: sda1 sda2 sda3 sda4
sd 0:0:0:0: [sda] Attached SCSI disk
root@imx6ull14x14evk:~#
root@imx6ull14x14evk:~# lsusb
Bus 001 Device 002: ID 0525:a4a5 Netchip Technology, Inc. Pocketbook Pro 903
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
0 项奖励
回复

4,786 次查看
Rita_Wang
NXP TechSupport
NXP TechSupport

Hi Alex,

You can refer to my later reply. It maybe do help for you.

Have a nice day

Rita

0 项奖励
回复