X-Git-Url: http://pere.pagekite.me/gitweb/homepage.git/blobdiff_plain/82fcb7b32991a75ff95efb8f8486cededce69f37..f2cb48659accd4757c7bbd81c82f9e779a7bbffe:/blog/archive/2013/01/index.html diff --git a/blog/archive/2013/01/index.html b/blog/archive/2013/01/index.html index ee632aa674..5b969a1f26 100644 --- a/blog/archive/2013/01/index.html +++ b/blog/archive/2013/01/index.html @@ -21,6 +21,437 @@

Entries from January 2013.

+
+
+ Using modalias info to find packages handling my hardware +
+
+ 15th January 2013 +
+
+

Yesterday, I wrote about the +modalias +values provided by the Linux kernel following my hope for +better +dongle support in Debian. Using this knowledge, I have tested how +modalias values attached to package names can be used to map packages +to hardware. This allow the system to look up and suggest relevant +packages when I plug in some new hardware into my machine, and replace +discover and discover-data as the database used to map hardware to +packages.

+ +

I create a modaliases file with entries like the following, +containing package name, kernel module name (if relevant, otherwise +the package name) and globs matching the relevant hardware +modalias.

+ +

+Package: package-name +
Modaliases: module(modaliasglob, modaliasglob, modaliasglob)

+

+ +

It is fairly trivial to write code to find the relevant packages +for a given modalias value using this file.

+ +

An entry like this would suggest the video and picture application +cheese for many USB web cameras (interface bus class 0E01):

+ +

+Package: cheese +
Modaliases: cheese(usb:v*p*d*dc*dsc*dp*ic0Eisc01ip*)

+

+ +

An entry like this would suggest the pcmciautils package when a +CardBus bridge (bus class 0607) PCI device is present:

+ +

+Package: pcmciautils +
Modaliases: pcmciautils(pci:v*d*sv*sd*bc06sc07i*) +

+ +

An entry like this would suggest the package colorhug-client when +plugging in a ColorHug with USB IDs 04D8:F8DA:

+ +

+Package: colorhug-client +
Modaliases: colorhug-client(usb:v04D8pF8DAd*)

+

+ +

I believe the format is compatible with the format of the Packages +file in the Debian archive. Ubuntu already uses their Packages file +to store their mappings from packages to hardware.

+ +

By adding a XB-Modaliases: header in debian/control, any .deb can +announce the hardware it support in a way my prototype understand. +This allow those publishing packages in an APT source outside the +Debian archive as well as those backporting packages to make sure the +hardware mapping are included in the package meta information. I've +tested such header in the pymissile package, and its modalias mapping +is working as it should with my prototype. It even made it to Ubuntu +Raring.

+ +

To test if it was possible to look up supported hardware using only +the shell tools available in the Debian installer, I wrote a shell +implementation of the lookup code. The idea is to create files for +each modalias and let the shell do the matching. Please check out and +try the +hw-support-lookup +shell script. It run without any extra dependencies and fetch the +hardware mappings from the Debian archive and the subversion +repository where I currently work on my prototype.

+ +

When I use it on a machine with a yubikey inserted, it suggest to +install yubikey-personalization:

+ +

+% ./hw-support-lookup +
yubikey-personalization +
% +

+ +

When I run it on my Thinkpad X40 with a PCMCIA/CardBus slot, it +propose to install the pcmciautils package:

+ +

+% ./hw-support-lookup +
pcmciautils +
% +

+ +

If you know of any hardware-package mapping that should be added to +my +database, please tell me about it.

+ +

It could be possible to generate several of the mappings between +packages and hardware. One source would be to look at packages with +kernel modules, ie packages with *.ko files in /lib/modules/, and +extract their modalias information. Another would be to look at +packages with udev rules, ie packages with files in +/lib/udev/rules.d/, and extract their vendor/model information to +generate a modalias matching rule. I have not tested any of these to +see if it work.

+ +

If you want to help implementing a system to let us propose what +packages to install when new hardware is plugged into a Debian +machine, please send me an email or talk to me on +#debian-devel.

+ +
+
+ + + Tags: debian, english. + + +
+
+
+ +
+
+ Modalias strings - a practical way to map "stuff" to hardware +
+
+ 14th January 2013 +
+
+

While looking into how to look up Debian packages based on hardware +information, to find the packages that support a given piece of +hardware, I refreshed my memory regarding modalias values, and decided +to document the details. Here are my findings so far, also available +in +the +Debian Edu subversion repository: + +

Modalias decoded

+ +

This document try to explain what the different types of modalias +values stands for. It is in part based on information from +<URL: https://wiki.archlinux.org/index.php/Modalias >, +<URL: http://unix.stackexchange.com/questions/26132/how-to-assign-usb-driver-to-device >, +<URL: http://code.metager.de/source/history/linux/stable/scripts/mod/file2alias.c > and +<URL: http://cvs.savannah.gnu.org/viewvc/dmidecode/dmidecode.c?root=dmidecode&view=markup >. + +

The modalias entries for a given Linux machine can be found using +this shell script:

+ +
+find /sys -name modalias -print0 | xargs -0 cat | sort -u
+
+ +

The supported modalias globs for a given kernel module can be found +using modinfo:

+ +
+% /sbin/modinfo psmouse | grep alias:
+alias:          serio:ty05pr*id*ex*
+alias:          serio:ty01pr*id*ex*
+%
+
+ +

PCI subtype

+ +

A typical PCI entry can look like this. This is an Intel Host +Bridge memory controller:

+ +

+pci:v00008086d00002770sv00001028sd000001ADbc06sc00i00 +

+ +

This represent these values:

+ +
+ v   00008086  (vendor)
+ d   00002770  (device)
+ sv  00001028  (subvendor)
+ sd  000001AD  (subdevice)
+ bc  06        (bus class)
+ sc  00        (bus subclass)
+ i   00        (interface)
+
+ +

The vendor/device values are the same values outputted from 'lspci +-n' as 8086:2770. The bus class/subclass is also shown by lspci as +0600. The 0600 class is a host bridge. Other useful bus values are +0300 (VGA compatible card) and 0200 (Ethernet controller).

+ +

Not sure how to figure out the interface value, nor what it +means.

+ +

USB subtype

+ +

Some typical USB entries can look like this. This is an internal +USB hub in a laptop:

+ +

+usb:v1D6Bp0001d0206dc09dsc00dp00ic09isc00ip00 +

+ +

Here is the values included in this alias:

+ +
+ v    1D6B  (device vendor)
+ p    0001  (device product)
+ d    0206  (bcddevice)
+ dc     09  (device class)
+ dsc    00  (device subclass)
+ dp     00  (device protocol)
+ ic     09  (interface class)
+ isc    00  (interface subclass)
+ ip     00  (interface protocol)
+
+ +

The 0900 device class/subclass means hub. Some times the relevant +class is in the interface class section. For a simple USB web camera, +these alias entries show up:

+ +

+usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc01ip00 +
usb:v0AC8p3420d5000dcEFdsc02dp01ic01isc02ip00 +
usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc01ip00 +
usb:v0AC8p3420d5000dcEFdsc02dp01ic0Eisc02ip00 +

+ +

Interface class 0E01 is video control, 0E02 is video streaming (aka +camera), 0101 is audio control device and 0102 is audio streaming (aka +microphone). Thus this is a camera with microphone included.

+ +

ACPI subtype

+ +

The ACPI type is used for several non-PCI/USB stuff. This is an IR +receiver in a Thinkpad X40:

+ +

+acpi:IBM0071:PNP0511: +

+ +

The values between the colons are IDs.

+ +

DMI subtype

+ +

The DMI table contain lots of information about the computer case +and model. This is an entry for a IBM Thinkpad X40, fetched from +/sys/devices/virtual/dmi/id/modalias:

+ +

+dmi:bvnIBM:bvr1UETB6WW(1.66):bd06/15/2005:svnIBM:pn2371H4G:pvrThinkPadX40:rvnIBM:rn2371H4G:rvrNotAvailable:cvnIBM:ct10:cvrNotAvailable: +

+ +

The values present are

+ +
+ bvn  IBM            (BIOS vendor)
+ bvr  1UETB6WW(1.66) (BIOS version)
+ bd   06/15/2005     (BIOS date)
+ svn  IBM            (system vendor)
+ pn   2371H4G        (product name)
+ pvr  ThinkPadX40    (product version)
+ rvn  IBM            (board vendor)
+ rn   2371H4G        (board name)
+ rvr  NotAvailable   (board version)
+ cvn  IBM            (chassis vendor)
+ ct   10             (chassis type)
+ cvr  NotAvailable   (chassis version)
+
+ +

The chassis type 10 is Notebook. Other interesting values can be +found in the dmidecode source:

+ +
+  3 Desktop
+  4 Low Profile Desktop
+  5 Pizza Box
+  6 Mini Tower
+  7 Tower
+  8 Portable
+  9 Laptop
+ 10 Notebook
+ 11 Hand Held
+ 12 Docking Station
+ 13 All In One
+ 14 Sub Notebook
+ 15 Space-saving
+ 16 Lunch Box
+ 17 Main Server Chassis
+ 18 Expansion Chassis
+ 19 Sub Chassis
+ 20 Bus Expansion Chassis
+ 21 Peripheral Chassis
+ 22 RAID Chassis
+ 23 Rack Mount Chassis
+ 24 Sealed-case PC
+ 25 Multi-system
+ 26 CompactPCI
+ 27 AdvancedTCA
+ 28 Blade
+ 29 Blade Enclosing
+
+ +

