# [HOWTO] PCMCIA and hotplug

## brodo

HOW TO use hotplug for managing 16-bit[*] PCMCIA cards

[*] Note: 32-bit CardBus cards have already been handled by hotplug since the 2.4. days

With the PCMCIA subsystem of the Linux kernel undergoing gradual improvement, recent changes merged into Linus' tree allow to use the default "hotplug" infrastructure to load appropriate drivers for PCMCIA devices. "cardmgr" from pcmcia-cs is no longer necessary. However, this bleeding edge feature needs to be set up properly. For additional information, also check http://kernel.org/pub/linux/utils/kernel/pcmcia/howto.html

0. Remove pcmcia-cs

As pcmcia-cs blocks pcmciautils, you need to get rid of it first:

```
rc-update del pcmcia

emerge unmerge pcmcia-cs
```

1. Kernel requirements

You need a kernel based at least on Linus' 2.6.13-rc1. If using 2.6.13-rc1, you should also apply this bugfix: http://kernel.org/pub/linux/kernel/people/brodo/patches/2.6.13-rc1/pcmcia-29-01-fix-sysfs-modalias. This patch is merged in Linus' tree by now (2.6.13-rc1-git3).

If you relied on the startup script of pcmcia-cs (/etc/init.d/pcmcia/) to load the appropriate kernel modules for 16-bit PCMCIA support ("pcmcia.ko") and the socket driver (in most cases "yenta_socket.ko"), it is recommended that you put the names of these modules ("pcmcia", "yenta_socket") into /etc/modules.autoload.d/kernel-2.6

2. pcmciautils

pcmciautils contains the hotplug scripts necessary for 16-bit PCMCIA card support and a small startup tool which is needed to pass the information contained in /etc/pcmcia/config.opts to the kernel. [*]

```
emerge pcmciautils
```

[*] Note: A few PCMCIA sockets found in embedded system do not need this information any longer; and I am confident that it will no longer be mandatory for a large number of "yenta"-style sockets in future. This needs some coding and lots of testing, so this is still talk about the future...

If coldplug needed to be emerged, don't forget to issue 

```
rc-update add coldplug default
```

 or 

```
rc-update add coldplug boot
```

.

3. Broken cards

Some cards require a CIS (something comparable to firmwire) update to work correctly. If you have a card requiring this, also

```
emerge pcmcia-cs-cis
```

4. Known bugs

PCMCIA drivers not in Linus' tree won't work.

5. Test

Reboot to the appropriate kernel, and test whether 16- and 32-bit PCCARDs work. Report troubles either in this thread or directly to me, linux AT dominikbrodowski DOT netLast edited by brodo on Thu Jun 30, 2005 10:18 pm; edited 5 times in total

----------

## GurliGebis

Nice, now we just need the kernel-2.eclass to get fixed so 2.6.11-mm1 ebuild would work  :Smile: 

----------

## genstef

Do you know a patch to use this new layout with the fritz card pcmcia?

net-dialup/fritzcapi .. I suppose it does not work, as it is not in linus tree, but it is maybe possible to convert it, as the source is provided under LGPL-2.

Is there a howto for converting drivers to the new pcmcia?

----------

## brodo

Sorry for the late reply. In 2.6.12-rc1-mm4, there's a directory Documentation/pcmcia/ which contains a file "driver-changes.txt" which contains (hopefully) all necessary information for changes in the last few months done to the Linux kernel PCMCIA subsystem. Then, "devicetable.txt" describes the information necessary for in-kernel device <-> driver matching a bit more detailed. However, it's not _much_ information, so it's best to a) look at the drivers already converted, or b) ask me or the list at linux minus pcmcia at lists dot infradead dot org.

----------

## GurliGebis

brodo> Have you figured out my problem with having to echo stuff into /sys to make it work?

----------

## brodo

 *GurliGebis wrote:*   

> brodo> Have you figured out my problem with having to echo stuff into /sys to make it work?

 

not yet, unfortunately. Quite busy with other issues these days, sorry...

----------

## GurliGebis

okay, I'll try the newest mm sources and see if it changes.

----------

