/[gentoo]/xml/htdocs/doc/en/usb-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/usb-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.14
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/usb-guide.xml,v 1.14 2007/03/13 00:40:27 nightmorph Exp $ -->
2 3
3<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 4<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4 5
5<guide link="/doc/en/usb-guide.xml"> 6<guide link="/doc/en/usb-guide.xml">
6<title>Gentoo Linux USB Guide</title> 7<title>Gentoo Linux USB Guide</title>
7 8
8<author title="Author"> 9<author title="Author">
9 <mail link="fox2mike@gmail.com">Shyam Mani</mail> 10 <mail link="fox2mike@gentoo.org">Shyam Mani</mail>
10</author> 11</author>
11 12
12<abstract> 13<abstract>
13This document helps a user setup USB on a Gentoo system and configure various 14This document helps a user setup USB on a Gentoo system and configure various
14USB devices as well. 15USB devices as well.
15</abstract> 16</abstract>
16 17
17<!-- The content of this document is licensed under the CC-BY-SA license --> 18<!-- The content of this document is licensed under the CC-BY-SA license -->
18<!-- See http://creativecommons.org/licenses/by-sa/2.0 --> 19<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
19<license/> 20<license/>
20 21
21<version>1.0</version> 22<version>1.12</version>
22<date>2005-03-02</date> 23<date>2007-03-12</date>
23 24
24<chapter> 25<chapter>
25<title>Introduction</title> 26<title>Introduction</title>
26<section> 27<section>
27<title>What is USB?</title> 28<title>What is USB?</title>
28<body> 29<body>
29 30
30<p> 31<p>
31USB stands for Universal Serial Bus and is basically an external interface 32USB stands for Universal Serial Bus and is basically an external interface
32standard that enables communication between the computer and various other 33standard that enables communication between the computer and various other
33peripherals. Some of the most commonly used USB devices today are keyboards, 34peripherals. Some of the most commonly used USB devices today are keyboards,
34mice, pen drives, digital cameras, external CD &amp; DVD writers, printers etc. 35mice, pen drives, digital cameras, external CD &amp; DVD writers, printers etc.
35</p>
36
37<p> 36</p>
37
38<p>
38There are currently two versions of USB in use, i.e. USB 1.1 and USB 2.0. 39There are currently two versions of USB in use, i.e. USB 1.1 and USB 2.0.
39Since USB has always been backward compatible with its previous versions, 40Since USB has always been backward compatible with its previous versions,
40USB 2.0 is backwards compatible with USB 1.1. The latest USB devices are 41USB 2.0 is backwards compatible with USB 1.1. The latest USB devices are
41typically USB 2.0 compatible. USB 2.0 supports a maximum data transmission 42typically USB 2.0 compatible. USB 2.0 supports a maximum data transmission
42speed of 480 Mbps or 60 MBps and this is the major difference between the two 43speed of 480 Mbps or 60 MBps and this is the major difference between the two
43standards. Another advantage with USB is that the devices are all 44standards. Another advantage with USB is that the devices are all
44<e>hot-pluggable</e>, which means that you do not have to restart your system 45<e>hot-pluggable</e>, which means that you do not have to restart your system
45in order for you to be able to use these devices. 46in order for you to be able to use these devices.
46</p> 47</p>
47 48
48</body> 49</body>
49</section> 50</section>
50
51<section> 51<section>
52<title>A Technical Perspective</title> 52<title>A Technical Perspective</title>
53<body> 53<body>
54 54
55<p> 55<p>
56Before we go onto the exact configuration options in the kernel, it would 56Before we go onto the exact configuration options in the kernel, it would
57be apt to look at USB in a little more detail. If you're in a hurry or want 57be apt to look at USB in a little more detail. If you're in a hurry or want
58to skip this section, please go to <uri link="#kernel">Kernel Configuration</uri>. 58to skip this section, please go to <uri link="#kernel">Kernel Configuration</uri>.
59</p> 59</p>
60 60
61<p> 61<p>
62A USB system has a host controller, hubs, a <e>root hub</e> amongst others 62A USB system has a host controller, hubs, a <e>root hub</e> amongst others
63and can support up to 127 USB devices including the hubs. The host controller 63and can support up to 127 USB devices including the hubs. The host controller
64is nothing but the hardware interface between the USB device and the 64is nothing but the hardware interface between the USB device and the
65operating system. There are a couple of HCI (Host Controller Interface) 65operating system. There are a couple of HCI (Host Controller Interface)
66in use today and they are the OHCI (Open HCI) by Compaq, UHCI (Universal HCI) 66in use today and they are the OHCI (Open HCI) by Compaq, UHCI (Universal HCI)
67and EHCI (Enhanced HCI), both from Intel. The OHCI/UHCI are the two industry 67and EHCI (Enhanced HCI), both from Intel. The OHCI/UHCI are the two industry
68standard USB 1.1 interfaces whereas the EHCI is for USB 2.0. 68standard USB 1.1 interfaces whereas the EHCI is for USB 2.0.
69</p> 69</p>
70 70
71<p> 71<p>
72The hardware vendor provides an interface for the programmer that allows 72The hardware vendor provides an interface for the programmer that allows
73the system to interact with the hardware and this is called the HCD or Host 73the system to interact with the hardware and this is called the HCD or Host
74Controller Device. It is through this HCD that the device interacts with the 74Controller Device. It is through this HCD that the device interacts with the
75system software. The following diagram should make things easier to comprehend. 75system software. The following diagram should make things easier to comprehend.
76</p> 76</p>
77 77
78<pre caption="General USB Architecture"> 78<pre caption="General USB Architecture">
79<comment>(Software consists of other components as well like the device driver, but 79<comment>(Software consists of other components as well like the device driver, but
80 for the sake of simplicity, they are not shown)</comment> 80for the sake of simplicity, they are not shown)</comment>
81 81
82 + ---- Hardware ---- + ---- Software ---- + 82 + ---- Hardware ---- + ---- Software ---- +
83 | | | 83 | | |
84 | [USB Dev] -+-> {EHCI} -+---> ( EHCD ) | 84 | [USB Dev] -+-> {EHCI} -+---> ( EHCD ) |
85 | | | | User 85 | | | | User
86 | `-> {UHCI} -+---> ( UHCD ) | 86 | `-> {UHCI} -+---> ( UHCD ) |
87 | | | 87 | | |
88 + ---- Hardware ---- + ---- Software ---- + 88 + ---- Hardware ---- + ---- Software ---- +
89
90</pre> 89</pre>
91 90
92<p> 91<p>
93A USB device can either use a custom driver or use one already present in 92A USB device can either use a custom driver or use one already present in
94the system and this is based on the concept of a device <e>class</e>. This 93the system and this is based on the concept of a device <e>class</e>. This
95means that if a device belongs to a certain <e>class</e>, then other devices 94means that if a device belongs to a certain <e>class</e>, then other devices
96belonging to the same <e>class</e> can make use of the same device driver. 95belonging to the same <e>class</e> can make use of the same device driver.
97Some of these <e>classes</e> are the USB HID (Human Interface Devices) class 96Some of these <e>classes</e> are the USB HID (Human Interface Devices) class
98which covers input devices like keyboards and mice, the USB Mass Storage 97which covers input devices like keyboards and mice, the USB Mass Storage
99devices class which covers devices like pen drives, digital cameras, audio 98devices class which covers devices like pen drives, digital cameras, audio
100players etc and the USB CDC (Communication Devices Class) which essentially 99players etc and the USB CDC (Communication Devices Class) which essentially
101covers USB modems and similar devices. 100covers USB modems and similar devices.
102</p> 101</p>
103 102
104</body> 103</body>
105</section> 104</section>
106 105<section>
107<section id="#lspci">
108<title>What's on your machine?</title> 106<title>What's on your machine?</title>
109<body> 107<body>
110 108
111<p> 109<p>
112It is very simple to find out whether your machine has USB 2.0 support or not. 110It is very simple to find out whether your machine has USB 2.0 support or not.
113We make use of the <c>lspci</c> command for this purpose. 111We make use of the <c>lspci</c> command for this purpose.
114</p> 112</p>
115 113
116<note> 114<note>
117The <c>lspci</c> tool is a part of the <c>sys-apps/pciutils</c> package. If 115The <c>lspci</c> tool is a part of the <c>sys-apps/pciutils</c> package. If
118you do not have this installed, please <c>emerge pciutils</c>. Please note 116you do not have this installed, please <c>emerge pciutils</c>. Please note
119that you have to be root while running the <c>lspci</c> command. 117that you have to be root while running the <c>lspci</c> command.
120</note> 118</note>
121 119
122<pre caption="Various lspci outputs"> 120<pre caption="Various lspci outputs">
123<comment>(In system that is USB 1.1 compliant, note the UHCI only)</comment> 121<comment>(In system that is USB 1.1 compliant, note the UHCI only)</comment>
13200:1d.2 USB Controller: Intel Corp. 82801DB USB (Hub #3) (rev 01) (prog-if 00 [UHCI]) 13000:1d.2 USB Controller: Intel Corp. 82801DB USB (Hub #3) (rev 01) (prog-if 00 [UHCI])
13300:1d.7 USB Controller: Intel Corp. 82801DB USB EHCI Controller (rev 01) (prog-if 20 [EHCI]) 13100:1d.7 USB Controller: Intel Corp. 82801DB USB EHCI Controller (rev 01) (prog-if 20 [EHCI])
134</pre> 132</pre>
135 133
136<p> 134<p>
137So using the <c>lspci</c> command, we can find out if the system supports 135So using the <c>lspci</c> command, we can find out if the system supports
138USB 2.0. This is useful as we will be enabling the corresponding options in 136USB 2.0. This is useful as we will be enabling the corresponding options in
139the kernel. 137the kernel.
140</p> 138</p>
141 139
142</body> 140</body>
143</section> 141</section>
147<title>Kernel Configuration</title> 145<title>Kernel Configuration</title>
148<section> 146<section>
149<title>Getting the kernel</title> 147<title>Getting the kernel</title>
150<body> 148<body>
151 149
150<note>
151Since the 2005.0 release, Gentoo Linux uses 2.6 as the default kernel. Unless
152you are specifically using the 2.4 profile, <c>gentoo-sources</c> will be a
1532.6 kernel on <e>most</e> architectures. Please check your kernel version and
154then proceed with the configuration accordingly.
155</note>
156
152<p> 157<p>
153First emerge the kernel sources of your choice. Here we'll use the 158First emerge the kernel sources of your choice. Here we'll use the
154<c>gentoo-dev-sources</c> (for 2.6.x) and <c>gentoo-sources</c> (for 2.4.x). 159<c>gentoo-sources</c>. For more information on the various kernel sources
155For more information on the various kernel sources available on Portage, 160available on Portage, please look up the <uri
156please look up the <uri link="/doc/en/gentoo-kernel.xml">Gentoo Linux Kernel Guide</uri>. 161link="/doc/en/gentoo-kernel.xml">Gentoo Linux Kernel Guide</uri>.
157</p> 162</p>
158 163
159<pre caption="Getting the kernel sources"> 164<pre caption="Getting the kernel sources">
160<comment>(For 2.6.x)</comment>
161# <i> emerge gentoo-dev-sources</i>
162<comment>(For 2.4.x)</comment>
163# <i> emerge gentoo-sources</i> 165# <i>emerge gentoo-sources</i>
164</pre> 166</pre>
165 167
166<p> 168<p>
167Now, lets get on with the task of configuring the kernel. 169Now, lets get on with the task of configuring the kernel.
168</p> 170</p>
169 171
170<pre caption="Heading over to the source"> 172<pre caption="Heading over to the source">
171# <i> cd /usr/src/linux</i> 173# <i>cd /usr/src/linux</i>
172# <i> make menuconfig</i> 174# <i>make menuconfig</i>
173</pre> 175</pre>
174 176
175<note> 177<note>
176The above example assumes that <path>/usr/src/linux</path> symlink points to 178The above example assumes that <path>/usr/src/linux</path> symlink points to
177the kernel sources you want to use. Please ensure the same before proceeding. 179the kernel sources you want to use. Please ensure the same before proceeding.
178</note> 180</note>
179 181
180</body> 182</body>
181</section> 183</section>
182
183<section id="2.6.xconfig"> 184<section id="newkernelconfig">
184<title>Config options for the 2.6.x kernel</title> 185<title>Config options for the 2.6.x kernel</title>
185<body> 186<body>
186 187
187<p> 188<p>
188Now we will look at some of the options we will have to enable in the 2.6 189Now we will look at some of the options we will have to enable in the 2.6
189kernel to ensure proper USB support for our devices. If you are using a 2.4 190kernel to ensure proper USB support for our devices. If you are using a 2.4
190kernel, please proceed with <uri link="#2.4.xconfig">Config options for the 191kernel, please proceed with <uri link="#oldkernelconfig">Config options for the
1912.4.x kernel</uri>. 1922.4.x kernel</uri>.
192</p> 193</p>
193 194
194<note> 195<note>
195Examples in this document will show configuration options for basic USB 196Examples in this document will show configuration options for basic USB
196support as well as those needed commonly, for example a USB mass storage 197support as well as those needed commonly, for example a USB mass storage
197device (most cameras and USB pen drives). If you have a specific USB device 198device (most cameras and USB pen drives). If you have a specific USB device
198that needs to be configured, please look up your device's manual or search 199that needs to be configured, please look up your device's manual or search
199online to see if that device has support built-in into the kernel or custom 200online to see if that device has support built-in into the kernel or custom
200drivers that you can use. Please note that for the sake of ease, all examples 201drivers that you can use. Please note that for the sake of ease, all examples
201have the options compiled into the kernel. If you would like to have a modular 202have the options compiled into the kernel. If you would like to have a modular
202kernel, ensure that you note down the various modules and adjust your config 203kernel, ensure that you note down the various modules and adjust your config
203files accordingly. 204files accordingly.
204</note> 205</note>
205 206
206<pre caption="make menuconfig options for 2.6 kernels"> 207<pre caption="make menuconfig options for 2.6 kernels">
207Device Drivers ---&gt; 208Device Drivers ---&gt;
208 SCSI device support ---&gt; 209 SCSI device support ---&gt;
209 210
210<comment>(Although SCSI will be enabled automatically when selecting USB Mass Storage, we need to enable disk support.)</comment> 211<comment>(Although SCSI will be enabled automatically when selecting USB Mass Storage,
212we need to enable disk support.)</comment>
211--- SCSI support type (disk, tape, CD-ROM) 213--- SCSI support type (disk, tape, CD-ROM)
212&lt;*&gt; SCSI disk support 214&lt;*&gt; SCSI disk support
213 215
214<comment>(Then move back a level and go into USB support)</comment> 216<comment>(Then move back a level and go into USB support)</comment>
215USB support ---&gt; 217USB support ---&gt;
216 218
217<comment>(This is the root hub and is required for USB support. If you'd like to compile this as a module,</comment> 219<comment>(This is the root hub and is required for USB support.
218<comment> it will be called usbcore.)</comment> 220If you'd like to compile this as a module, it will be called usbcore.)</comment>
219&lt;*&gt; Support for Host-side USB 221&lt;*&gt; Support for Host-side USB
220 222
221<comment>(Enable this option to see your USB devices in /proc/bus/usb. This is recommended.)</comment> 223<comment>(Enable this option to see your USB devices in /proc/bus/usb.
224This is recommended.)</comment>
222 [*] USB device filesystem 225 [*] USB device filesystem
223 226
224<comment>(Select at least one of the HCDs. If you are unsure, picking all is fine.)</comment> 227<comment>(Select at least one of the HCDs. If you are unsure, picking all is fine.)</comment>
225--- USB Host Controller Drivers 228--- USB Host Controller Drivers
226&lt;*&gt; EHCI HCD (USB 2.0) support 229&lt;*&gt; EHCI HCD (USB 2.0) support
227&lt; &gt; OHCI HCD support 230&lt; &gt; OHCI HCD support
228&lt;*&gt; UHCI HCD (most Intel and VIA) support 231&lt;*&gt; UHCI HCD (most Intel and VIA) support
229 232
230<comment>(Moving a little further down, we come to CDC and mass storage.)</comment> 233<comment>(Moving a little further down, we come to CDC and mass storage.)</comment>
231&lt; &gt; USB Modem (CDC ACM) support 234&lt; &gt; USB Modem (CDC ACM) support
232&lt;*&gt; USB Printer support 235&lt;*&gt; USB Printer support
233&lt;*&gt; USB Mass Storage support 236&lt;*&gt; USB Mass Storage support
234 [*] USB Mass Storage Write-Protected Media Detection (EXPERIMENTAL)
235 237
236<comment>(And then the HID bits. You have to select HID input support if you have a USB</comment> 238<comment>(Then the HID bits.
239You have to select HID input support if you have a USB keyboard,
237<comment> keyboard, mouse, joystick or any other USB input device)</comment> 240mouse, joystick or any other USB input device)</comment>
238--- USB Input Devices 241--- USB Input Devices
239&lt;*&gt; USB Human Interface Device (full HID) support 242&lt;*&gt; USB Human Interface Device (full HID) support
240 [*] HID input layer support 243 [*] HID input layer support
241 244
242<comment>(If you have a USB Network Card like the RTL8150, you'll need this)</comment> 245<comment>(If you have a USB Network Card like the RTL8150, you'll need this)</comment>
244 &lt;*&gt; USB RTL8150 based ethernet device support (EXPERIMENTAL) 247 &lt;*&gt; USB RTL8150 based ethernet device support (EXPERIMENTAL)
245 248
246<comment>(If you have a serial to USB converter like the Prolific 2303, you'll need this)</comment> 249<comment>(If you have a serial to USB converter like the Prolific 2303, you'll need this)</comment>
247USB Serial Converter support ---> 250USB Serial Converter support --->
248 &lt;*&gt; USB Serial Converter support 251 &lt;*&gt; USB Serial Converter support
249 &lt;*&gt; USB Prolific 2303 Single Port Serial Driver (NEW) 252 &lt;*&gt; USB Prolific 2303 Single Port Serial Driver (NEW)
250</pre> 253</pre>
251 254
252<p> 255<p>
253Now that your options are set, you can (re)compile the kernel and USB support 256Now that your options are set, you can (re)compile the kernel and USB support
254should be functional once you reboot into the new kernel. You can now proceed 257should be functional once you reboot into the new kernel. You can now proceed
255to <uri link="#postkern">Seeing USB at work</uri> and see if everything is 258to <uri link="#postkern">Seeing USB at work</uri> and see if everything is
256working as it should. 259working as it should.
257</p> 260</p>
258</body>
259</section>
260 261
262</body>
263</section>
261<section id="2.4.xconfig"> 264<section id="oldkernelconfig">
262<title>Config options for the 2.4.x kernel</title> 265<title>Config options for the 2.4.x kernel</title>
263<body> 266<body>
264 267
265<p> 268<p>
266We will look at the options the we will have to enable in the 2.4 kernel to 269We will look at the options the we will have to enable in the 2.4 kernel to
267ensure proper USB support for our devices. If you are using a 2.6 kernel, 270ensure proper USB support for our devices. If you are using a 2.6 kernel,
268please look at <uri link="#2.6.xconfig">Config options for the 2.6.x 271please look at <uri link="#newkernelconfig">Config options for the 2.6.x
269kernel</uri>. 272kernel</uri>.
270</p> 273</p>
271 274
272<note> 275<note>
273Examples in this document will show configuration options for basic USB 276Examples in this document will show configuration options for basic USB
274support as well as those needed commonly, for example a USB mass storage 277support as well as those needed commonly, for example a USB mass storage
275device (most cameras and USB pen drives). If you have a specific USB device 278device (most cameras and USB pen drives). If you have a specific USB device
276that needs to be configured, please look up your device's manual or search 279that needs to be configured, please look up your device's manual or search
277online to see if that device has support built-in into the kernel or custom 280online to see if that device has support built-in into the kernel or custom
278drivers that you can use. Please note that for the sake of ease, all examples 281drivers that you can use. Please note that for the sake of ease, all examples
279have the options compiled into the kernel. If you would like to have a modular 282have the options compiled into the kernel. If you would like to have a modular
280kernel, ensure that you note down the various modules and adjust your config 283kernel, ensure that you note down the various modules and adjust your config
281files accordingly. 284files accordingly.
282</note> 285</note>
283 286
284<pre caption="make menuconfig options for 2.4 kernels"> 287<pre caption="make menuconfig options for 2.4 kernels">
285<comment>(This immediate config is only for those who have USB input devices. Input</comment> 288<comment>(This immediate config is only for those who have USB input devices.
286<comment> core support is needed by USB HID later.)</comment> 289Input core support is needed by USB HID later.)</comment>
287Input core support ---&gt; 290Input core support ---&gt;
288 &lt;*&gt; Input core support 291 &lt;*&gt; Input core support
289 &lt; &gt; Keyboard support 292 &lt; &gt; Keyboard support
290 &lt; &gt; Mouse support 293 &lt; &gt; Mouse support
291 &lt; &gt; Event interface support 294 &lt; &gt; Event interface support
292 295
293USB support ---&gt; 296USB support ---&gt;
294 297
295<comment>(This is the root hub and is required for USB support. If you'd like to compile this as a module,</comment> 298<comment>(This is the root hub and is required for USB support.
296<comment> it will be called usbcore.o)</comment> 299If you'd like to compile this as a module, it will be called usbcore.o)</comment>
297&lt;*&gt; Support for USB 300&lt;*&gt; Support for USB
298 301
299<comment>(Enable this option to see your USB devices in /proc/bus/usb. This is recommended.)</comment> 302<comment>(Enable this option to see your USB devices in /proc/bus/usb.
303This is recommended.)</comment>
300 [*] Preliminary USB device filesystem 304 [*] Preliminary USB device filesystem
301 305
302<comment>(Select at least one of the HCDs. If you are unsure, picking all is fine.)</comment> 306<comment>(Select at least one of the HCDs. If you are unsure, picking all is fine.)</comment>
303--- USB Host Controller Drivers 307--- USB Host Controller Drivers
304&lt;*&gt; UHCI Alternate Driver (JE) support 308&lt;*&gt; UHCI Alternate Driver (JE) support
305&lt; &gt; OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support 309&lt; &gt; OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support
306 310
307<comment>(This is the device section. Select only what you need.)</comment> 311<comment>(This is the device section. Select only what you need.)</comment>
308--- USB Device Class drivers 312--- USB Device Class drivers
309&lt; &gt; USB Audio support 313&lt; &gt; USB Audio support
310&lt;*&gt; USB Mass Storage support 314&lt;*&gt; USB Mass Storage support
311&lt; &gt; USB Modem (CDC ACM) support 315&lt; &gt; USB Modem (CDC ACM) support
312&lt;*&gt; USB Printer support 316&lt;*&gt; USB Printer support
313 317
321 &lt;*&gt; USB Serial Converter support 325 &lt;*&gt; USB Serial Converter support
322 &lt;*&gt; USB Prolific 2303 Single Port Serial Driver (NEW) 326 &lt;*&gt; USB Prolific 2303 Single Port Serial Driver (NEW)
323</pre> 327</pre>
324 328
325<p> 329<p>
326Now that the options are set, you can (re)compile the kernel and USB support 330Now that the options are set, you can (re)compile the kernel and USB support
327should be functional once you reboot into the new kernel. 331should be functional once you reboot into the new kernel.
328</p> 332</p>
333
329</body> 334</body>
330</section> 335</section>
331</chapter> 336</chapter>
332 337
333<chapter id="postkern"> 338<chapter id="postkern">
335<section> 340<section>
336<title>dmesg is your friend!</title> 341<title>dmesg is your friend!</title>
337<body> 342<body>
338 343
339<p> 344<p>
340The time has finally come to play with those USB devices :) So let's get 345The time has finally come to play with those USB devices :) So let's get
341started. In this chapter, we'll see how the system responds to various USB 346started. In this chapter, we'll see how the system responds to various USB
342devices. We'll start by plugging in a USB 512 MB Memory Stick/Pen Drive. You 347devices. We'll start by plugging in a USB 512 MB Memory Stick/Pen Drive. You
343could use some other similar mass storage device. We will primarily use 348could use some other similar mass storage device. We will primarily use
344<c>dmesg</c> to see what is happening and how the system responds to the 349<c>dmesg</c> to see what is happening and how the system responds to the
345device. 350device.
346</p> 351</p>
347 352
348<note> 353<note>
349<c>dmesg</c> will generally give a lot of output up front before coming to the 354<c>dmesg</c> will generally give a lot of output up front before coming to the
350info we need, as it reads the kernel ring buffer that has all the boot up 355info we need, as it reads the kernel ring buffer that has all the boot up
351messages as well. The output in the following examples have only the relevant 356messages as well. The output in the following examples have only the relevant
352portion(s) ans extra spaces in between to enable better readability. 357portion(s) and extra spaces in between to enable better readability. If needed
358please use a <c>dmesg | more</c> or <c>dmesg | less</c> to see the output
359better in your system.
353</note> 360</note>
354 361
355<pre caption="dmesg output for Memory Stick"> 362<pre caption="dmesg output for Memory Stick">
356<comment>(Plug in Memory Stick into available USB port and then..)</comment> 363<comment>(Plug in Memory Stick into available USB port and then..)</comment>
357# <i>dmesg</i> 364# <i>dmesg | less</i>
358 365
359<comment>(The device is picked up as a USB 1.1 and allocated an address. Also says what HCD it is using.)</comment> 366<comment>(The device is picked up as a USB 1.1 and allocated an address.
367Also says what HCD it is using.)</comment>
360usb 1-1: new full speed USB device using uhci_hcd and address 2 368usb 1-1: new full speed USB device using uhci_hcd and address 2
361 369
362<comment>(SCSI emulation automatically kicks in)</comment> 370<comment>(SCSI emulation automatically kicks in)</comment>
363scsi0 : SCSI emulation for USB Mass Storage devices 371scsi0 : SCSI emulation for USB Mass Storage devices
364usb-storage: device found at 2 372usb-storage: device found at 2
383<comment>(When the device is disconnected, the system acknowledges the same)</comment> 391<comment>(When the device is disconnected, the system acknowledges the same)</comment>
384usb 1-1: USB disconnect, address 2 392usb 1-1: USB disconnect, address 2
385</pre> 393</pre>
386 394
387<p> 395<p>
388Once the device is connected and mounted, you can access it like a normal hard 396Once the device is connected and mounted, you can access it like a normal hard
389disk. Usual operations like <c>cp</c>, <c>mv</c>, <c>rm</c> etc work fine. You 397disk. Usual operations like <c>cp</c>, <c>mv</c>, <c>rm</c>, etc work fine. You
390could also create a filesystem on the USB stick/format it. 398could also create a filesystem on the USB stick/format it.
391</p> 399</p>
392 400
393<pre caption="Accessing the Memory Stick"> 401<pre caption="Accessing the Memory Stick">
394# <i>mount /dev/sda1 /mnt/usb</i> 402# <i>mount /dev/sda1 /mnt/usb</i>
399none 189M 0 189M 0% /dev/shm 407none 189M 0 189M 0% /dev/shm
400/dev/sda1 490M 34M 457M 7% /mnt/usb 408/dev/sda1 490M 34M 457M 7% /mnt/usb
401</pre> 409</pre>
402 410
403<note> 411<note>
404Digital cameras can be accessed the same way as memory sticks. I have a Nikon 412Digital cameras can be accessed the same way as memory sticks. I have a Nikon
405Coolpix 5200 and this is the way I access it. The camera is set to behave like 413Coolpix 5200 and this is the way I access it. Cameras these days usually have
406a USB mass storage device (as against PTP mode, which most cameras have these 414two modes to transfer pictures; USB mass storage and PTP (Picture Transfer
407days) and the procedure is exactly the same, because of which I have not 415Protocol). The camera is set to USB mass storage mode and hence the procedure is
416exactly the same as that of accessing a memory stick because of which I have not
408explained in detail about the same. Please note that this may NOT work in all 417explained in detail about it. Please note that this may NOT work in all cases
409cases and with all digital cameras that have USB support. 418and with all digital cameras that have USB support.
410</note> 419</note>
411 420
412<p> 421<p>
413How would a USB mouse show up in case you had one? It will show up as an HID 422How would a USB mouse show up in case you had one? It will show up as an HID
414device. 423device.
415</p> 424</p>
416 425
417<pre caption="USB Optical Mouse"> 426<pre caption="USB Optical Mouse">
418# <i>dmesg | grep USB</i> 427# <i>dmesg | grep USB</i>
420usb 1-1: new low speed USB device using address 2 429usb 1-1: new low speed USB device using address 2
421input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:07.2-1 430input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:07.2-1
422</pre> 431</pre>
423 432
424<p> 433<p>
425Another nifty command you can use to see the status of your USB ports is 434Another nifty command you can use to see the status of your USB ports is
426<c>lsusb</c>. This is part of <c>sys-apps/usbutils</c> and will be covered in 435<c>lsusb</c>. This is part of <c>sys-apps/usbutils</c> and will be covered in
427the next chapter. 436the next chapter.
428</p> 437</p>
429 438
430</body> 439</body>
431</section> 440</section>
436<section> 445<section>
437<title>Nifty tools</title> 446<title>Nifty tools</title>
438<body> 447<body>
439 448
440<p> 449<p>
441So far we've seen how much support exists on the kernel/system side for USB on 450So far we've seen how much support exists on the kernel/system side for USB on
442Linux. Now we'll take a peek into what kind of support is provided by Gentoo 451Linux. Now we'll take a peek into what kind of support is provided by Gentoo
443for USB in the userspace. 452for USB in the userspace.
444</p> 453</p>
445 454
446<p> 455<p>
447One of the most useful tools around is <c>lsusb</c>. This lists all the usb 456One of the most useful tools around is <c>lsusb</c>. This lists all the usb
448devices connected to the system. Installing it is a breeze. 457devices connected to the system. Installing it is a breeze.
449</p> 458</p>
450 459
451<pre caption="Installing usbutils"> 460<pre caption="Installing usbutils">
452# <i>emerge usbutils</i> 461# <i>emerge usbutils</i>
453</pre> 462</pre>
454 463
455<p> 464<p>
456Once installed, you can just run <c>lsusb</c> to get simple info on the USB 465Once installed, you can just run <c>lsusb</c> to get simple info on the USB
457devices attached to the machine. 466devices attached to the machine.
458</p> 467</p>
459 468
460<note> 469<note>
461You have to be root in most cases to run <c>lsusb</c>. 470You have to be root in most cases to run <c>lsusb</c>.
462</note> 471</note>
463 472
464<warn> 473<warn>
465<c>lsusb</c> reads the information for the USB devices from 474<c>lsusb</c> reads the information for the USB devices from
466<path>/proc/bus/usb</path>. If you have not enabled that in your kernel, 475<path>/proc/bus/usb</path>. If you have not enabled that in your kernel,
467chances are that <c>lsusb</c> may not work at all. Please ensure you have 476chances are that <c>lsusb</c> may not work at all. Please ensure you have
468<path>/proc</path> filesystem support enabled in your kernel and that 477<path>/proc</path> filesystem support enabled in your kernel and that
469<c>usbfs</c> is mounted at <path>/proc/bus/usb</path> (which should happen 478<c>usbfs</c> is mounted at <path>/proc/bus/usb</path> (which should happen
470automatically). 479automatically).
471</warn> 480</warn>
472 481
479<comment>(This is the root hub)</comment> 488<comment>(This is the root hub)</comment>
480Bus 001 Device 001: ID 0000:0000 489Bus 001 Device 001: ID 0000:0000
481</pre> 490</pre>
482 491
483<p> 492<p>
484If you are one of those types who love to see lots of information, you have 493If you are one of those types who love to see lots of information, you have
485the option of running <c>lsusb -v</c>. Try that and see the amount of info it 494the option of running <c>lsusb -v</c>. Try that and see the amount of info it
486gives out. Another good option is that <c>lsusb</c> dumps the current physical 495gives out. Another good option is that <c>lsusb</c> dumps the current physical
487USB hierarchy as a tree and thus makes it easier to understand the exact 496USB hierarchy as a tree and thus makes it easier to understand the exact
488device map. The command is <c>lsusb -t</c>. For example, 497device map. The command is <c>lsusb -t</c>. For example,
489</p> 498</p>
490 499
491<pre caption="lsusb showing USB hierarchy"> 500<pre caption="lsusb showing USB hierarchy">
492# <i>lsusb -t</i> 501# <i>lsusb -t</i>
495 |-Dev# 2 Vendor 0x046d Product 0xc00e 504 |-Dev# 2 Vendor 0x046d Product 0xc00e
496 `-Dev# 3 Vendor 0x0c76 Product 0x0005 505 `-Dev# 3 Vendor 0x0c76 Product 0x0005
497</pre> 506</pre>
498 507
499<p> 508<p>
500You can easily correlate the outputs of <c>lsusb</c> and <c>lsusb -t</c>, 509You can easily correlate the outputs of <c>lsusb</c> and <c>lsusb -t</c>,
501which helps debugging as well as understanding how USB works. 510which helps debugging as well as understanding how USB works.
502</p> 511</p>
503 512
504</body> 513</body>
505</section> 514</section>
506
507<section> 515<section>
508<title>Hot or Cold plug??</title> 516<title>Hotplug</title>
509<body> 517<body>
510 518
511<p>
512Gentoo uses two packages, <c>sys-apps/hotplug</c> and <c>sys-apps/coldplug</c>
513to do some magic with <e>hot-pluggable</e> devices. Just like any other magic
514trick, there is a simple logic behind this one too. We shall now see what that
515is, and in the process hopefully we will be able to understand these twins
516better.
517</p> 519<p>
518 520Gentoo uses <c>sys-apps/hotplug</c> to do some magic with <e>hot-pluggable</e>
521devices. Just like any other magic trick, there is a simple logic behind this
522one too. We shall now see what that is, and in the process hopefully we will be
523able to understand these twins better.
519<p> 524</p>
525
526<p>
520Firmware can be defined as the software on a piece of hardware that is loaded 527Firmware can be defined as the software on a piece of hardware that is loaded
521and executed but can't be modified easily. Many devices have firmware in them 528and executed but can't be modified easily. Many devices have firmware in them
522to ensure that they work properly and often firmware may contain code that is 529to ensure that they work properly and often firmware may contain code that is
523critical to ensure that the hardware performs as expected. Firmware is present 530critical to ensure that the hardware performs as expected. Firmware is present
524in a wide variety of computer devices ranging from ROM chips to state of the 531in a wide variety of computer devices ranging from ROM chips to state of the
525art USB and PCMCIA cards. When a device is plugged in, the firmware (which may 532art USB and PCMCIA cards. When a device is plugged in, the firmware (which may,
526in some cases be the driver as well) is read and loaded onto memory after 533in some cases, be the driver as well) is read and loaded onto memory after
527which the device can be used by the system. 534which the device can be used by the system.
528</p> 535</p>
529 536
530<p> 537<p>
531To cut the long story short, Gentoo uses <c>sys-apps/hotplug</c> to handle 538To cut the long story short, Gentoo uses <c>sys-apps/hotplug</c> to handle
532the firmware side of things in <e>hot-pluggable</e> devices. 539the firmware side of things in <e>hot-pluggable</e> devices.
533<c>sys-apps/hotplug</c> will use the required firmware to make that device 540<c>sys-apps/hotplug</c> will use the required firmware to make that device
534usable. The firmware should be put in the <path>/lib/firmware</path> directory 541usable. The firmware should be put in the <path>/lib/firmware</path> directory
535and is picked up from there. Getting it is simple, the usual emerge will do. 542and is picked up from there. Getting it is simple; the usual emerge will do.
536</p> 543</p>
537 544
538<pre caption="Installing hotplug"> 545<pre caption="Installing hotplug">
539# <i>emerge hotplug</i> 546# <i>emerge hotplug</i>
540</pre> 547</pre>
541 548
542<p>
543Now the obvious question would be, what is coldplug and why is it needed?
544<c>sys-apps/coldplug</c> does what hotplug does, but it does it for
545<e>hot-pluggable</e> devices that are already connected at boot time. A good
546example of this would be a USB Network card. Earlier hotplug was the package
547responsible for handling both but then it was split into hotplug and coldplug,
548each with their distinct purposes. Emerge it if you have <e>hot-pluggable</e>
549devices that you need activated on boot up.
550</p>
551
552<pre caption="Installing coldplug">
553# <i>emerge coldplug</i>
554<comment>(And you can add it to the boot runlevel)</comment>
555# <i>rc-update add coldplug boot</i>
556 * coldplug added to runlevel boot
557 * rc-update complete.
558</pre>
559
560<note>
561The above initscript does what hotplug's initscript used to do (for already
562attached hot-pluggable devices). hotplug does not have an initscript of its
563own as of now.
564</note>
565
566</body> 549</body>
567</section> 550</section>
568</chapter> 551</chapter>
569 552
570<chapter> 553<chapter>
572<section> 555<section>
573<title>References</title> 556<title>References</title>
574<body> 557<body>
575 558
576<p> 559<p>
577A good number of documents online helped me during writing this, and there are 560A good number of online documents helped me during the development of this
578some that are that are highly technical but truly interesting. I thought they 561document and there are some that are highly technical but truly interesting.
579all deserve some credit. So here we go! 562I thought they all deserve some credit, so here we go!
580</p>
581<p> 563</p>
564
565<ul>
5821) <uri link="http://www.usb.org">The Official USB Website</uri> 566 <li><uri link="http://www.usb.org">The Official USB Website</uri></li>
583</p>
584<p>
5852) <uri link="http://www.usb.org/faq">The USB FAQ</uri> 567 <li><uri link="http://www.usb.org/about/faq">The USB FAQ</uri></li>
586</p> 568 <li>
587<p> 569 <uri
5883) <uri link="http://h18000.www1.hp.com/productinfo/development/openhci.html">Compaq's OHCI Standard</uri> 570 link="http://h18000.www1.hp.com/productinfo/development/openhci.html">Compaq's
589</p> 571 OHCI Standard</uri>
590<p> 572 </li>
573 <li>
5914) <uri link="http://developer.intel.com/technology/usb/uhci11d.htm">Intel's UHCI Standard</uri> 574 <uri link="http://developer.intel.com/technology/usb/uhci11d.htm">Intel's
592</p> 575 UHCI Standard</uri>
593<p> 576 </li>
577 <li>
5945) <uri link="http://www.intel.com/technology/usb/ehcispec.htm">Intel's EHCI Standard</uri> 578 <uri link="http://www.intel.com/technology/usb/ehcispec.htm">Intel's EHCI
595</p> 579 Standard</uri>
580 </li>
581</ul>
582
583</body>
584</section>
585<section>
586<title>Other Interesting Links</title>
587<body>
588
589<ul>
590 <li><uri link="/doc/en/liveusb.xml">Gentoo Linux LiveUSB HOWTO</uri></li>
591</ul>
596 592
597</body> 593</body>
598</section> 594</section>
599</chapter> 595</chapter>
600</guide> 596</guide>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20