The chassis type values are not always accurately set in the DMI +table. For example my home server is a tower, but the DMI modalias +claim it is a desktop.

+ +

SerIO subtype

+ +

This type is used for PS/2 mouse plugs. One example is from my +test machine:

+ +

+serio:ty01pr00id00ex00 +

+ +

The values present are

+ +
+  ty  01  (type)
+  pr  00  (prototype)
+  id  00  (id)
+  ex  00  (extra)
+
+ +

This type is supported by the psmouse driver. I am not sure what +the valid values are.

+ +

Other subtypes

+ +

There are heaps of other modalias subtypes according to +file2alias.c. There is the rest of the list from that source: amba, +ap, bcma, ccw, css, eisa, hid, i2c, ieee1394, input, ipack, isapnp, +mdio, of, parisc, pcmcia, platform, scsi, sdio, spi, ssb, vio, virtio, +vmbus, x86cpu and zorro. I did not spend time documenting all of +these, as they do not seem relevant for my intended use with mapping +hardware to packages when new stuff is inserted during run time.

+ +

Looking up kernel modules using modalias values

+ +

To check which kernel modules provide support for a given modalias, +one can use the following shell script:

+ +
+  for id in $(find /sys -name modalias -print0 | xargs -0 cat | sort -u); do \
+    echo "$id" ; \
+    /sbin/modprobe --show-depends "$id"|sed 's/^/  /' ; \
+  done
+
+ +

The output can look like this (only the first few entries as the +list is very long on my test machine):

+ +
+  acpi:ACPI0003:
+    insmod /lib/modules/2.6.32-5-686/kernel/drivers/acpi/ac.ko 
+  acpi:device:
+  FATAL: Module acpi:device: not found.
+  acpi:IBM0068:
+    insmod /lib/modules/2.6.32-5-686/kernel/drivers/char/nvram.ko 
+    insmod /lib/modules/2.6.32-5-686/kernel/drivers/leds/led-class.ko 
+    insmod /lib/modules/2.6.32-5-686/kernel/net/rfkill/rfkill.ko 
+    insmod /lib/modules/2.6.32-5-686/kernel/drivers/platform/x86/thinkpad_acpi.ko 
+  acpi:IBM0071:PNP0511:
+    insmod /lib/modules/2.6.32-5-686/kernel/lib/crc-ccitt.ko 
+    insmod /lib/modules/2.6.32-5-686/kernel/net/irda/irda.ko 
+    insmod /lib/modules/2.6.32-5-686/kernel/drivers/net/irda/nsc-ircc.ko 
+  [...]
+
+ +

If you want to help implementing a system to let us propose what +packages to install when new hardware is plugged into a Debian +machine, please send me an email or talk to me on +#debian-devel.

+ +

Update 2013-01-15: Rewrite "cat $(find ...)" to +"find ... -print0 | xargs -0 cat" to make sure it handle directories +in /sys/ with space in them.

+ +
+
+ + + Tags: debian, english. + + +
+
+
+ +
+
+ Moved the pymissile Debian packaging to collab-maint +
+
+ 10th January 2013 +
+
+

As part of my investigation on how to improve the support in Debian +for hardware dongles, I dug up my old Mark and Spencer USB Rocket +Launcher and updated the Debian package +pymissile to make +sure udev will fix the device permissions when it is plugged in. I +also added a "Modaliases" header to test it in the Debian archive and +hopefully make the package be proposed by jockey in Ubuntu when a user +plug in his rocket launcher. In the process I moved the source to a +git repository under collab-maint, to make it easier for any DD to +contribute. Upstream +is not very active, but the software still work for me even after five +years of relative silence. The new git repository is not listed in +the uploaded package yet, because I want to test the other changes a +bit more before I upload the new version. If you want to check out +the new version with a .desktop file included, visit the +gitweb +view or use "git clone +git://anonscm.debian.org/collab-maint/pymissile.git".

+ +
+
+ + + Tags: debian, english, robot. + + +
+
+
+
Lets make hardware dongles easier to use in Debian @@ -282,7 +713,7 @@ siste måneden.

  • 2013
  • @@ -432,7 +863,7 @@ siste mÃ¥neden.

  • bsa (2)
  • -
  • debian (61)
  • +
  • debian (64)
  • debian edu (118)
  • @@ -442,7 +873,7 @@ siste mÃ¥neden.

  • drivstoffpriser (4)
  • -
  • english (167)
  • +
  • english (170)
  • fiksgatami (21)
  • @@ -482,7 +913,7 @@ siste mÃ¥neden.

  • rfid (2)
  • -
  • robot (5)
  • +
  • robot (6)
  • rss (1)