]> pere.pagekite.me Git - homepage.git/blob - blog/data/2013-01-14-hw-autoinstall-modalias.txt
240b21d52c60ed16108e2adbba4cb5c38216fb7c
[homepage.git] / blog / data / 2013-01-14-hw-autoinstall-modalias.txt
1 Title: Modalias strings - a practical way to map "stuff" to hardware
2 Tags: english, debian
3 Date: 2013-01-14 11:10
4
5 <p>While looking into how to look up Debian packages based on hardware
6 information, to find the packages that support a given piece of
7 hardware, I refreshed my memory regarding modalias values, and decided
8 to document the details. Here are my findings so far, also available
9 in
10 <a href="http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/">the
11 Debian Edu subversion repository</a>:
12
13 <p><strong>Modalias decoded</strong></p>
14
15 <p>This document try to explain what the different types of modalias
16 values stands for. It is in part based on information from
17 &lt;URL: <a href="https://wiki.archlinux.org/index.php/Modalias">https://wiki.archlinux.org/index.php/Modalias</a> &gt;,
18 &lt;URL: <a href="http://unix.stackexchange.com/questions/26132/how-to-assign-usb-driver-to-device">http://unix.stackexchange.com/questions/26132/how-to-assign-usb-driver-to-device</a> &gt;,
19 &lt;URL: <a href="http://code.metager.de/source/history/linux/stable/scripts/mod/file2alias.c">http://code.metager.de/source/history/linux/stable/scripts/mod/file2alias.c</a> &gt; and
20 &lt;URL: <a href="http://cvs.savannah.gnu.org/viewvc/dmidecode/dmidecode.c?root=dmidecode&view=markup">http://cvs.savannah.gnu.org/viewvc/dmidecode/dmidecode.c?root=dmidecode&view=markup</a> &gt;.
21
22 <p><strong>PCI subtype</strong></p>
23
24 <p>A typical PCI entry can look like this. This is an Intel Host
25 Bridge memory controller:</p>
26
27 <p><blockquote>
28 pci:v00008086d00002770sv00001028sd000001ADbc06sc00i00
29 </blockquote></p>
30
31 <p>This represent these values:</p>
32
33 <pre>
34 v 00008086 (vendor)
35 d 00002770 (device)
36 sv 00001028 (subvendor)
37 sd 000001AD (subdevice)
38 bc 06 (bus class)
39 sc 00 (bus subclass)
40 i 00 (interface)
41 </pre>
42
43 <p>The vendor/device values are the same values outputted from 'lspci
44 -n' as 8086:2770. The bus class/subclass is also shown by lspci as
45 0600. The 0600 class is a host bridge. Other useful bus values are
46 0300 (VGA compatible card) and 0200 (Ethernet controller).</p>
47
48 <p>Not sure how to figure out the interface value, nor what it
49 means.</p>
50
51 <p><strong>USB subtype</strong></p>
52
53 <p>Some typical USB entries can look like this. This is an internal
54 USB hub in a laptop:</p>
55
56 <p><blockquote>
57 usb:v1D6Bp0001d0206dc09dsc00dp00ic09isc00ip00
58 </blockquote></p>
59
60 <p>Here is the values included in this alias:</p>
61
62 <pre>
63 v 1D6B (device vendor)
64 p 0001 (device product)
65 d 0206 (bcddevice)
66 dc 09 (device class)
67 dsc 00 (device subclass)
68 dp 00 (device protocol)
69 ic 09 (interface class)
70 isc 00 (interface subclass)
71 ip 00 (interface protocol)
72 </pre>
73
74 <p>The 0900 device class/subclass means hub. Some times the relevant
75 class is in the interface class section. For a simple USB web camera,
76 these alias entries show up:</p>
77
78 <p><blockquote>
79 usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc01ip00
80 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc02ip00
81 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc01ip00
82 <br>usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc02ip00
83 </blockquote></p>
84
85 <p>Interface class 0E01 is video control, 0E02 is video streaming (aka
86 camera), 0101 is audio control device and 0102 is audio streaming (aka
87 microphone). Thus this is a camera with microphone included.</p>
88
89 <p><strong>ACPI subtype</strong></p>
90
91 <p>The ACPI type is used for several non-PCI/USB stuff. This is an IR
92 receiver in a Thinkpad X40:</p>
93
94 <p><blockquote>
95 acpi:IBM0071:PNP0511:
96 </blockquote></p>
97
98 <p>The values between the colons are IDs.</p>
99
100 <p><strong>DMI subtype</strong></p>
101
102 <p>The DMI table contain lots of information about the computer case
103 and model. This is an entry for a IBM Thinkpad X40, fetched from
104 /sys/devices/virtual/dmi/id/modalias:</p>
105
106 <p><blockquote>
107 dmi:bvnIBM:bvr1UETB6WW(1.66):bd06/15/2005:svnIBM:pn2371H4G:pvrThinkPadX40:rvnIBM:rn2371H4G:rvrNotAvailable:cvnIBM:ct10:cvrNotAvailable:
108 </blockquote></p>
109
110 <p>The values present are</p>
111
112 <pre>
113 bvn IBM (BIOS vendor)
114 bvr 1UETB6WW(1.66) (BIOS version)
115 bd 06/15/2005 (BIOS date)
116 svn IBM (system vendor)
117 pn 2371H4G (product name)
118 pvr ThinkPadX40 (product version)
119 rvn IBM (board vendor)
120 rn 2371H4G (board name)
121 rvr NotAvailable (board version)
122 cvn IBM (chassis vendor)
123 ct 10 (chassis type)
124 cvr NotAvailable (chassis version)
125 </pre>
126
127 <p>The chassis type 10 is Notebook. Other interesting values can be
128 found in the dmidecode source:</p>
129
130 <pre>
131 3 Desktop
132 4 Low Profile Desktop
133 5 Pizza Box
134 6 Mini Tower
135 7 Tower
136 8 Portable
137 9 Laptop
138 10 Notebook
139 11 Hand Held
140 12 Docking Station
141 13 All In One
142 14 Sub Notebook
143 15 Space-saving
144 16 Lunch Box
145 17 Main Server Chassis
146 18 Expansion Chassis
147 19 Sub Chassis
148 20 Bus Expansion Chassis
149 21 Peripheral Chassis
150 22 RAID Chassis
151 23 Rack Mount Chassis
152 24 Sealed-case PC
153 25 Multi-system
154 26 CompactPCI
155 27 AdvancedTCA
156 28 Blade
157 29 Blade Enclosing
158 </pre>
159
160 <p>The chassis type values are not always accurately set in the DMI
161 table. For example my home server is a tower, but the DMI modalias
162 claim it is a desktop.</p>
163
164 <p><strong>SerIO subtype</strong></p>
165
166 <p>This type is used for PS/2 mouse plugs. One example is from my
167 test machine:</p>
168
169 <p><blockquote>
170 serio:ty01pr00id00ex00
171 </blockquote></p>
172
173 <p>The values present are</p>
174
175 <pre>
176 ty 01 (type)
177 pr 00 (prototype)
178 id 00 (id)
179 ex 00 (extra)
180 </pre>
181
182 <p>This type is supported by the psmouse driver. I am not sure what
183 the valid values are.</p>
184
185 <p><strong>Other subtypes</strong></p>
186
187 <p>There are heaps of other modalias subtypes according to
188 file2alias.c. There is the rest of the list from that source: amba,
189 ap, bcma, ccw, css, eisa, hid, i2c, ieee1394, input, ipack, isapnp,
190 mdio, of, parisc, pcmcia, platform, scsi, sdio, spi, ssb, vio, virtio,
191 vmbus, x86cpu and zorro. I did not spend time documenting all of
192 these, as they do not seem relevant for my intended use with mapping
193 hardware to packages when new stuff is inserted during run time.</p>
194
195 <p><strong>Looking up kernel modules using modalias values</strong></p>
196
197 <p>To check which kernel modules provide support for a given modalias,
198 one can use the following shell script:</p>
199
200 <pre>
201 for id in $(cat $(find /sys -name modalias)|sort -u); do \
202 echo "$id" ; \
203 /sbin/modprobe --show-depends "$id"|sed 's/^/ /' ; \
204 done
205 </pre>
206
207 <p>The output can look like this (only the first few entries as the
208 list is very long on my test machine):</p>
209
210 <pre>
211 acpi:ACPI0003:
212 insmod /lib/modules/2.6.32-5-686/kernel/drivers/acpi/ac.ko
213 acpi:device:
214 FATAL: Module acpi:device: not found.
215 acpi:IBM0068:
216 insmod /lib/modules/2.6.32-5-686/kernel/drivers/char/nvram.ko
217 insmod /lib/modules/2.6.32-5-686/kernel/drivers/leds/led-class.ko
218 insmod /lib/modules/2.6.32-5-686/kernel/net/rfkill/rfkill.ko
219 insmod /lib/modules/2.6.32-5-686/kernel/drivers/platform/x86/thinkpad_acpi.ko
220 acpi:IBM0071:PNP0511:
221 insmod /lib/modules/2.6.32-5-686/kernel/lib/crc-ccitt.ko
222 insmod /lib/modules/2.6.32-5-686/kernel/net/irda/irda.ko
223 insmod /lib/modules/2.6.32-5-686/kernel/drivers/net/irda/nsc-ircc.ko
224 [...]
225 </pre>
226
227 <p>If you want to help implementing a system to let us propose what
228 packages to install when new hardware is plugged into a Debian
229 machine, please send me an email or talk to me on
230 <a href="irc://irc.debian.org/%23debian-devel">#debian-devel</a>.</p>