## brodo

bump... as the patches reached Linus' tree, this might be of interest to more people.

----------

## thesnowman

 *genstef wrote:*   

> Is there a howto for converting drivers to the new pcmcia?

 

Not quite a HOWTO, but if you read /usr/src/linux/Documentation/pcmcia/devicetable.txt and compare some of the 2.6.12 kernel pcmcia drivers to their 2.6.13 equivalent you will see what is required.

Edit: Just realised I was reiterating what brodo said back in April   :Embarassed:  Sorry.Last edited by thesnowman on Thu Nov 03, 2005 10:07 pm; edited 1 time in total

----------

## thesnowman

I think the best feature of this new PCMCIA subsystem is you can now insert and eject cards from /sys

```
sudo sh -c "echo \"1\" > /sys/class/pcmcia_socket/pcmcia_socket1/card_eject
```

I created a group called pcmcia and wrote a script to give members of this group write access to the card_eject and card_insert files in /sys.  This way I can eject the card as a normal user.  Here's the script, which I run in /etc/conf.d/local.start

```
#!/bin/bash

socket_dir=/sys/class/pcmcia_socket

insert=card_insert

eject=card_eject

if [ `whoami` != "root" ]; then

    echo "You must be root to run this script."

    exit 1

fi

if [ -e ${socket_dir} ]; then

    for socket in $( find ${socket_dir} -type d -name 'pcmcia_socket[0-9]' )

    do

        for file in "${socket}/${insert}" "${socket}/${eject}"

        do

            chown root:pcmcia ${file}

            chmod g+w ${file}

        done

    done

fi

```

----------

## billk

I have been using an atheros wireless card with madwifi with up to 2.6.13-3

No 2.6.14 version appears to work (PCI bus sees card plugged in, ath_pci prints some messages and thats it)

I upgraded to the new pcmcia stuff with the only change being that 2.6.13 no longer works either - same log messages as 2.6.14

The udev rules are present, but I cant tell if the new pcmciautils are being run

Can you confirm

1) I do need this new pcmcia stuff with the 2.6.14 series

2) how I can get wireless back, or do I downgrade?

3) If I downgrade, how do I get wireless working with 2.6.14

This is presuming that the cause is the new pcmcia stuff not something else.

BillK

----------

## billk

Works.  The problem was elsewhere (wpa_supplicant version)

The new pcmcia stuff works well so far.  I do wish there was a better way to see debug info so it is easily confirmed that its working or not.

BillK

----------

## mags

Hi,

I have an Aspire 3020 and I've been happily running Gentoo on 2.6.13-r3. However, I recently emerged world and now have 2.6.14-r5 and no working PCMCIA. I've read around the new PCMCIA subsystem discussions, unmerged pcmcia-cs, merged pcmciautils and pcmcia-cs-cis, yet the system refuses to recognise my card. I have a 3Com OfficeConnect 802.11g (3CRWE154G72) which had been happy to run with ndiswrapper. 

Here's a few random technical bits:

If I unplug/eject the card, this appears in /var/log/messages:

Dec 24 10:11:29 flygirl PCMCIA: socket dfc5882c: *** DANGER *** unable to remove socket power

flygirl etc # pccardctl info;pccardctl ident

PRODID_1=""

PRODID_2=""

PRODID_3=""

PRODID_4=""

MANFID=0000,0000

FUNCID=255

Socket 0:

  no product info available

flygirl etc # pccardctl insert; pccardctl info;pccardctl ident

PRODID_1=""

PRODID_2=""

PRODID_3=""

PRODID_4=""

MANFID=0000,0000

FUNCID=255

Socket 0:

  no product info available

Nothing appears in /var/log/messages concerning the inserting of the card.

The relevant lspci -v -v entry:

06:06.0 CardBus bridge: Texas Instruments PCIxx21/x515 Cardbus Controller

        Subsystem: Acer Incorporated [ALI] Unknown device 0080

        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B-

        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR-

        Latency: 168, Cache Line Size 10

        Interrupt: pin A routed to IRQ 11

        Region 0: Memory at 52000000 (32-bit, non-prefetchable) [size=4K]

        Bus: primary=06, secondary=07, subordinate=0a, sec-latency=176

        Memory window 0: 54000000-55fff000 (prefetchable)

        Memory window 1: 50000000-51fff000

        I/O window 0: 0000a400-0000a4ff

        I/O window 1: 0000a800-0000a8ff

        BridgeCtl: Parity- SERR- ISA- VGA- MAbort- >Reset- 16bInt- PostWrite+

        16-bit legacy interface ports at 0001

From dmesg:

PCI: Bus 7, cardbus bridge: 0000:06:06.0

  IO window: 0000a400-0000a4ff

  IO window: 0000a800-0000a8ff

  PREFETCH window: 54000000-55ffffff

  MEM window: 50000000-51ffffff

ACPI: PCI Interrupt 0000:06:06.0[A] -> Link [LNKE] -> GSI 11 (level, low) -> IRQ 11

Yenta: CardBus bridge found at 0000:06:06.0 [1025:0080]

Yenta: Using CSCINT to route CSC interrupts to PCI

Yenta: Routing CardBus interrupts to PCI

Yenta TI: socket 0000:06:06.0, mfunc 0x010a1b22, devctl 0x64

Yenta: ISA IRQ mask 0x00f8, PCI irq 11

Socket status: 30000820

pcmcia: parent PCI bridge I/O window: 0xa000 - 0xafff

cs: IO port probe 0xa000-0xafff: clean.

pcmcia: parent PCI bridge Memory window: 0x50000000 - 0x52ffffff

pcmcia: parent PCI bridge Memory window: 0x53000000 - 0x55ffffff

And for completeness:

flygirl ~ # uname -a

Linux flygirl 2.6.14-gentoo-r5 #1 SMP PREEMPT Tue Dec 20 23:35:27 GMT 2005 i686 Mobile AMD Sempron(tm) Processor 2800+ AuthenticAMD GNU/Linux

Any thoughts at all?

I'd really appreciate some help as having no wireless card is a little annoying!

John

----------

## mags

http://www.kernel.org/pub/linux/utils/kernel/pcmcia/powerbugs.html#2

I had the *** DANGER *** message in my kernel messages, and when I used the correct reserve= kernel option, the PCMCIA card started working too.

John

----------

## mags

Or rather, I added this to the kernel parameters: pci=assign-busses

Sorry - the reserve option did nothing  :Smile: 

----------

## cjm46543

 *brodo wrote:*   

> 
> 
> If you relied on the startup script of pcmcia-cs (/etc/init.d/pcmcia/) to load the appropriate kernel modules for 16-bit PCMCIA support ("pcmcia.ko") and the socket driver (in most cases "yenta_socket.ko"), it is recommended that you put the names of these modules ("pcmcia", "yenta_socket") into /etc/modules.autoload.d/kernel-2.6
> 
> 

 

A warning about this: I just upgraded to kernel 2.6.15-gentoo-r1 and did the upgrade from pcmcia-cs to pcmciautils.  Following the instructions here, I put "pcmcia" and "yenta_socket" in my modules.autoload.d/kernel-2.6.  I also have coldplug and hotplug loading in the default runlevel.  With this setup, my Netgear MA401 wireless card (a Hermes/Orinoco chipset) wouldn't connect to the network on boot, only if it was hotplugged.  I was also getting a Usage message on pcmcia-check-broken-cis when coldplug loaded pcmcia devices.  I removed yenta_socket from the modules.autoload.d (leaving only pcmcia), and now the wireless card connects to the network on boot.

----------

## chrbecke

Hi, 

I hope someone is still watching this thread...

I tried to switch to pcmciautils on my notebook and I'm having some trouble with it.

I'm running

gentoo-sources-2.6.15-r1

hotplug-20040923-r3

hotplug-base-20040401

coldplug-20040920

udev-087

pcmciautils-013

The pcmcia socket uses yenta_socket, I'm using a pcmcia modem/network card which uses xirc2ps_cs for networking and serial_cs as modem driver.

pcmcia is in /etc/modules.autoload.d/kernel-2.6

If I boot the laptop with the network card plugged in, I find  *dmesg wrote:*   

> cs: no high memory available!
> 
> cs: unable to map memory!

 

"lsmod" reveals that firmware_class, pcmcia_core, pcmcia, rsrc_nonstatic and yenta_socket are loaded.

If I then run 

```
pcmcia-socket-startup
```

 I see some IO port ranges being assigned to the two pcmcia sockets, followed by

 *dmesg wrote:*   

> 0.1: ttyS3 at I/O 0x2e8 (irq = 3) is a 16550A
> 
> xirc2ps_cs: no ports available

 

So it looks as if the modem is up allright (haven't tested - and don't care, actually), but the nic isn't... network is unreachable.

"lsmod" shows serial_cs and xirc2ps_cs both being loaded.

If I now eject and reinsert the card, the nic comes up allright:

 *dmesg wrote:*   

> Apr 29 06:25:10 klotz pccard: card ejected from slot 0
> 
> Apr 29 06:25:14 klotz pccard: PCMCIA card inserted into slot 0
> 
> Apr 29 06:25:14 klotz pcmcia: registering new device pcmcia0.0
> ...

 

My guess is some kind of race condition in the udev/coldplugging process, which confuses the order in which modules are loaded and pcmcia-socket-startup is being run, and/or some sysfs entries/device nodes appear too slow... I booted with udev/hot-/colplug debugging enabled, but I couldn't find anything odd...

So, has anyone got any ideas on how to get my nic up and running with coldplug? Or is this a case for the linux-pcmcia list?

Thanks in advance,

Christian

----------

## DeepBass909

 *chrbecke wrote:*   

> Hi, 
> 
> I hope someone is still watching this thread...
> 
> I tried to switch to pcmciautils on my notebook and I'm having some trouble with it.
> ...

 

Have you emerged pcmcia-cs-cis?

----------

## chrbecke

 *DeepBass909 wrote:*   

> Have you emerged pcmcia-cs-cis?

 

Thanks for your answer, DeepBass909.

No, I hadn't, because there is no cis update needed for my card, afaik. Tried again with pcmcia-cs-cis installed, anyways, but no difference. 

As I said before, my nic works if I bring it up manually - it just isn't brought up by the hot-/coldplug/udev system.

If I do the following, in the given order, my nic works fine: modprobe pcmcia

 modprobe yenta_socket

 modprobe xirc2ps_cs

 pcmcia-socket-startup

These are exactly the steps that should be executed by udev, according to /etc/udev/rules.d/60-pcmcia.rules. With udev debugging enabled, I can see these steps being done by udev, but udev screws up the right order - resulting in my nic not working.

If I put pcmcia, yenta_socket and xirc2ps_cs in /etc/modules.autoload.d/kernel-2.6 and put /sbin/pcmcia-socket-startup in /etc/conf.d/local.start, my nic works right after booting. I could live with this workaround, but I would prefer to get it to work with udev.  :Smile: 

----------

## DeepBass909

I have an other small but anoying problem.

My pcmcia socket is working, even hotplug works with my Netgear wifi card (that's only pcmcia card I have), but there is something strange thou.

If I start Linux with the card in the pcmcia-slot, everthing works fine. But when I insert it while the laptop is already running, Linux doesn't take notice of the card in any way and the powerled of the card stays off. But if I eject it and insert it again, Linux all of a sudden does see the card, loads the modules and everything.

If I eject the card again (mind you, it's running at this time), dmesg shows an eject message (as expected) and the modules are kept running (also as expected). But the strange thing is, when I insert it again, then again nothing happens (no messages in dmesg, powerled of the card stays off). I repeat the procedure of ejecting and inserting, and surprise surprise, the card works again...   :Rolling Eyes: 

I'm not really sure if this is related to hotplug or acpi. Because the powerled stays off, I would think it's related to the acpi... But then again, I thought acpid used hotplug to test if there's a card inserted...

Who can help me on this? It isn't critical, because the second time the card is inserted, everything works ok, but it's damn anoying...

----------

## kipz

 *chrbecke wrote:*   

> 
> 
> .....
> 
> As I said before, my nic works if I bring it up manually - it just isn't brought up by the hot-/coldplug/udev system.
> ...

 

I'm having the same problem on my Toshiba Satellite 4090CDS with the ToPIC97  (rev-5) CardBus bridge (yenta_socket compatible) and udev on kernel 2.6.16.16 (vanilla-sources). Works fine after I've run 'pcmcia-socket-startup', but I really want it to work cleanly through udev on boot too.

----------

## DeepBass909

 *kipz wrote:*   

>  *chrbecke wrote:*   
> 
> .....
> 
> As I said before, my nic works if I bring it up manually - it just isn't brought up by the hot-/coldplug/udev system.
> ...

 

Just a thought, but would it work if you created an /etc/modules.d/xircps_cs file containing the following:

```

above xirc2pc_cs yenta_socket
```

After that you should run modules-update to get it integrated into /etc/modules.conf.

This should force modprobe and thus udev to first load the yenta_socket driver and after that the xirc2ps_cs module.

ps I'm not really sure about the above, if I understand the man modules.conf right, this should "pull-in" the module behind xirc2pc_cs above itself, and thus force itself to work on top of yenta_socket. 

But basically I would think this is a small bug in the kernel config, because it should have made an extra line in modules.dep, creating a dependency on yenta-socket... But I' m also not really sure about this, I'm still trying to figure out how linux exactly handles modules...

----------

## mamac

Hi,

I installed a wireless pcmcia card and I need to unplug/re-plug it after startup to make it work.

Strange because lspci shows the card if don't do anything.

Do you know if it's related to udev/pcmcia or (udev loads yenta_socket at startup)?

I searched but didn't find any clue, and I'm not a udev guru.

Thanks

P.S.: everything went find after updating world   :Wink: 

----------

## kingcoras

I cannot get my Orinoco Silver Wavelan card to work.  it refuses to scan out, saying the network is down.  I have pcmciautils and hotplug installed.

relevant dmesg output:

```

pccard: PCMCIA card inserted into slot 0

cs: memory probe 0x0c0000-0x0fffff: excluding 0xc0000-0xcffff 0xdc000-0xfffff

cs: memory probe 0x50000000-0x53ffffff: excluding 0x50000000-0x53ffffff

cs: memory probe 0x60000000-0x60ffffff: clean.

cs: memory probe 0xa0000000-0xa0ffffff: clean.

cs: memory probe 0xe0300000-0xe03fffff: excluding 0xe0300000-0xe030ffff

pcmcia: registering new device pcmcia0.0

orinoco 0.15 (David Gibson <hermes@gibson.dropbear.id.au>, Pavel Roskin <proski@gnu.org>, et al)

orinoco_cs 0.15 (David Gibson <hermes@gibson.dropbear.id.au>, Pavel Roskin <proski@gnu.org>, et al)

pcmcia: request for exclusive IRQ could not be fulfilled.

pcmcia: the driver needs updating to supported shared IRQ lines.

eth1: Hardware identity 0001:0001:0004:0000

eth1: Station identity  001f:0001:0006:0006

eth1: Firmware determined as Lucent/Agere 6.06

eth1: Ad-hoc demo mode supported

eth1: IEEE standard IBSS ad-hoc mode supported

eth1: WEP supported, 104-bit key

eth1: MAC address 00:02:2D:1F:41:4B

eth1: Station name "HERMES I"

eth1: ready

eth1: orinoco_cs at 0.0, irq 17, io 0x4100-0x413f

```

lsmod output:

```

orinoco_cs             13572  1 

orinoco                38420  1 orinoco_cs

hermes                  6144  2 orinoco_cs,orinoco

```

pccardctl ident output:

```

Socket 0:

  product info: "Lucent Technologies", "WaveLAN/IEEE", "Version 01.01", ""

  manfid: 0x0156, 0x0002

  function: 6 (network)

```

The card acts likes it's there, but doesn't do anything.  It works fine in my windows laptop, but I hate that piece of crap...

----------

## mamac

Hi,

What gives "iwlist eth1 scanning", assuming eth1 is your wireless card?

----------

