3 Usage and features

Contents of this section

3.1 How do I tell if it is working?

The cardmgr daemon normally beeps when a card is inserted, and the tone of the beeps indicates the status of the newly inserted card. Two high beeps indicate the card was identified and configured successfully. A high beep followed by a lower beep indicates that the card was identified, but could not be configured for some reason. One low beep indicates that the card could not be identified.

If you are running X, the new cardinfo utility produces a slick graphical display showing the current status of all PCMCIA sockets.

If the modules are all loaded correctly, the output of the lsmod command should look like the following, with no cards inserted:

Module:        #pages:  Used by:
ds                 2
i82365             2
pcmcia_core        6    [ds i82365]

All the PCMCIA modules and the cardmgr daemon send status messages to the system log. This will usually be /usr/adm/messages. This file should be the first place to look when tracking down a problem. When submitting a bug report, always include the contents of this file. Cardmgr also records some current device information for each socket in /etc/stab.

You can also submit bug reports via the WWW: see http://hyper.stanford.edu/~dhinds/pcmcia/pcmcia.html for details.

3.2 How do I use my PCMCIA ethernet card?

Linux ethernet-type network interfaces normally have names like eth0, eth1, and so on. The ifconfig command is used to view or modify the state of a network interface. A peculiarity of Linux is that network interfaces do not have corresponding device files under /dev, so don't be surprised when you can't find them.

When a PCMCIA ethernet card is detected, it will be assigned the first free interface name, which will probably be eth0. Cardmgr will run the /etc/pcmcia/network script to configure the interface, which should be customized for your local network setup.

Do not configure your PCMCIA ethernet card in /etc/rc.d/rc.inet1, since the card may not be present when this script is executed. Comment out everything except the loopback stuff in rc.inet1 and instead edit the /etc/pcmcia/network script to match your local network setup. This script will be executed only when your ethernet card is actually present.

3.3 How do I use my PCMCIA modem card?

Linux serial devices are accessed via the /dev/cua* and /dev/ttyS* special device files. The ttyS* devices are for incoming connections, such as directly connected terminals. The cua* devices are for outgoing connections, such as modems. The configuration of a serial device can be examined and modified with the setserial command.

When a PCMCIA serial or modem card is detected, it will be assigned to the first available serial device slot. This will usually be /dev/cua1 or /dev/cua2, depending on the number of built-in serial ports. The default serial device script, /etc/pcmcia/serial, will link the appropriate device file to /dev/modem as a convenience.

If you are using more than one PCMCIA modem, use /etc/stab or cardinfo to find out which device corresponds to each modem.

Do not try to use /etc/rc.d/rc.serial to configure a PCMCIA modem. This script should only be used to configure non-removable devices. Modify /etc/pcmcia/serial if you want to do anything special to set up your modem.

If a PCMCIA modem is already configured when Linux boots, it may be incorrectly identified as an ordinary built-in serial port. This is harmless, however, when the PCMCIA drivers take control of the modem, it will be assigned a different device slot. It is best to either parse /etc/stab or use /dev/modem, rather than expecting a PCMCIA modem to always have the same device assignment.

3.4 How do I use my PCMCIA SCSI card?

The Qlogic FastSCSI, New Media Bus Toaster, and Adaptec APA-1460 SlimSCSI cards work under Card Services. The PCMCIA driver modules for these cards are built by linking some PCMCIA-specific code (in qlogic_cs.c and toaster_cs.c) with a normal Linux SCSI driver. The Qlogic PCMCIA driver links with the normal QLogic driver. The Bus Toaster PCMCIA driver, which also supports the Adaptec SlimSCSI, links with the Adaptec 152x driver. It is important to use a 1.2.8 or later kernel if you will be using a SCSI adapter, because there have been important changes to the low-level drivers in recent releases.

The Adaptec APA-460 SlimSCSI adapter is not supported. This card was originally sold under the Trantor name, and when Adaptec merged with Trantor, they continued to sell the Trantor card with an Adaptec label. The APA-460 is not compatible with any existing Linux driver. I'm not sure how hard it would be to write a driver; I don't think anyone has been able to obtain the technical information from Adaptec.

The Trantor SlimSCSI can be identified by the following:

Trantor / Adaptec APA-460 SlimSCSI FCC ID: IE8T460 Shipped with SCSIworks! driver software

The Adaptec SlimSCSI can be identified by the following:

Adaptec APA-1460 SlimSCSI FCC ID: FGT1460 P/N: 900100 Shipped with EZ-SCSI driver software

Always turn on SCSI devices before powering up your laptop, or before inserting the adapter card, so that the SCSI bus is properly terminated when the adapter is configured.

When a new SCSI host adapter is detected, the SCSI drivers will probe for devices. Check /usr/adm/messages to make sure your devices are detected properly. New SCSI devices will be assigned to the first available SCSI device files. The first SCSI disk will be /dev/sda, the first SCSI tape will be /dev/st0, and the first CDROM will be /dev/scd0.

Be very careful about ejecting a SCSI adapter. Be sure that all associated SCSI devices are unmounted and closed before ejecting the card. For now, all SCSI devices should be powered up before plugging in a SCSI adapter, and should stay connected until after you unplug the adapter and/or power down your laptop.

Roger Pao (rpao@paonet.org) adds:

Make sure there is a device capable of supplying termination power both to the terminating target device and to the PCMCIA SCSI card. This is vitally important as most PCMCIA SCSI cards do not supply termination power to the SCSI bus. This is usually to save laptop battery power and to isolate the laptop from the SCSI bus.

