1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Example Host-side Device Driver</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="eCos Support for Developing USB-ethernet Peripherals"
23 HREF="io-usb-slave-eth.html"><LINK
25 TITLE="Network Device for the eCos TCP/IP Stack"
26 HREF="usbseth-netdev.html"><LINK
28 TITLE="Communication Protocol"
29 HREF="usbseth-protocol.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="usbseth-netdev.html"
71 HREF="usbseth-protocol.html"
82 NAME="USBSETH-HOST">Example Host-side Device Driver</H1
90 >Example Host-side Device Driver -- Provide host-side support for the eCos USB-ethernet package</DIV
99 >The USB-ethernet package is supplied with a single host-side device
100 driver. This driver has been developed against the Linux kernel
101 2.2.16-22, as shipped with Red Hat 7. The driver is provided as is and
102 should not be considered production quality: for example it only
103 checks for a bogus vendor id <TT
107 official vendor id supplied by the <A
108 HREF="http://www.usb.org/"
110 >USB Implementers Forum</A
112 peripheral involves multiple configurations or multiple interfaces, it
113 will fail to detect this. However, the driver can be used for simple
114 testing and as the basis of a full device driver. Details of the
115 protocol used between host and peripheral can be found in the <A
116 HREF="usbseth-protocol.html"
117 >Communication Protocol</A
120 >The host-side device driver can be found in the <TT
123 > subdirectory of the USB-ethernet
124 package, specifically the file <TT
131 >. Both files may need
132 to be modified for specific applications. For example, the vendor id
135 >ecos_usbeth_implementations</TT
137 updated for the specific USB peripheral being built. The
141 > assumes that the Linux kernel sources
146 that the kernel has already been configured and built. Assuming this
147 is the case, the device driver can be built simply by invoking
151 > with no additional arguments. This will result
152 in a dynamically loadable kernel module,
156 >, in the current directory.</P
164 >As normal for Linux kernel builds, the generated files such as
168 > live in the same directory as the
169 source tree. This is very different from eCos where the source tree
170 (or component repository) is kept separate from any builds. There may
171 be problems if the component repository is kept read-only or if it is
172 put under source code control. Any such problems can be avoided by
173 making a copy of the <TT
177 subdirectory and building that copy.</P
181 >Loading the kernel module into the current system requires root
182 privileges. If the generic USB support is also a loadable module and
183 has not been loaded already, this must happen first:</P
193 Using /lib/modules/2.2.16-22/usb/usb-uhci.o</PRE
198 >Depending on the host hardware, the <TT
205 > modules may be more appropriate. Loading
206 the generic USB module will typically result in a number of messages
209 >/var/log/messages</TT
211 of the specific host-side hardware that has been detected plus any
212 hubs. The next step is to load the USB-ethernet module:</P
221 ># insmod ecos_usbeth.o</PRE
226 >This should result in a number of additional diagnostics in the
236 >Apr 1 18:01:08 grumpy kernel: eCos USB-ethernet device driver
237 Apr 1 18:01:08 grumpy kernel: usb.c: registered new driver ecos_usbeth</PRE
242 >If a suitable USB peripheral is now connected the host will detect
243 this, assign an address in the local USB network, obtain enumeration
244 data, and find a suitable device driver. Assuming the peripheral and
245 device driver agree on the supported vendor ids, the
249 > module will be selected and this
250 will be reported in the system log:</P
259 >Apr 1 18:04:12 grumpy kernel: usb.c: USB new device connect, assigned device number 3
260 Apr 1 18:04:12 grumpy kernel: eCos-based USB ethernet peripheral active at eth1</PRE
265 >What can happen next depends very much on the software that is running
266 on top of the USB-ethernet package inside the peripheral. For example,
267 if there is a TCP/IP stack then it should be possible to bring up a
268 network connection between host and peripheral using
279 SUMMARY="Footer navigation table"
290 HREF="usbseth-netdev.html"
308 HREF="usbseth-protocol.html"
318 >Network Device for the eCos TCP/IP Stack</TD
324 HREF="io-usb-slave-eth.html"
332 >Communication Protocol</TD