LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-25-2008, 01:40 AM   #1
galapogos
Member
 
Registered: May 2008
Posts: 227

Rep: Reputation: 30
Problem with PCMCIA smart card reader


Hi,

I have a smart card reader that is bound to the serial port(/dev/ttyS0), and I've installed the necessary drivers/packages to get it to work properly on Mandriva 2008.1

I'm now trying to get it to work on my own kernel build(2.6.22.19)

I have included all relevant serial/PCMCIA options in menuconfig, however my smart card application doesn't seem to detect the card reader.

The kernel recognizes when I plug/unplug the reader.

Is there anything I can do to test the serial/PCMCIA ports?
 
Old 07-25-2008, 06:20 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
It may be a matter of whether the modules are loaded or not. Compare the initrd's for each kernel. However, the pcmcia bus is a pci bus extension and not a serial bus. Make sure that the yenta module is loaded. If the device on the card is detected properly, it seems that the PCMCIA interface is working and you need to work on the device that is on the card. In other words, the problem is with the device on the pcmcia card and not with the pcmcia driver on the computer.

Something about "the reader being bound to a serial port" just doesn't sound right. Smart card readers normally use usb/scsi modules and not terminal serial devices.

Since it is working in Mandriva 2008.1, look at what modules you have loaded when runnng it's kernel. Do you have the hal hardware monitor program? That can give you a dependency tree. Ålso look at the modinfo information for the modules used in Mandriva. Also run "depmod -a" to make sure your dependency lists are current.

When compiling a new kernel, it is best to run "make oldconfig" first. That will copy your old config and use it as a model when starting out. New options are brought to your attention. Then you can tweak your config in "make xconfig".

It could also be a matter of which modules are included in the initrd file. Also check the boot scripts. Do you have a file listing modules that should be loaded. Another thing to check is the /etc/modprobe.d/ files. However if it works in one kernel and not the other, then these entries are probably correct.
 
Old 07-26-2008, 02:01 AM   #3
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
Thanks for the reply.

Actually I'm not loading them as modules but building them directly into the kernel. I figured out that I needed to mount them into /sys, which I did with "mount -t sysfs none /sys/", after which I was able to detect the card reader with pccardctl. The readers also appear on /sys/bus/devices immediately after they are plugged in.

However, the weird thing is that when I run lspcmcia, I get a "driver not loaded" or some similar message when I insert the Gemplus reader. I do however see the "CM4040" with I instead insert an Omnikey CardMan 4040 reader. In the kernel menuconfig I have enabled CM4040 support, so this makes sense. What doesn't make sense is why the Gemplus reader isn't being read, because I have also enabled serial_cs support, which is what the Gemplus reader is supposed to use, as seen in the Mandriva 08 box.

The yenta module is loaded, I see it there.
 
Old 07-27-2008, 12:11 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I just read something and came back to this post. However, once I did, maybe it isn't applicable. Since you mentioned a serial port, to gain access to a serial port, one needs to be a member of the uucp group. http://www.arduino.cc/playground/Linux/OpenSUSE
 
Old 07-27-2008, 12:21 AM   #5
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
Hi,

Thanks. Speaking of the serial port, it's actually bound, or supposed to be bound, to /dev/ttyS0 or /dev/ttyS1 according to the CCID documentation. I then have to state this location in the /etc/reader.conf configuration file. Where exactly it's bound to depends on detection. IIRC I did a tail -f /var/log/messages on my Mandriva box to find out where it's detected as being connected to(ttyS0 or ttyS1). However, I don't even have that file in my own kernel build. Also, I did not have ttyS0 to begin with, hence I just did a mknod on it.

So, 2 questions for now
1) Is there any way to make the /var/log/messages appear so I can see where the card reader is trying to connect to? I tried dmesg but I don't think it showed anything.
2) Can I just simply do a mknod to create the ttyS0(with the correct major, minor numbers), assuming serial support is already enabled in the kernel .config? Or is there some other proper way of creating this device file.

Sorry for the noob questions, and thanks for the help so far.
 
Old 07-27-2008, 01:00 PM   #6
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I went looking for documentation for serial devices in the kernel source. Different kernels may have different drivers, but in kernel/drivers/serial/ I found the source for the serial_cs driver.
It is "A driver for PCMCIA serial devices". That sounds like what this device would use. Do you have this device modprobed?
 
Old 07-27-2008, 09:14 PM   #7
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
Yes serial_cs is actually installed in my kernel, not as a module. In Mandriva 08, this driver is what's loaded for the Gemplus card reader. However, I don't know why it doesn't seem to be loaded in my own build. Instead I get a "driver not loaded" or something. This is despite pccardctl properly identifying the reader, which leaves me confused. It's like half detected, but still half undetected.

Here's the output of some of the commands I ran

pccardctl ident:
Code:
Socket 0:
  product info: "Gemplus", "SerialPort", "GemPC Card", ""
  manfid: 0x0157, 0x0100
  function:  (serial)
pccardctl info:
Code:
PRODID_1="Gemplus"
PRODID_2="SerialPort"
PRODID_3="GemPC Card"
PRODID_4=""
MANFID=0157, 0100
FUNCID=2
pccardctl status:
Code:
Socket 0:
  5.0V 16-bit PC Card
  Subdevice 0 (function 0) [unbound]