For a recommendation, the APS SCSI Sentry 2 ($100) is an external Centronics active terminator block (male on one end, female on the other) which uses an external power supply (115/230VAC) to supply termination power (5VDC 2.0A) to its own active terminator and to the PCMCIA SCSI card's terminators (be it active or passive). For more details, APS Technical Support can be reached at 800-334-7550.

3.5 How do I use my PCMCIA memory card?

The default memory card startup script will create block and character devices for accessing a card's first common memory and attribute memory regions. Check the man pages for all the details, but the devices you'll probably be using will be /dev/mem0c (character device) or /dev/mem0b (block device). The block device is used for disk-like access (creating and mounting filesystems, etc). The character device is for "raw" reads and writes at arbitrary locations.

To use a flash memory card as an ordinary disk-like block device, first create a ``flash translation layer'' partition on the device with the ftl_format command:

ftl_format -i /dev/mem0c

Note that this command accesses the card through the ``raw'' memory card interface. Once formatted, the card can be accessed as an ordinary block device via the ftl_cs driver. For example:

mke2fs /dev/ftl0
mount -t ext2 /dev/ftl0 /mnt

3.6 How do I tell cardmgr how to identify a new card?

Assuming that your card is supported by an existing driver, all that needs to be done is to add an entry to /etc/pcmcia/config to tell cardmgr how to identify the card, and which driver(s) need to be linked up to this card. Check the man page for pcmcia for more information about the config file format. If you insert an unknown card, cardmgr will normally record some identification information in /usr/adm/messages that can be used to construct the config entry.

Here is an example of how cardmgr will report an unsupported card in /usr/adm/messages.

cardmgr[460]: unsupported card in socket 1
cardmgr[460]: version info: "MEGAHERTZ", "XJ2288", "V.34 PCMCIA MODEM"

The corresponding entry in /etc/pcmcia/config would be:

card "Megahertz XJ2288 V.34 Fax Modem"
  version "MEGAHERTZ", "XJ2288", "V.34 PCMCIA MODEM"
  bind "serial_cs"

You can use ``*'' to match strings that don't need to match exactly, like version numbers. When making new config entries, be careful to copy the strings exactly, preserving case and blank spaces. Also be sure that the config entry has the same number of strings as are reported in the log file.

After editing /etc/pcmcia/config, you can signal cardmgr to reload the file with:

kill -HUP `cat /var/run/cardmgr.pid`

If you do set up an entry for a new card, please send me a copy so that I can include it in the standard config file.

3.7 How do I control which interrupts and ports are used by a device?

In theory, it should not really matter which interrupt is allocated to which device, as long as two devices are not configured to use the same interrupt. At the top of /etc/pcmcia/config you'll find a place for excluding interrupts that are used by non-PCMCIA devices.

All the client card drivers have a parameter called irq_mask for specifying which interrupts they may try to allocate. Each bit of irq_mask corresponds to one irq line: bit 0 is irq 0, bit 1 is irq 1, and so on. So, a mask of 0x1200 would correspond to irq 9 and irq 12. To limit a driver to use only one specific interrupt, its irq_mask should have only one bit set. These driver options should be set in your /etc/pcmcia/config file. For example:

device "serial_cs"
  module "serial_cs" opts "irq_mask=0x1100"
  ...

would specify that the serial driver should only use irq 8 or irq 12. Note that Card Services will never allocate an interrupt that is already in use by another device, or an interrupt that is excluded in the config file.

There is no way to directly specify the I/O addresses for a PCMCIA card to use. The /etc/pcmcia/config file allows you to specify ranges of ports available for use by all PCMCIA devices.

After modifying /etc/pcmcia/config, you can restart cardmgr with ``kill -HUP''.

3.8 When is it safe to insert or eject a PCMCIA card?

In theory, you can insert and remove PCMCIA cards at any time. However, it is a good idea not to eject a card that is currently being used by an application program. Kernels older than 1.1.77 would often lock up when serial/modem cards were ejected, but this should be fixed now.

3.9 How do I unload PCMCIA drivers?

To unload the entire PCMCIA package, invoke rc.pcmcia with:

/etc/rc.d/rc.pcmcia stop

This script will take several seconds to run, to give all client drivers time to shut down gracefully. If a PCMCIA device is currently in use, the shutdown will fail.

3.10 How does Card Services deal with suspend/resume?

Card Services can be compiled with support for APM (Advanced Power Management) if you've installed this package on your system. The current release of Stephen Rothwell's APM support package is version 0.5. Unlike the 0.4 release, 0.5 does not require a special patch to work with PCMCIA. The PCMCIA modules will automatically be configured for APM if a compatible version is detected on your system.

Without resorting to APM, you can do ``cardctl suspend'' before suspending your laptop, and ``cardctl resume'' after resuming, to properly shut down and restart your PCMCIA cards. This will not work with a PCMCIA modem that is in use, because the serial driver isn't able to save and restore the modem operating parameters.

APM seems to be unstable on some systems. If you experience trouble with APM and PCMCIA on your system, try to narrow down the problem to one package or the other before reporting a bug.

3.11 How do I turn off a PCMCIA card without ejecting it?

Use either the cardctl or cardinfo command. ``cardctl suspend #'' will suspend one socket, and turn off its power. The corresponding resume command will wake up the card in its previous state.

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter