1*4882a593Smuzhiyun============================== 2*4882a593SmuzhiyunMultifunction Composite Gadget 3*4882a593Smuzhiyun============================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunOverview 6*4882a593Smuzhiyun======== 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunThe Multifunction Composite Gadget (or g_multi) is a composite gadget 9*4882a593Smuzhiyunthat makes extensive use of the composite framework to provide 10*4882a593Smuzhiyuna... multifunction gadget. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunIn it's standard configuration it provides a single USB configuration 13*4882a593Smuzhiyunwith RNDIS[1] (that is Ethernet), USB CDC[2] ACM (that is serial) and 14*4882a593SmuzhiyunUSB Mass Storage functions. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunA CDC ECM (Ethernet) function may be turned on via a Kconfig option 17*4882a593Smuzhiyunand RNDIS can be turned off. If they are both enabled the gadget will 18*4882a593Smuzhiyunhave two configurations -- one with RNDIS and another with CDC ECM[3]. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunPlease note that if you use non-standard configuration (that is enable 21*4882a593SmuzhiyunCDC ECM) you may need to change vendor and/or product ID. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunHost drivers 24*4882a593Smuzhiyun============ 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunTo make use of the gadget one needs to make it work on host side -- 27*4882a593Smuzhiyunwithout that there's no hope of achieving anything with the gadget. 28*4882a593SmuzhiyunAs one might expect, things one need to do very from system to system. 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunLinux host drivers 31*4882a593Smuzhiyun------------------ 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunSince the gadget uses standard composite framework and appears as such 34*4882a593Smuzhiyunto Linux host it does not need any additional drivers on Linux host 35*4882a593Smuzhiyunside. All the functions are handled by respective drivers developed 36*4882a593Smuzhiyunfor them. 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunThis is also true for two configuration set-up with RNDIS 39*4882a593Smuzhiyunconfiguration being the first one. Linux host will use the second 40*4882a593Smuzhiyunconfiguration with CDC ECM which should work better under Linux. 41*4882a593Smuzhiyun 42*4882a593SmuzhiyunWindows host drivers 43*4882a593Smuzhiyun-------------------- 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunFor the gadget to work under Windows two conditions have to be met: 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunDetecting as composite gadget 48*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunFirst of all, Windows need to detect the gadget as an USB composite 51*4882a593Smuzhiyungadget which on its own have some conditions[4]. If they are met, 52*4882a593SmuzhiyunWindows lets USB Generic Parent Driver[5] handle the device which then 53*4882a593Smuzhiyuntries to match drivers for each individual interface (sort of, don't 54*4882a593Smuzhiyunget into too many details). 55*4882a593Smuzhiyun 56*4882a593SmuzhiyunThe good news is: you do not have to worry about most of the 57*4882a593Smuzhiyunconditions! 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunThe only thing to worry is that the gadget has to have a single 60*4882a593Smuzhiyunconfiguration so a dual RNDIS and CDC ECM gadget won't work unless you 61*4882a593Smuzhiyuncreate a proper INF -- and of course, if you do submit it! 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunInstalling drivers for each function 64*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65*4882a593Smuzhiyun 66*4882a593SmuzhiyunThe other, trickier thing is making Windows install drivers for each 67*4882a593Smuzhiyunindividual function. 68*4882a593Smuzhiyun 69*4882a593SmuzhiyunFor mass storage it is trivial since Windows detect it's an interface 70*4882a593Smuzhiyunimplementing USB Mass Storage class and selects appropriate driver. 71*4882a593Smuzhiyun 72*4882a593SmuzhiyunThings are harder with RDNIS and CDC ACM. 73*4882a593Smuzhiyun 74*4882a593SmuzhiyunRNDIS 75*4882a593Smuzhiyun..... 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunTo make Windows select RNDIS drivers for the first function in the 78*4882a593Smuzhiyungadget, one needs to use the [[file:linux.inf]] file provided with this 79*4882a593Smuzhiyundocument. It "attaches" Window's RNDIS driver to the first interface 80*4882a593Smuzhiyunof the gadget. 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunPlease note, that while testing we encountered some issues[6] when 83*4882a593SmuzhiyunRNDIS was not the first interface. You do not need to worry abut it 84*4882a593Smuzhiyununless you are trying to develop your own gadget in which case watch 85*4882a593Smuzhiyunout for this bug. 86*4882a593Smuzhiyun 87*4882a593SmuzhiyunCDC ACM 88*4882a593Smuzhiyun....... 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunSimilarly, [[file:linux-cdc-acm.inf]] is provided for CDC ACM. 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunCustomising the gadget 93*4882a593Smuzhiyun...................... 94*4882a593Smuzhiyun 95*4882a593SmuzhiyunIf you intend to hack the g_multi gadget be advised that rearranging 96*4882a593Smuzhiyunfunctions will obviously change interface numbers for each of the 97*4882a593Smuzhiyunfunctionality. As an effect provided INFs won't work since they have 98*4882a593Smuzhiyuninterface numbers hard-coded in them (it's not hard to change those 99*4882a593Smuzhiyunthough[7]). 100*4882a593Smuzhiyun 101*4882a593SmuzhiyunThis also means, that after experimenting with g_multi and changing 102*4882a593Smuzhiyunprovided functions one should change gadget's vendor and/or product ID 103*4882a593Smuzhiyunso there will be no collision with other customised gadgets or the 104*4882a593Smuzhiyunoriginal gadget. 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunFailing to comply may cause brain damage after wondering for hours why 107*4882a593Smuzhiyunthings don't work as intended before realising Windows have cached 108*4882a593Smuzhiyunsome drivers information (changing USB port may sometimes help plus 109*4882a593Smuzhiyunyou might try using USBDeview[8] to remove the phantom device). 110*4882a593Smuzhiyun 111*4882a593SmuzhiyunINF testing 112*4882a593Smuzhiyun........... 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunProvided INF files have been tested on Windows XP SP3, Windows Vista 115*4882a593Smuzhiyunand Windows 7, all 32-bit versions. It should work on 64-bit versions 116*4882a593Smuzhiyunas well. It most likely won't work on Windows prior to Windows XP 117*4882a593SmuzhiyunSP2. 118*4882a593Smuzhiyun 119*4882a593SmuzhiyunOther systems 120*4882a593Smuzhiyun------------- 121*4882a593Smuzhiyun 122*4882a593SmuzhiyunAt this moment, drivers for any other systems have not been tested. 123*4882a593SmuzhiyunKnowing how MacOS is based on BSD and BSD is an Open Source it is 124*4882a593Smuzhiyunbelieved that it should (read: "I have no idea whether it will") work 125*4882a593Smuzhiyunout-of-the-box. 126*4882a593Smuzhiyun 127*4882a593SmuzhiyunFor more exotic systems I have even less to say... 128*4882a593Smuzhiyun 129*4882a593SmuzhiyunAny testing and drivers *are* *welcome*! 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunAuthors 132*4882a593Smuzhiyun======= 133*4882a593Smuzhiyun 134*4882a593SmuzhiyunThis document has been written by Michal Nazarewicz 135*4882a593Smuzhiyun([[mailto:mina86@mina86.com]]). INF files have been hacked with 136*4882a593Smuzhiyunsupport of Marek Szyprowski ([[mailto:m.szyprowski@samsung.com]]) and 137*4882a593SmuzhiyunXiaofan Chen ([[mailto:xiaofanc@gmail.com]]) basing on the MS RNDIS 138*4882a593Smuzhiyuntemplate[9], Microchip's CDC ACM INF file and David Brownell's 139*4882a593Smuzhiyun([[mailto:dbrownell@users.sourceforge.net]]) original INF files. 140*4882a593Smuzhiyun 141*4882a593SmuzhiyunFootnotes 142*4882a593Smuzhiyun========= 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun[1] Remote Network Driver Interface Specification, 145*4882a593Smuzhiyun[[https://msdn.microsoft.com/en-us/library/ee484414.aspx]]. 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun[2] Communications Device Class Abstract Control Model, spec for this 148*4882a593Smuzhiyunand other USB classes can be found at 149*4882a593Smuzhiyun[[http://www.usb.org/developers/devclass_docs/]]. 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun[3] CDC Ethernet Control Model. 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun[4] [[https://msdn.microsoft.com/en-us/library/ff537109(v=VS.85).aspx]] 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun[5] [[https://msdn.microsoft.com/en-us/library/ff539234(v=VS.85).aspx]] 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun[6] To put it in some other nice words, Windows failed to respond to 158*4882a593Smuzhiyunany user input. 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun[7] You may find [[http://www.cygnal.org/ubb/Forum9/HTML/001050.html]] 161*4882a593Smuzhiyunuseful. 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun[8] https://www.nirsoft.net/utils/usb_devices_view.html 164*4882a593Smuzhiyun 165*4882a593Smuzhiyun[9] [[https://msdn.microsoft.com/en-us/library/ff570620.aspx]] 166