lspcmcia -v
Code:
Socket 0 Bridge:        [yenta_cardbus]         (bus ID: 0000:03:0b.0)
        Configuration:  state: on       ready: yes
                        Voltage: 5.0V Vcc: 5.0V Vpp: 5.0V
Socket 0 Device 0:      [-- no driver --]       (bus ID: 0.0)
        Configuration:  state: on
        Product Name:   Gemplus SerialPort GemPC Card
        Identification: manf_id: 0x0157 card_id: 0x0100
                        function: 2 (serial)
                        prod_id(1): "Gemplus" (0x0981590f)
                        prod_id(2): "SerialPort" (0xe9010d26)
                        prod_id(3): "GemPC Card" (0xddc63bd8)
                        prod_id(4): --- (---)
On my Mandriva box, when I do an ls /sys/bus/pcmcia/devices/0.0, I get a few files/directories that I don't see in my own kernel build, such as:
bus -> ../../../../../bus/pcmcia/drivers/serial_cs
power/
tty:ttyS0 -> ../../../../../class/tty/ttyS0

Also when I do an ls /sys/bus/pcmcia/drivers/serial_cs, I also get a few missing files/directories

So I know I'm missing something, just not sure what.

btw I really appreciate your help so far.

Last edited by galapogos; 07-27-2008 at 09:56 PM.
 
Old 07-28-2008, 02:29 AM   #8
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
OK, after compiling power management support and sysfs_deprecated into the kernel, I get the bus/ and power/ subdirectory in /sys/bus/pcmcia/devices/0.0. However, I'm still facing a few problems:

With the Gemplus GemPC Card reader, the driver/ subdirectory doesn't show up in /sys/bus/pcmcia/devices/0.0/ when I plug it in. With the Omnikey CM4040, it shows up, and is in fact a symlink to /sys/bus/pcmcia/drivers/cm4040_cs. The GemPC Card should have a symlink to /sys/bus/pcmcia/drivers/serial_cs, but it doesn't, which is why I guess I get the [-- no driver --] message when I do a lspcmcia. How do I bind the card reader to the driver?

Also, with the GemPC Card reader on the Mandriva box, when I plug the reader in, a tty:ttyS0 symlink also shows up in the device subdirectory. This doesn't happen on my own kernel build. Again I'm guessing this is a problem since the device is supposed to be bound to ttyS0. So again, how do I accomplish this?

Thanks again.
 
Old 07-28-2008, 07:05 PM   #9
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Monitor the kernel messages while plugging the device in the Mandriva computer. Note any kernel messages from devices you don't have on the other machine. Also try "lshal -m". I'm surprised that your reader uses a serial device and not one of the mmc modules. Also study the udev rules in /etc/udev/rules.d/. One of the rules in Mandriva probably creates the tty/ttyS0 link.
Look at any other links produced as well. And list the links with the -l option to see where they point. Creating special device files and linking to them is what udev does now. If you have all of the devices you need and the device is detected, I'm betting that you need a udev rule to create the device node and the symbolic links to that node.

Last edited by jschiwal; 07-28-2008 at 07:09 PM.
 
Old 07-28-2008, 08:53 PM   #10
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
On the Mandriva box, when I insert the Gemplus reader, /var/log/messages shows:
Code:
pccard: PCMCIA card inserted into slot 0
pcmcia: registering new device pcmcia0.0
0.0: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450
On my kernel build I somehow don't have /var/log/messages, but I've enabled kernel debug messages so I get the same thing on the screen in real time. Upon insertion of the Gemplus reader, I get only the 1st 2 lines and not the 3rd.

Actually I did not install udev on my own kernel build, since it was adapted from a previous project that was using a 2.4 kernel. I'm going to try to use hotplug instead for now and if that doesn't work I will try to "install" udev - basically just copy all the related files from the Mandriva box over to my own kernel environment. Will that work?

I just find it weird that my kernel detects and binds the driver for the omnikey card reader just fine, but not the gemplus one.

Last edited by galapogos; 07-28-2008 at 09:04 PM.
 
Old 10-05-2008, 02:54 PM   #11
magwas
LQ Newbie
 
Registered: Oct 2008
Posts: 1

Rep: Reputation: 0
your solution, my problem

[QUOTE=galapogos;3229260]On the Mandriva box, when I insert the Gemplus reader, /var/log/messages shows:
Code:
pccard: PCMCIA card inserted into slot 0
pcmcia: registering new device pcmcia0.0
0.0: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450
On my kernel build I somehow don't have /var/log/messages, but I've enabled kernel debug messages so I get the same thing on the screen in real time. Upon insertion of the Gemplus reader, I get only the 1st 2 lines and not the 3rd.


Solution:
echo "0x3 0x0157 0x0100 0 0 0 0 0 0 0">/sys/bus/pcmcia/drivers/serial_cs/new_id

You tell serial_cs with it that your card should be handled by it.
This command should be issued after loading the serial_cs module.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ChipDrive Smart card reader the-yikes Slackware 0 07-24-2007 02:30 PM
smart card reader questions rastavideo Ubuntu 5 08-01-2006 10:39 AM
Smart card reader mehro Linux - Software 0 12-06-2005 12:56 AM
Smart card reader (PCI) with open pgp card cracidy Linux - Hardware 0 10-24-2005 02:34 AM
problem with smart card reader pxes351 Linux - Hardware 2 03-07-2005 01:11 AM


All times are GMT -5. The time now is 06:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration