Plug-and-Play Hardware
August 1st, 1999 by David Cantrell in
Chances are, you or someone you know has had to deal with plug-and-play (PnP) hardware. These devices are just like “legacy” devices, except they have no jumpers to configure the resources (i.e., IRQs, DMAs and I/O addresses). PnP cards expect the computer, either the BIOS or the operating system, to find and configure the card. It's an excellent idea, but why?
Most Linux users enjoy configuring their computers—getting their hands dirty working with the hardware. On the other side of the coin is the user who expects his computer to turn on in the morning and be ready for him to complete his work without intervention by him. This type of user will also add hardware to his computer, but does not want to spend time finding free resources and setting them. PnP hardware is ideal for him.
This user can purchase a plug-and-play device, put it in his computer, and the configuration is done automatically. This idea of automatic configuration was designed into the PCI bus, the newer of the common busses. Unfortunately, most users still rely on the standard architecture defined by the industry; that is, the ISA bus. It works well, but still has its limitations. Most notably, plug-and-play was not considered when ISA was designed.
The designers of the plug-and-play standard decided to extend plug-and-play to ISA devices. Wouldn't it be nice to have some sort of detection and configuration scheme to find these devices and set them up for the user? Think how easy computers would be! So, the designers set up a scheme to find ISA cards and configure them to the jumpered resources on the card. Hardware vendors loved the idea and decided to cooperate by suggesting the removal of all the jumpers.
Now we have a fully functional plug-and-play system for the ISA bus, right? Well, not exactly. It still has a way to go before it is all the way out the door. PCI architecture will take over in the next few years before plug-and-play ISA works without any problems. For now, we have to work with these plug-and-play ISA devices while mourning the loss of our beloved jumpers.
PnP ISA devices can be used in several ways under Linux. The kernel can find and configure them before loading any other drivers. This method sometimes fails to find all devices and to initialize the devices. It also requires patching the kernel with one of the PnP add-ons.
Another way, which I recommend, is to use an initialization program at the user level. You create a configuration file with your devices and specify the resources each device is to use. Then, this file is read by an initialization utility that configures the devices. However, this method does require the drivers for these devices to be compiled as kernel modules.
I have tried a couple of these user-level configuration programs, and the one I have found to be the easiest and most reliable is the isapnptools package. This program is designed to work on systems with or without a PnP-compatible BIOS. It will not interfere with “legacy” ISA devices either (devices with jumpers); at least, I have not had that problem.
As an example, I will configure a PnP sound card and load the driver for it. I will assume you can install the card and you have a working knowledge of Linux. Here's a basic overview of the setup process:
getting the isapnptools package
dumping all possible values
choosing your resources
testing the configuration
compiling the kernel driver
enabling the device at bootup
Most of the latest Linux distributions come with the isapnptools package. However, you may want to grab the latest version from the isapnptools web page, http://www.roestock.demon.co.uk/isapnptools/. At the time of this writing, the latest version is 1.17.
After downloading the file, extract the contents and compile it. Some systems may require editing the Makefile. Check the included INSTALL file for more information. As root, I used the following commands to compile and install the package:
tar xvzf isapnptools-1.17.tar.gz cd isapnptools-1.17 make make install (as root)
The installation will create the isapnp and pnpdump programs along with their accompanying man pages and sample configuration file.
After you've compiled and installed isapnptools, it is time to configure your devices. This is done by creating a configuration file explaining the device(s) and which resources it will use. The great thing about isapnptools is that it will build this file for you. Then you go in and play “multiple choice” (as the author puts it).
To create the configuration file, run the pnpdump program. It scans for all ISA plug-and-play devices and all possible configurations. These values are dumped to standard out (STDOUT) in the file format needed. Here is the command I use to create the file as root:
/sbin/pnpdump > /etc/isapnp.conf
Listing 1. Confuguration File Start
The program failed on me a few times, but that was mainly due to other system errors. You should now have a configuration file in /etc if you used my command. The beginning of the file should look something like Listing 1. The rest of the configuration file will contain sections for the different devices it found. Now you need to choose which resources the device will use.
The configuration file may seem a bit confusing at first, but it needs only a little deciphering. The basic layout for a device section is shown in Listing 2. By default, a listing of all possible resources for that device will be within the device section. Basically, just uncomment the lines for the resources the device will use. The lines are commented with # marks.
Editing this file requires knowing a bit about the device to be configured. Typically, the user manual for the device will list which resources are required to use the device. In my case, with the Sound Blaster AWE32, I needed a Base I/O address, one IRQ, an 8-bit DMA channel, a 16-bit DMA channel and a MIDI synthesizer I/O address. Other resources are on my card, but I am not using them in this example.
The example device section in Listing 2 shows the resources I chose for my card. I chose 0x0220 for the Base I/O address, 5 for the IRQ channel, 1 for the 8-bit DMA channel, 5 for the 16-bit DMA channel and 0x0330 for the MIDI I/O.
Note that the I/O addresses are called IO 0 and IO 1, and the DMA channels are called DMA 0 and DMA 1. This may make it a little difficult to map the right values to the 8-bit DMA and 16-bit DMA. However, if you read your configuration file after running pnpdump and look at the default resource settings in the user manual for your device, you can easily match things up.
In my case, I know DMA 0 corresponds to the 8-bit DMA because only the 8-bit DMA can have a value of 1. So, the other setting must be the 16-bit DMA channel. The same goes for the IO settings; IO 0 must be the Base I/O address, because the MIDI I/O address can never be 0x0220.
Once you have uncommented the lines you need, make sure the (ACT Y) line is uncommented; otherwise, your device will not be configured.
You have now passed the hard part of PnP configuration under Linux. It is a good idea to test your PnP configuration before going any further. You want to make sure isapnp can properly initialize the card with the resources you have set. Assuming isapnp is in /sbin, execute this command to test your configuration:
/sbin/isapnp /etc/isapnp.conf
If there are no error messages, your configuration should work fine. If you do get resource conflict errors, now would be a good time to go back and edit that configuration file. It is better to get it working now than have to fool with it later. Play around with the resource settings until you find those that don't produce errors when you test the configuration.
Now we are ready for the fun part. Most Linux distributions will come with the various device drivers compiled as modules. Refer to the kernel documentation for more information about modules. Basically, a module is just a device driver that can be added to an already-running kernel. This provides a lot of flexibility for the user, and it is modules that allow us to use PnP devices.
PnP devices must be initialized before the driver can be loaded, so using modules is a necessity. They are the only part of the kernel that can be loaded after the kernel boots.
Your distribution may already include a module for the device you want to use. In the case of sound cards, you might be compiling one from scratch. In my example, I use a Sound Blaster AWE32. The device driver included with my distribution is /lib/modules/2.0.35/misc/sound.o.
If you must recompile, be sure to set any resources for the driver according to those set in the isapnp.conf file. You can always pass the resource values when loading the module, but having the default ones is always nice.
To load the driver for my PnP sound card, I did this:
/sbin/isapnp /etc/isapnp.conf /sbin/modprobe sound.o io=0x0220 irq=5 dma=1\ dma1=5
If all goes well, you should have a driver loaded and working with that device. Check to make sure the module is loaded by typing:
/sbin/lsmodIf this is a sound card, try playing sound files. For network cards, try bringing up the device with ifconfig. At this point the device should be working.
Now that you have your PnP card working under Linux, wouldn't it be great if those devices were set up automatically at boot time? I added the above two lines to my /etc/rc.d/rc.local file, so that my sound driver is loaded each time I boot the system.
This example used what I view as the most common plug-and-play situation when using Linux—a sound card. Other PnP devices exist, such as modems and network cards. The same technique can be applied to those cards as well.
Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer
Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.
Subscribe now!
The Latest
Newsletter
Tech Tip Videos
- Jul-01-09
- Jun-29-09
Recently Popular
From the Magazine
July 2009, #183
News Flash: Linux Kernel 3.0 to include an on-the-go Expresso machine interface! Ok, maybe not, but Linux is definitely going mobile, from phones to e-readers. Find out more inside about Android, the Kindle 2, the Western Digital MyBook II, The Bug, and Indamixx (a portable recording studio). And if you've gone mobile and you been wanting more Emacs in your life then check out Conkeror.
To compliment the mobile we've got the stationary: parsing command line options with getopt, checking your Ruby code with metric_fu, and building a secure Squid proxy. How is this stationary you ask? What can we say? It's not. We just wanted to see if anybody actually read this part of the page :) .
All this and more, and all you have to do is get your hot sweaty hands on the latest copy of Linux Journal.

