xref: /openbmc/linux/Documentation/usb/gadget_multi.rst (revision 1a931707ad4a46e79d4ecfee56d8f6e8cc8d4f28)
1ecefae6dSMauro Carvalho Chehab==============================
2ecefae6dSMauro Carvalho ChehabMultifunction Composite Gadget
3ecefae6dSMauro Carvalho Chehab==============================
4ecefae6dSMauro Carvalho Chehab
5ecefae6dSMauro Carvalho ChehabOverview
6ecefae6dSMauro Carvalho Chehab========
7ecefae6dSMauro Carvalho Chehab
8ecefae6dSMauro Carvalho ChehabThe Multifunction Composite Gadget (or g_multi) is a composite gadget
9ecefae6dSMauro Carvalho Chehabthat makes extensive use of the composite framework to provide
10ecefae6dSMauro Carvalho Chehaba... multifunction gadget.
11ecefae6dSMauro Carvalho Chehab
12*f13039ceSRandy DunlapIn its standard configuration it provides a single USB configuration
13ecefae6dSMauro Carvalho Chehabwith RNDIS[1] (that is Ethernet), USB CDC[2] ACM (that is serial) and
14ecefae6dSMauro Carvalho ChehabUSB Mass Storage functions.
15ecefae6dSMauro Carvalho Chehab
16ecefae6dSMauro Carvalho ChehabA CDC ECM (Ethernet) function may be turned on via a Kconfig option
17ecefae6dSMauro Carvalho Chehaband RNDIS can be turned off.  If they are both enabled the gadget will
18ecefae6dSMauro Carvalho Chehabhave two configurations -- one with RNDIS and another with CDC ECM[3].
19ecefae6dSMauro Carvalho Chehab
20ecefae6dSMauro Carvalho ChehabPlease note that if you use non-standard configuration (that is enable
21ecefae6dSMauro Carvalho ChehabCDC ECM) you may need to change vendor and/or product ID.
22ecefae6dSMauro Carvalho Chehab
23ecefae6dSMauro Carvalho ChehabHost drivers
24ecefae6dSMauro Carvalho Chehab============
25ecefae6dSMauro Carvalho Chehab
26ecefae6dSMauro Carvalho ChehabTo make use of the gadget one needs to make it work on host side --
27ecefae6dSMauro Carvalho Chehabwithout that there's no hope of achieving anything with the gadget.
28ecefae6dSMauro Carvalho ChehabAs one might expect, things one need to do very from system to system.
29ecefae6dSMauro Carvalho Chehab
30ecefae6dSMauro Carvalho ChehabLinux host drivers
31ecefae6dSMauro Carvalho Chehab------------------
32ecefae6dSMauro Carvalho Chehab
33ecefae6dSMauro Carvalho ChehabSince the gadget uses standard composite framework and appears as such
34ecefae6dSMauro Carvalho Chehabto Linux host it does not need any additional drivers on Linux host
35ecefae6dSMauro Carvalho Chehabside.  All the functions are handled by respective drivers developed
36ecefae6dSMauro Carvalho Chehabfor them.
37ecefae6dSMauro Carvalho Chehab
38ecefae6dSMauro Carvalho ChehabThis is also true for two configuration set-up with RNDIS
39ecefae6dSMauro Carvalho Chehabconfiguration being the first one.  Linux host will use the second
40ecefae6dSMauro Carvalho Chehabconfiguration with CDC ECM which should work better under Linux.
41ecefae6dSMauro Carvalho Chehab
42ecefae6dSMauro Carvalho ChehabWindows host drivers
43ecefae6dSMauro Carvalho Chehab--------------------
44ecefae6dSMauro Carvalho Chehab
45ecefae6dSMauro Carvalho ChehabFor the gadget to work under Windows two conditions have to be met:
46ecefae6dSMauro Carvalho Chehab
47ecefae6dSMauro Carvalho ChehabDetecting as composite gadget
48ecefae6dSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
49ecefae6dSMauro Carvalho Chehab
50ecefae6dSMauro Carvalho ChehabFirst of all, Windows need to detect the gadget as an USB composite
51ecefae6dSMauro Carvalho Chehabgadget which on its own have some conditions[4].  If they are met,
52ecefae6dSMauro Carvalho ChehabWindows lets USB Generic Parent Driver[5] handle the device which then
53ecefae6dSMauro Carvalho Chehabtries to match drivers for each individual interface (sort of, don't
54ecefae6dSMauro Carvalho Chehabget into too many details).
55ecefae6dSMauro Carvalho Chehab
56ecefae6dSMauro Carvalho ChehabThe good news is: you do not have to worry about most of the
57ecefae6dSMauro Carvalho Chehabconditions!
58ecefae6dSMauro Carvalho Chehab
59ecefae6dSMauro Carvalho ChehabThe only thing to worry is that the gadget has to have a single
60ecefae6dSMauro Carvalho Chehabconfiguration so a dual RNDIS and CDC ECM gadget won't work unless you
61ecefae6dSMauro Carvalho Chehabcreate a proper INF -- and of course, if you do submit it!
62ecefae6dSMauro Carvalho Chehab
63ecefae6dSMauro Carvalho ChehabInstalling drivers for each function
64ecefae6dSMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65ecefae6dSMauro Carvalho Chehab
66ecefae6dSMauro Carvalho ChehabThe other, trickier thing is making Windows install drivers for each
67ecefae6dSMauro Carvalho Chehabindividual function.
68ecefae6dSMauro Carvalho Chehab
69ecefae6dSMauro Carvalho ChehabFor mass storage it is trivial since Windows detect it's an interface
70ecefae6dSMauro Carvalho Chehabimplementing USB Mass Storage class and selects appropriate driver.
71ecefae6dSMauro Carvalho Chehab
72ecefae6dSMauro Carvalho ChehabThings are harder with RDNIS and CDC ACM.
73ecefae6dSMauro Carvalho Chehab
74ecefae6dSMauro Carvalho ChehabRNDIS
75ecefae6dSMauro Carvalho Chehab.....
76ecefae6dSMauro Carvalho Chehab
77ecefae6dSMauro Carvalho ChehabTo make Windows select RNDIS drivers for the first function in the
78ecefae6dSMauro Carvalho Chehabgadget, one needs to use the [[file:linux.inf]] file provided with this
79ecefae6dSMauro Carvalho Chehabdocument.  It "attaches" Window's RNDIS driver to the first interface
80ecefae6dSMauro Carvalho Chehabof the gadget.
81ecefae6dSMauro Carvalho Chehab
82ecefae6dSMauro Carvalho ChehabPlease note, that while testing we encountered some issues[6] when
83ecefae6dSMauro Carvalho ChehabRNDIS was not the first interface.  You do not need to worry abut it
84ecefae6dSMauro Carvalho Chehabunless you are trying to develop your own gadget in which case watch
85ecefae6dSMauro Carvalho Chehabout for this bug.
86ecefae6dSMauro Carvalho Chehab
87ecefae6dSMauro Carvalho ChehabCDC ACM
88ecefae6dSMauro Carvalho Chehab.......
89ecefae6dSMauro Carvalho Chehab
90ecefae6dSMauro Carvalho ChehabSimilarly, [[file:linux-cdc-acm.inf]] is provided for CDC ACM.
91ecefae6dSMauro Carvalho Chehab
92ecefae6dSMauro Carvalho ChehabCustomising the gadget
93ecefae6dSMauro Carvalho Chehab......................
94ecefae6dSMauro Carvalho Chehab
95ecefae6dSMauro Carvalho ChehabIf you intend to hack the g_multi gadget be advised that rearranging
96ecefae6dSMauro Carvalho Chehabfunctions will obviously change interface numbers for each of the
97ecefae6dSMauro Carvalho Chehabfunctionality.  As an effect provided INFs won't work since they have
98ecefae6dSMauro Carvalho Chehabinterface numbers hard-coded in them (it's not hard to change those
99ecefae6dSMauro Carvalho Chehabthough[7]).
100ecefae6dSMauro Carvalho Chehab
101ecefae6dSMauro Carvalho ChehabThis also means, that after experimenting with g_multi and changing
102ecefae6dSMauro Carvalho Chehabprovided functions one should change gadget's vendor and/or product ID
103ecefae6dSMauro Carvalho Chehabso there will be no collision with other customised gadgets or the
104ecefae6dSMauro Carvalho Chehaboriginal gadget.
105ecefae6dSMauro Carvalho Chehab
106ecefae6dSMauro Carvalho ChehabFailing to comply may cause brain damage after wondering for hours why
107ecefae6dSMauro Carvalho Chehabthings don't work as intended before realising Windows have cached
108ecefae6dSMauro Carvalho Chehabsome drivers information (changing USB port may sometimes help plus
109ecefae6dSMauro Carvalho Chehabyou might try using USBDeview[8] to remove the phantom device).
110ecefae6dSMauro Carvalho Chehab
111ecefae6dSMauro Carvalho ChehabINF testing
112ecefae6dSMauro Carvalho Chehab...........
113ecefae6dSMauro Carvalho Chehab
114ecefae6dSMauro Carvalho ChehabProvided INF files have been tested on Windows XP SP3, Windows Vista
115ecefae6dSMauro Carvalho Chehaband Windows 7, all 32-bit versions.  It should work on 64-bit versions
116ecefae6dSMauro Carvalho Chehabas well.  It most likely won't work on Windows prior to Windows XP
117ecefae6dSMauro Carvalho ChehabSP2.
118ecefae6dSMauro Carvalho Chehab
119ecefae6dSMauro Carvalho ChehabOther systems
120ecefae6dSMauro Carvalho Chehab-------------
121ecefae6dSMauro Carvalho Chehab
122ecefae6dSMauro Carvalho ChehabAt this moment, drivers for any other systems have not been tested.
123ecefae6dSMauro Carvalho ChehabKnowing how MacOS is based on BSD and BSD is an Open Source it is
124ecefae6dSMauro Carvalho Chehabbelieved that it should (read: "I have no idea whether it will") work
125ecefae6dSMauro Carvalho Chehabout-of-the-box.
126ecefae6dSMauro Carvalho Chehab
127ecefae6dSMauro Carvalho ChehabFor more exotic systems I have even less to say...
128ecefae6dSMauro Carvalho Chehab
129ecefae6dSMauro Carvalho ChehabAny testing and drivers *are* *welcome*!
130ecefae6dSMauro Carvalho Chehab
131ecefae6dSMauro Carvalho ChehabAuthors
132ecefae6dSMauro Carvalho Chehab=======
133ecefae6dSMauro Carvalho Chehab
134ecefae6dSMauro Carvalho ChehabThis document has been written by Michal Nazarewicz
135ecefae6dSMauro Carvalho Chehab([[mailto:mina86@mina86.com]]).  INF files have been hacked with
136ecefae6dSMauro Carvalho Chehabsupport of Marek Szyprowski ([[mailto:m.szyprowski@samsung.com]]) and
137ecefae6dSMauro Carvalho ChehabXiaofan Chen ([[mailto:xiaofanc@gmail.com]]) basing on the MS RNDIS
138ecefae6dSMauro Carvalho Chehabtemplate[9], Microchip's CDC ACM INF file and David Brownell's
139ecefae6dSMauro Carvalho Chehab([[mailto:dbrownell@users.sourceforge.net]]) original INF files.
140ecefae6dSMauro Carvalho Chehab
141ecefae6dSMauro Carvalho ChehabFootnotes
142ecefae6dSMauro Carvalho Chehab=========
143ecefae6dSMauro Carvalho Chehab
144ecefae6dSMauro Carvalho Chehab[1] Remote Network Driver Interface Specification,
145ffeb1e9eSAlexander A. Klimov[[https://msdn.microsoft.com/en-us/library/ee484414.aspx]].
146ecefae6dSMauro Carvalho Chehab
147ecefae6dSMauro Carvalho Chehab[2] Communications Device Class Abstract Control Model, spec for this
148ecefae6dSMauro Carvalho Chehaband other USB classes can be found at
149ecefae6dSMauro Carvalho Chehab[[http://www.usb.org/developers/devclass_docs/]].
150ecefae6dSMauro Carvalho Chehab
151ecefae6dSMauro Carvalho Chehab[3] CDC Ethernet Control Model.
152ecefae6dSMauro Carvalho Chehab
153ffeb1e9eSAlexander A. Klimov[4] [[https://msdn.microsoft.com/en-us/library/ff537109(v=VS.85).aspx]]
154ecefae6dSMauro Carvalho Chehab
155ffeb1e9eSAlexander A. Klimov[5] [[https://msdn.microsoft.com/en-us/library/ff539234(v=VS.85).aspx]]
156ecefae6dSMauro Carvalho Chehab
157ecefae6dSMauro Carvalho Chehab[6] To put it in some other nice words, Windows failed to respond to
158ecefae6dSMauro Carvalho Chehabany user input.
159ecefae6dSMauro Carvalho Chehab
160ecefae6dSMauro Carvalho Chehab[7] You may find [[http://www.cygnal.org/ubb/Forum9/HTML/001050.html]]
161ecefae6dSMauro Carvalho Chehabuseful.
162ecefae6dSMauro Carvalho Chehab
163ffeb1e9eSAlexander A. Klimov[8] https://www.nirsoft.net/utils/usb_devices_view.html
164ecefae6dSMauro Carvalho Chehab
165ffeb1e9eSAlexander A. Klimov[9] [[https://msdn.microsoft.com/en-us/library/ff570620.aspx]]
166