Monthly Columns
 

Getting Your PC Card to Work

Copyright © Annelise Anderson

Published here with agreement of Daemon News

Getting FreeBSD to recognize and run the pccards on your laptop isn't easy, butit can be systematically approached. FreeBSD includes considerable support for pccards, and recently what's called PAO has been included in FreeBSD as a branch. PAO has some features and supports some cards not included in the standard FreeBSD branches. Whether or not you choose to install PAO depends on how much you need the hardware support it provides. There are now PAO boot floppies that may make it possible to install FreeBSD by ethernet.

My own choice has been to install -current on laptops, becausethe support for new hardware (e.g., cardbus and usb devices) is likely to be developed there and only later be merged back into the -stable branch.

There are three manual pages on PC cards: pccardd, pccardc, and pccard.conf.

Another resource is the PAO page. This page lists a great many cards that people have used successfully. Some ofthe drivers for the cards are only included in PAO, so you want to be careful when using this as a shopping list.

Here are the tasks to get your PC cards running; they are the same whether you install PAO or not. You need to compile the necessary drivers into the kernel for all the cards you intend to use, as well as drivers for the pccard controller itself and the individual slots. You must also enter an accurate description of each card in the /etc/pccard.conf database.

Recompile your kernel, commenting out the zp and ze drivers by placing a # in front of these lines (if they are not already commented out) and including the three general lines for pccard support, one for the controller itself and two for the card slots. These can be found in the LINT kernel and also in the GENERIC and PCCARD kernels; the PCCARD kernel is simply a GENERIC kernelwith pcmcia support included. The lines currently look like this:

controller card0
device     pcic0 at card?
device     pcic1 at card?

You will also want to include the driver for the card in the kernel configuration file. The drivers for modems (sio0 and sio1) will already be there; you maywant to add sio2 and sio3. You will need to select an ethernet driver, or make sure it is included, by reading the information on the box your card came in. For example, an NE2000 compatible card uses the ed0 driver.

Edit /etc/rc.conf, so that pccard_enable="YES". If you are installing an ethernet card, you will also want to include the driver asone of the network interfaces in rc.conf.

Move or copy /etc/pccard.conf.sample to /etc/pccard.conf. This is the database of pccards to which the card will be matched when itis inserted. If there is a card with a manufacturer and name that matches your card, that will be the entry to work with. Otherwise you will have to createone.

Reboot the computer without the card in the slot and check to ensure that the ze and zp drivers are not mentioned and that the controller for the pccard is identified and given an IRQ. The two card slots will also appear.

It will look something like this, if you've included the ed0 driver:

ed0 not found at 0x280
PC-Card Cirrus Logic PD672X (5 mem & 2 I/O windows)
pcic: controller irq 5
Initializing PC-card drivers: ed sio

Insert the card in the slot and run pccardc dumpcis. This will produce an output of information from the card itself in the form of tuples. You may want to print this information out or save it to a file for future reference. Here area few lines from an ethernet card that isn't included in the data base but is NE2000 compatible (according to box) and thus uses the ed0 driver:

Configuration data for card in slot 0
Tuple #6, code = 0x15 (Version 1 info), length = 38
    Version = 4.1, Manuf = [D-Link],card vers = [DE-660]
Tuple #8, code = 0x1b (Configuration entry), length = 7
    Config index = 0x20(default)
    Interface byte = 0x81 (I/O) wait signal supported
2 slots found

Sometimes several alternatives may be available for the configuration index. From this information and examples already in the pccard.conf file,we can construct a card entry to be included in pccard.conf:

#D-LINK Ethernet PC Card DE-660
card "D-Link" "DE-660"
    config 0x20 "ed0" 10
    ether 0x81
    insert echo D-Link 660 Ethernet inserted
    insert /etc/pccard_ether ed0
    remove echo D-Link 660 Ethernet removed
    remove /sbin/ifconfig ed0 delete

Save the card entry information to pccard.conf.

Reboot without the card in the slot. If everything is right, you should get a message on the console when the card is inserted showing (for an ethernet card)its address and possibly the "echo" text. If there are errors during boot about incorrect configuration or inability to assign resources to the card, the card entry is not correct and you will need to experiment. The beginning of /etc/pccard.conf shows some resources being made available; you may need to edit these. The /etc/pccard.conf file is read when a card is inserted or removed, so that you do not need to reboot to test your changes.

If the card is correctly identified, you have a working card. You can use ed0 (in this example) as you normally would, writing ifconfig statements at the command line.

At this point you can arrange to have the network configuration take place when the card is inserted. To do this, you take advantage of the "insert" lines in pccard.conf. In the example above, the insert lines run two commands: echo and the script /etc/pccard_ether ed0. The script uses information from the pccard_ifconfig line in /etc/rc.conf and other routing information provided in rc.conf. When the card is removed, the ed0 interface is deleted. Instead of assigning fixed network parameters, you could also use DHCP to assign parameters dynamically -- one of the options for pccard_ifconfig is "DHCP".

Alternatively you may wish to boot with the card in the slot and try to get thenetwork to come up on boot. It may work just as well in that case to have theinformation in an ordinary ifconfig statement in rc.conf (and include ed0 in the list of interfaces) and leave pccard_ifconfig blank. This has worked for me with earlier FreeBSD versions but not with more recent ones.

This how-to is not intended to address every difficulty, but it should give youan overview of how the process works so that you can experiment yourself. Letme know if it works or if I've left out any information you find important.

Annelise Anderson, andrsn@andrsn.stanford.edu