Typo
[linux_from_scratch_hints.git] / OLD / hardware-detection.txt
blobc4d0de24bea9d503ca7aece117e20704d928c449
1 AUTHOR: Alexander E. Patrakov <semzx at newmail dot ru>
2 DATE: 2003-12-03
3 LICENSE: GNU GPL
4 SYNOPSIS: Automatic Detection of PCI and USB Hardware in LFS
5 DESCRIPTION:
6 Sometimes you don't know exactly what type of hardware you have and don't
7 want to guess the correct module. Now you don't have to guess. Software
8 needed to automatically detect your hardware at boot time is described in
9 this hint.
11 PREREQUISITES: This hint works for LFS >=4.0, with or without devfs, with
12 2.4 or 2.6 kernel.
14 HINT:
15 Currently, LFS users must either compile all relevant device drivers into
16 the kernel statically or write some magic lines in /etc/modules.conf.
17 Either way, they need to know exactly what hardware thay have. This
18 information is not always available for notebooks and "rebranded" devices.
19 Fortunately, most of your hardware can be autodetected at boot time. One
20 drawback of my solution is that it doesn't work at all with ISA cards.
21 Another drawback is a two-second delay during the boot process. The third
22 drawback is that modules for not-so-often used hardware are loaded at boot
23 time, not on first use as it is the case for the variant with modules.conf.
25 BIG WARNING:
27 It has been reported that following this hint results in tons of
28 (possibly bogus) messages about overcurrent from USB modules on some
29 computers. I will not be responsible for any damaged hardware.
31 If you see or don't see these messages, please mail the author the output of
32 lspci and lsusb commands so that he can formulate the exact conditions
33 leading to these messages in the future versions of this hint.
35 HAVE YOU READ THE BIG WARNING ABOVE?
37 To make your computer detect hardware automatically, install the following
38 software:
40 1) pciutils
42 Instructions are in the BLFS book. You will need the patch named
43 pciutils-2.1.11-pcimodules-1.patch from the patches project since we will
44 use the pcimodules command.
46 This command should output the list of modules needed to support your PCI
47 cards, based on the contents of /lib/modules/`uname -r`/modules.pcimap file.
49 Test your installation of pciutils:
51 a) run the lspci command and see if the output is correct. At home I get the
52 following:
54 00:00.0 Host bridge: VIA Technologies, Inc. VT82C693A/694x [Apollo PRO133x]
55 (rev c4)
56 00:01.0 PCI bridge: VIA Technologies, Inc. VT82C598/694x [Apollo
57 MVP3/Pro133x AGP]
58 00:07.0 ISA bridge: VIA Technologies, Inc. VT82C686 [Apollo Super South]
59 (rev 40)
60 00:07.1 IDE interface: VIA Technologies, Inc. VT82C586/B/686A/B PIPC Bus
61 Master IDE (rev 06) 00:07.2 USB Controller: VIA
62 Technologies, Inc. USB (rev 1a)
63 00:07.4 SMBus: VIA Technologies, Inc. VT82C686 [Apollo Super ACPI] (rev 40)
64 00:0b.0 Communication controller: Lucent Microelectronics LT WinModem (rev
65 02)
66 00:0d.0 Multimedia audio controller: Fortemedia, Inc Xwave QS3000A
67 [FM801] (rev b2)
68 00:0d.1 Input device controller: Fortemedia, Inc Xwave QS3000A [FM801 game
69 port] (rev b2)
70 01:00.0 VGA compatible controller: nVidia Corporation NV11 [GeForce2 MX]
71 (rev b2)
73 b) run the pcimodules command and see if the results make any sense for the
74 running kernel.
76 I have the following output:
78 rivafb
79 snd-fm801
80 usb-uhci
81 uhci
82 parport_pc
84 If you want the pci.ids file to be in /usr/share/misc rather than in
85 /usr/share, use the patch named pciutils-2.1.11-sharedir-1.patch
87 2) [optional] usbutils
89 This package contains lsusb and usbmodules commands. They are the USB
90 equivalents of the lspci and pcimodules commands from pciutils. The package
91 is, strictly speaking, not needed because the hotplug script will parse
92 /proc/bus/usb/*/* files and detect USB devices even without usbutils. That
93 works for me. But the authors of the hotplug package write that the process
94 will be more reliable with usbutils.
96 Download location:
97 http://wwwbode.cs.tum.edu/Par/arch/usb/download/usbutils/usbutils-0.11.tar.gz
99 Installation instructions:
101 ./configure --prefix=/usr
102 make
103 make install
104 rm /usr/lib/libusb.*
105 rm /usr/include/libusb.h
107 Explanation of the last two commands: the libusb libraries installed by the
108 usbutils package are not used. The relevant code is linked statically into
109 lsusb and usbmodules programs. A newer, incompatible version of libusb is
110 available separately and it provides files /usr/lib/libusb-0.1.* and
111 /usr/include/usb.h. Other applications such as SANE use that newer version.
113 If you want the usb.ids file to be in /usr/share/misc rather than in
114 /usr/share, add the --datadir=/usr/share/misc switch to the ./configure
115 command.
117 Now test the package:
119 - insert modules that correspond to your USB controller. If in doubt, consult
120 the output of the pcimodules command. E.g.:
122 modprobe uhci
124 - mount the usb filesystem:
126 mount -t usbfs usbfs /proc/bus/usb
128 - run the lsusb command. On my system, the output is:
130 Unknown line at line 1809
131 Duplicate HUT Usage Spec at line 2650
132 Bus 001 Device 001: ID 0000:0000 Virtual Hub
133 Bus 001 Device 002: ID 05d8:4002 Ultima Electronics Corp. Lifetec LT9385
134 Scanner
136 (really this is Mustek 1200 UB plus)
138 - run the usbmodules command for one of the devices, e.g.:
140 usbmodules --device /proc/bus/usb/001/002
142 The output on my computer is:
144 scanner
146 Note that the usb.ids file shipped with the usbutils package is old and
147 incomplete. This is not a problem because the usbmodules command uses
148 another file, /lib/modules/`uname -r`/modules.usbmap to map devices to
149 module names.
151 3) hotplug
153 Download:
154 http://www.kernel.org/pub/linux/utils/kernel/hotplug/hotplug-2003_08_05.tar.b
157 The scripts in this package react to the hotplug events sent by kernel, and
158 also to the synthetic "coldplug" events at boot time. They use programs from
159 pciutils and usbutils to load the correct modules and execute specific
160 actions.
162 The scripts contained in the hotplug package have to be modified a bit to
163 conform to LFS standards. Do the following with etc/rc.d/init.d/hotplug:
165 a) [required] After the line "start|restart|status)" add:
166 [ -d /var/run/usb ] || mkdir -m 700 /var/run/usb
168 b) [required] Remove all lines that refer to /var/lock/subsys/hotplug - the
169 /var/lock/subsys directory is not used in LFS.
171 c) [cosmetic] Change all lines of the form "$RC $1" or "$RC start" to:
173             HW=`basename $RC .rc | tr [:lower:] [:upper:]`
174             echo "Detecting $HW hardware..."
175             $RC $1
176         (or $1 start)
177             report_status success
179 Do similar changes to lines of the form "$RS stop":
181             HW=`basename $RC .rc | tr [:lower:] [:upper:]`
182             echo "Stopping $HW hardware support..."
183             $RC stop
184             report_status success
186 Now copy all scripts contained in the hotplug package to their final places
187 and chown them to root:root. Make the following symlinks:
189 ln -s ../init.d/hotplug /etc/rc.d/rc3.d/S15hotplug
190 ln -s ../init.d/hotplug /etc/rc.d/rc4.d/S15hotplug
191 ln -s ../init.d/hotplug /etc/rc.d/rc5.d/S15hotplug
193 4) Linux kernel
195 Compile one kernel supporting all hardware on all target computers, with
196 lots of modules. Also compile ALSA, DRI and whatever packages that contain
197 modules. Don't forget the following:
199 a) Compile in "Support for hot-pluggable devices"
201 b) Compile in support for "Preliminary USB filesystem". My kernel has this
202 compiled in statically. It has been reported that compilation of it as a
203 module does not work as expected. I am too lazy to verify this.
205 c) Never compile your root device and filesystem as modules.
207 d) Don't forget that sometimes there are two drivers for the same device.
208 Compile only one of them, ok blacklist all modules except one (see below).
210 5) Configuration
212 a) /etc/modules.conf
214 Comment out all lines of the form "alias eth0 8139too" that specify the
215 driver explicitly. The modules will be loaded from the hotplug script. Note
216 that the order of your ethernet adapters may change if you have two of
217 different types.
219 b) /etc/fstab
221 Add the following line:
223 usbfs /proc/bus/usb usbfs defaults 0 0
225 FIXME: maybe this doesn't work on old computers without USB.
227 c) /etc/hotplug/blacklist
229 Add names of modules that you don't want to load automatically. Good
230 candidates are:
231 - duplicate drivers (e.g. e100 vs eepro100)
232 - unstable drivers (e.g. scanner in linux-2.4.21, my scanner worked well only
233   with libusb; the problem went away in 2.4.22)
234 - framebuffers (e.g. rivafb) if you primarily use X
235 - often-misdetected modules (e.g. i810_rng gives false positives)
237 d) Specific actions for specific hardware (aka quirks)
239 (you are lucky if you don't need them)
241 If you have anything specific to do with your USB hardware, create a script
242 in /etc/hotplug/usb. E.g., before one-endpoint scanners were well supported
243 by the scanner kernel module, I had to change permissions on the pseudofile
244 in /proc/bus/usb corresponding to my Mustek 1200 UB Plus scanner, so that I
245 could work with it as a user, not as root. This script accepts the name of
246 the pseudofile in the DEVICE environment variable. The complete
247 documentation concerning other variables is at the top of
248 /etc/hotplug/usb.agent. So I wrote this:
250 cat >/etc/hotplug/usb/mustek1200ubplus <<"EOF"
251 #!/bin/sh
252 chmod 666 $DEVICE
254 chmof 755 /etc/hotplug/usb/mustek1200ubplus
256 Then add a line to /etc/hotplug/usb.usermap, as described in the comment at
257 the top of file. I added the following (sorry for wrapping):
259 mustek1200ubplus     0x0003      0x05d8   0x4002    0x0000       0x0000
260 0x00         0x00            0x00            0x00            0x00
261 0x00               0x00000000
263 The idVendor and idProduct fields (0x05d8 and 0x4002) can be taken from the
264 output of lsusb. The first field is a logical OR of the following flags:
266 USB_MATCH_VENDOR=0x0001
267 USB_MATCH_PRODUCT=0x0002
268 USB_MATCH_DEV_LO=0x0004
269 USB_MATCH_DEV_HI=0x0008
270 USB_MATCH_DEV_CLASS=0x0010
271 USB_MATCH_DEV_SUBCLASS=0x0020
272 USB_MATCH_DEV_PROTOCOL=0x0040
273 USB_MATCH_INT_CLASS=0x0080
274 USB_MATCH_INT_SUBCLASS=0x0100
275 USB_MATCH_INT_PROTOCOL=0x0200
277 So my line basically says "Check for vendor and product IDs and ignore
278 everything else. If they are equal to 0x05d8 and 0x4002, the execute
279 the mustek1200ubplus script".
281 Of course, now there is no this line because linux-2.4.22 supports this
282 scanner well without libusb.
284 Apparently there is some support for such specific actions (e.g. firmware
285 loading) for PCI hardware. See the top of /etc/hotplug/pci.agent. I can't
286 say more because I don't need such actions.
288 6) Testing
290 Reboot and see if all needed modules are loaded by the hotplug script.
292 7) Problems
294 In my case, LT WinModem remains undetected. I resorted to
295 having a line for that modem in /etc/modules.conf:
297 alias /dev/tts/LT0 lt_serial
299 A different approach is to create a script named /etc/hotplug/hidden.rc that
300 executes modprobe commands for each undetectable module. Or you can edit
301 /lib/modules/`uname -r`/modules.pcimap.
303 Manual editing of /lib/modules/`uname -r`/modules.pcimap is also one of the
304 ways to deal with misdetections when the wrong module gets loaded (the other
305 way is blacklisting the wrong module).
307 8) Todo
309 - Add autoconfiguration of the X server
310 - Add something for ISA PNP cards
312 CHANGELOG:
313 2003-12-04: Initial submission