Delicious
Digg
StumbleUpon
Reddit
Facebook








Hi, friend I appreciate your
On March 2nd, 2009 Vajinder Dutt (not verified) says:
Hi, friend
I appreciate your contribution
I'm using Ubuntu Intrepid Ibex. Everything is good except sound. My sound card is Crystal CS 4235. I hear drum sound only at the login screen. There after no sound. Volume control carries a red mark when I click it it reads :"No volume control GStreamer plugins and/or devices found"
$aplay -l output is:
aplay: device_list:215: no soundcards found...
----------------------------------------------------------------------
My isapnp.conf file shows:
# $Id: pnpdump_main.c,v 1.27 2001/04/30 21:54:53 fox Exp $
# Release isapnptools-1.27
#
# This is free software, see the sources for details.
# This software has NO WARRANTY, use at your OWN RISK
#
# For details of the output file format, see isapnp.conf(5)
#
# For latest information and FAQ on isapnp and pnpdump see:
# http://www.roestock.demon.co.uk/isapnptools/
#
# Compiler flags: -DREALTIME -DHAVE_PROC -DENABLE_PCI -DHAVE_SCHED_SETSCHEDULER -DHAVE_NANOSLEEP -DWANT_TO_VALIDATE
#
# Trying port address 0273
# Board 1 has serial identifier a9 ff ff ff ff 36 42 63 0e
# (DEBUG)
(READPORT 0x0273)
(ISOLATE PRESERVE)
(IDENTIFY *)
(VERBOSITY 2)
(CONFLICT (IO FATAL)(IRQ FATAL)(DMA FATAL)(MEM FATAL)) # or WARNING
# Card 1: (serial identifier a9 ff ff ff ff 36 42 63 0e)
# Vendor Id CSC4236, No Serial Number (-1), checksum 0xA9.
# Version 1.0, Vendor version 0.5
# ANSI string -->Crystal Codec<--
#
# Logical device id CSC0000
# Device supports vendor reserved register @ 0x38
# Device supports vendor reserved register @ 0x3c
# Device supports vendor reserved register @ 0x3e
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy
(CONFIGURE CSC4236/-1 (LD 0
# ANSI string -->WSS/SB<--
# Multiple choice time, choose one only !
# Start dependent functions: priority preferred
# First DMA channel 1.
# 8 bit DMA only
# Logical device is not a bus master
# DMA may execute in count by byte mode
# DMA may not execute in count by word mode
# DMA channel speed type A
# (DMA 0 (CHANNEL 1))
# Next DMA channel 0 or 3.
# 8 bit DMA only
# Logical device is a bus master
# DMA may execute in count by byte mode
# DMA may not execute in count by word mode
# DMA channel speed type A
# (DMA 1 (CHANNEL 0))
# IRQ 5.
# High true, edge sensitive interrupt (by default)
# (INT 0 (IRQ 5 (MODE +E)))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0534
# Maximum IO base address 0x0534
# IO base alignment 4 bytes
# Number of IO addresses required: 4
# (IO 0 (SIZE 4) (BASE 0x0534))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0388
# Maximum IO base address 0x0388
# IO base alignment 8 bytes
# Number of IO addresses required: 4
# (IO 1 (SIZE 4) (BASE 0x0388))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0220
# Maximum IO base address 0x0220
# IO base alignment 32 bytes
# Number of IO addresses required: 16
# (IO 2 (SIZE 16) (BASE 0x0220))
# Start dependent functions: priority acceptable
# First DMA channel 1 or 3.
# 8 bit DMA only
# Logical device is not a bus master
# DMA may execute in count by byte mode
# DMA may not execute in count by word mode
# DMA channel speed type A
# (DMA 0 (CHANNEL 1))
# Next DMA channel 0, 1 or 3.
# 8 bit DMA only
# Logical device is not a bus master
# DMA may execute in count by byte mode
# DMA may not execute in count by word mode
# DMA channel speed type A
# (DMA 1 (CHANNEL 0))
# IRQ 5, 7, 9, 11, 12 or 15.
# High true, edge sensitive interrupt (by default)
# (INT 0 (IRQ 5 (MODE +E)))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0534
# Maximum IO base address 0x0ffc
# IO base alignment 4 bytes
# Number of IO addresses required: 4
# (IO 0 (SIZE 4) (BASE 0x0534))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0388
# Maximum IO base address 0x0388
# IO base alignment 8 bytes
# Number of IO addresses required: 4
# (IO 1 (SIZE 4) (BASE 0x0388))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0220
# Maximum IO base address 0x0260
# IO base alignment 32 bytes
# Number of IO addresses required: 16
#(IO 2 (SIZE 16) (BASE 0x0220))
# Start dependent functions: priority functional
# First DMA channel 0, 1 or 3.
# 8 bit DMA only
# Logical device is a bus master
# DMA may execute in count by byte mode
# DMA may not execute in count by word mode
# DMA channel speed type A
# (DMA 0 (CHANNEL 0))
# IRQ 5, 7, 9, 11, 12 or 15.
# High true, edge sensitive interrupt (by default)
# (INT 0 (IRQ 5 (MODE +E)))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0534
# Maximum IO base address 0x0ffc
# IO base alignment 4 bytes
# Number of IO addresses required: 4
# (IO 0 (SIZE 4) (BASE 0x0534))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0388
# Maximum IO base address 0x03f8
# IO base alignment 8 bytes
# Number of IO addresses required: 4
# (IO 1 (SIZE 4) (BASE 0x0388))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0220
# Maximum IO base address 0x0300
# IO base alignment 32 bytes
# Number of IO addresses required: 16
# (IO 2 (SIZE 16) (BASE 0x0220))
# End dependent functions
(NAME "CSC4236/-1[0]{WSS/SB }")
# (ACT Y)
))
#
# Logical device id CSC0001
# Device supports vendor reserved register @ 0x39
# Device supports vendor reserved register @ 0x3c
# Device supports vendor reserved register @ 0x3e
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy
(CONFIGURE CSC4236/-1 (LD 1
# ANSI string -->GAME<--
# Multiple choice time, choose one only !
# Start dependent functions: priority preferred
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0200
# Maximum IO base address 0x0200
# IO base alignment 8 bytes
# Number of IO addresses required: 8
# (IO 0 (SIZE 8) (BASE 0x0200))
# Start dependent functions: priority acceptable
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0208
# Maximum IO base address 0x0208
# IO base alignment 8 bytes
# Number of IO addresses required: 8
# (IO 0 (SIZE 8) (BASE 0x0208))
# End dependent functions
(NAME "CSC4236/-1[1]{GAME }")
# (ACT Y)
))
#
# Logical device id CSC0010
# Device supports vendor reserved register @ 0x38
# Device supports vendor reserved register @ 0x3c
# Device supports vendor reserved register @ 0x3e
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy
(CONFIGURE CSC4236/-1 (LD 2
# ANSI string -->CTRL<--
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0120
# Maximum IO base address 0x0ff8
# IO base alignment 8 bytes
# Number of IO addresses required: 8
# (IO 0 (SIZE 8) (BASE 0x0120))
(NAME "CSC4236/-1[2]{CTRL }")
# (ACT Y)
))
#
# Logical device id CSC0003
# Device supports vendor reserved register @ 0x38
# Device supports vendor reserved register @ 0x3c
# Device supports vendor reserved register @ 0x3e
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy
(CONFIGURE CSC4236/-1 (LD 3
# ANSI string -->MPU<--
# Multiple choice time, choose one only !
# Start dependent functions: priority preferred
# IRQ 9.
# High true, edge sensitive interrupt (by default)
# (INT 0 (IRQ 9 (MODE +E)))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0330
# Maximum IO base address 0x0330
# IO base alignment 8 bytes
# Number of IO addresses required: 2
# (IO 0 (SIZE 2) (BASE 0x0330))
# Start dependent functions: priority acceptable
# IRQ 9, 11, 12 or 15.
# High true, edge sensitive interrupt (by default)
# (INT 0 (IRQ 9 (MODE +E)))
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0330
# Maximum IO base address 0x0360
# IO base alignment 8 bytes
# Number of IO addresses required: 2
# (IO 0 (SIZE 2) (BASE 0x0330))
# Start dependent functions: priority functional
# Logical device decodes 16 bit IO address lines
# Minimum IO base address 0x0330
# Maximum IO base address 0x03e0
# IO base alignment 8 bytes
# Number of IO addresses required: 2
# (IO 0 (SIZE 2) (BASE 0x0330))
# End dependent functions
(NAME "CSC4236/-1[3]{MPU }")
# (ACT Y)
))
# End tag... Checksum 0x00 (OK)
# Returns all cards to the "Wait for Key" state
(WAITFORKEY)
----------------------------------------------------------------------
And my lspnp -v output is:
01:01.00 CSC0000 Crystal PnP audio system CODEC
state = active
dma 1
dma 3
irq 5
io 0x534-0x537
io 0x388-0x38b
io 0x220-0x22f
01:01.01 CSC0001 Crystal PnP audio system joystick
state = disabled
01:01.02 CSC0010 Crystal PnP audio system control registers
state = active
io 0x120-0x127
01:01.03 CSC0003 Crystal PnP audio system MPU-401 compatible
state = active
io 0x330-0x331
--------------------------------------------------------------------
I don't know what to do with isapnp.conf file. Which lines are to be uncommented?
Re: Strictly On-Line: Plug-and-Play Hardware
On March 15th, 2002 Anonymous says:
Thank you for a plain easy explanation that a newbie can understand!!
Re: Strictly On-Line: Plug-and-Play Hardware
On January 4th, 2003 Anonymous says:
Your explanation is very good. However, when I do the command "modprobe sb.o io=0x220 irq=5 dma=1" it always tells me "Can't locate module sb.o". It tells me that even if I specify another module, such as sound.o or whatever. I check whether the module is installed or not, and it's actually installed!!! But it says it's not there!!! What can I do?? Please e-mail me if you can help me, thank you. noviembrexx@hotmail.com
Re: Strictly On-Line: Plug-and-Play Hardware
On March 16th, 2003 Anonymous says:
don't use the ".o" with modprobe -- just the module name
modprobe sb ...
bv
Re: Strictly On-Line: Plug-and-Play Hardware
On July 29th, 2003 Anonymous says:
I've got another problem:
"this module has no such paramter - IRQ"
"this module has no such paramter - DMA"
"this module has no such paramter - DMA1"
:((
Post new comment