Sophie

Sophie

distrib > Mandriva > current > x86_64 > by-pkgid > ed9fe908e8304375d99a386ba3861200 > files > 93

openct-0.6.20-1mdv2010.1.x86_64.rpm

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
      TroubleShooting – OpenCT
    </title><style type="text/css">
           @import url(trac.css);
          </style></head><body><div id="content" class="wiki">
      <div class="wikipage searchable">
        
          <h1 id="Troubleshootinganddebugging">Troubleshooting and debugging</h1>
<p>
If something doesn't work, please contact us on the opensc-users mailing lists.
For details, please see <a class="missing wiki" shape="rect">MailingList?</a>.
</p>
<p>
If you subscribe to these mailing lists you can post directly, if not a moderator
will review your posting first, so we can filter spam.
</p>
<p>
So here are some step by step instructions to find your problem:
</p>
<p>
If you try to use a USB device, please try this: 
</p>
<ul><li>Is your /proc filesystem mounted? ls /proc will show some files and directories.
</li><li>Is your linux kernel compiled with usb support? Does it work? "lsusb" should list your usb controller and all devices.
</li><li>Is your linux kernel compiled with hotplugging support? cat /proc/sys/kernel/hotplug should output "/sbin/hotplug".
</li><li>Do you have a hotplug script? ls /sbin/hotplug will list it or print an error message?
</li><li>Did you create the directory /var/run/openct? What files are in there? What are the file permissions? ls -la /var/run/openct will tell you.
</li></ul><p>
Note that recently some linux distributions changed the hotplug system:
</p>
<ul><li>The kernel still needs to be compiled with CONFIG_HOTPLUG but "cat /proc/sys/kernel/hotplug" will not show anything. 
</li><li>The system is no longer using the hotplug scripts. Instead it is using either udev or udev with hald.
</li><li>/proc/bus/usb might be empty. Instead the usb devices might show up in /dev/bus/usb.
</li></ul><p>
In all cases:
</p>
<ul><li>Did you install the openct init.d script? Did you run it? 
</li><li>Does openct-tool list show your reader?
</li></ul><p>
If you are using a usb smart card reader, and openct-tool does not list it: What is that readers USB vendor and product id?
lsusb will tell you. Edit /etc/openct.conf and /etc/hotplug/usb/openct.usermap, check if that entry is listed, and add it if not.
If the reader works after doing this, please contact opensc-devel@…, so we can add that id to OpenCT.
</p>
<h2 id="USBLinuxKernelfeature">USB / Linux Kernel "feature"</h2>
<p>
This has been fixed in OpenCT 0.6.7 or even earlier. 
</p>
<p>
We found a problem with the linux kernel. If you plugin your usb token/reader/device and it sometimes works well,
and it sometimes does not work well, and if syslog has an error message that open() failed: we were too fast,
the kernel was not yet ready to allow us to use the device. Please edit /etc/hotplug/usb/openct and replace
</p>
<pre class="wiki" xml:space="preserve">
#!/bin/sh

test "$ACTION" = "add" || exit 0

if [ -e /var/run/openct/status ]
then
        /usr/sbin/openct-control attach $DEVICE usb:$PRODUCT
fi
</pre><p>
with
</p>
<pre class="wiki" xml:space="preserve">
#!/bin/sh

test "$ACTION" = "add" || exit 0

if [ -e /var/run/openct/status ]
then
        sleep 1
        /usr/sbin/openct-control attach $DEVICE usb:$PRODUCT
fi
</pre><p>
(i.e. add the line "sleep 1" before the "openct-control" line.)
</p>
<p>
For reference: hotplug-devel mailing list, 2005-06-14
<a class="ext-link" href="http://sourceforge.net/mailarchive/message.php?msg_id=12059902" shape="rect"><span class="icon"> </span>http://sourceforge.net/mailarchive/message.php?msg_id=12059902</a> and
the response by Kay Sievers.
</p>
<h2 id="DebuggingHotplug">Debugging Hotplug</h2>
<p>
For many users the hotplug system on linux doesn't work as expected.
Here are some tips how to debug it.
</p>
<p>
Your linux kernel needs to be compiled with CONFIG_HOTPLUG.
</p>
<pre class="wiki" xml:space="preserve">cat /proc/sys/kernel/hotplug 
</pre><p>
will tell you if your kernel does hotplugging.
</p>
<p>
You can install a test script to see if it works as advertised:
</p>
<pre class="wiki" xml:space="preserve">cat &gt; /root/testplug &lt;&lt;EOF
#!/bin/bash

(echo \$0: \$*; export; echo) &gt;&gt; /root/testplug.log
EOF
chmod +x /root/testplug
echo /root/testplug &gt; /proc/sys/kernel/hotplug
</pre><p>
With this change you will generate a log file for all
hotplug events. A typical log file entry for adding atoken looks like this:
</p>
<pre class="wiki" xml:space="preserve">/root/testplug: usb
declare -x ACTION="add"
declare -x DEVPATH="/devices/pci0000:00/0000:00:1d.1/usb3/3-2"
declare -x HOME="/"
declare -x OLDPWD
declare -x PATH="/sbin:/bin:/usr/sbin:/usr/bin"
declare -x PHYSDEVBUS="usb"
declare -x PHYSDEVDRIVER="usb"
declare -x PWD="/"
declare -x SEQNUM="2398"
declare -x SHLVL="1"
declare -x SUBSYSTEM="usb"

/root/testplug: usb
declare -x ACTION="add"
declare -x DEVICE="/proc/bus/usb/003/063"
declare -x DEVPATH="/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0"
declare -x HOME="/"
declare -x OLDPWD
declare -x PATH="/sbin:/bin:/usr/sbin:/usr/bin"
declare -x PHYSDEVBUS="usb"
declare -x PRODUCT="973/1/100"
declare -x PWD="/"
declare -x SEQNUM="2399"
declare -x SHLVL="1"
declare -x SUBSYSTEM="usb"
declare -x TYPE="255/0/0"
</pre><p>
You can ignore the first entry, only those of subsystem "usb" and ACTION="add"
are important.
</p>
<p>
You can test the hotplug scripts on your system like this:
</p>
<pre class="wiki" xml:space="preserve">/root/testplug: usb
export ACTION="add"
export DEVICE="/proc/bus/usb/003/063"
export DEVPATH="/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0"
export PHYSDEVBUS="usb"
export PRODUCT="973/1/100"
export SUBSYSTEM="usb"
export TYPE="255/0/0"
sh -x /sbin/hotplug add 2&gt;&amp;1 |tee hotplug.log
</pre><p>
You only need those environment settings, but please change DEVICE and DEVPATH
and PRODUCT to match your last log file entry. Not that if you remove and add
a usb device, the DEVICE entry will change.  This will start the hotplug scripts
as usual, but using "sh -x" you can see what the shell script does.
</p>
<p>
If no other software needs hotplugging, here is
the fastest way to make sure it works with openct:
</p>
<pre class="wiki" xml:space="preserve">echo /etc/hotplug/usb/openct &gt; /proc/sys/kernel/hotplug
</pre><h2 id="DebuggingOpenCT">Debugging OpenCT</h2>
<p>
But if you are writing a new driver or you have some device and you are not sure 
whether it works, you might want to debug openct directly.
</p>
<p>
First you need to start the init script and make sure that /var/run/opensc/status
does exist.
</p>
<p>
Second add your device. If hotplug does not work or the ifdhandler dies that is ok.
Use lsbusb to find out which controller your usb device is attached to and what the
device number is. Also you need to check if you have usb devices in /dev/bus/usb/
or in /proc/bus/usb/.
</p>
<p>
Third start ifdhandler yourself as root. Here is an example for usb controller 002 and device 005 and the ccid driver:
</p>
<pre class="wiki" xml:space="preserve">ifdhandler -FHddddd ccid /dev/bus/usb/002/005
</pre><p>
In this example:
</p>
<ul><li>"-F" tells ifdhandler to stay in foreground and write errors to stdout/stderror.
</li><li>"-H" tells ifdhandler this is a hotplug device, it could vanish any second.
</li><li>"-d" increases the debug level. 5 or 6 is usualy nice for debugging usb transactions.
</li><li>"ccid" is the name of the driver. Make sure you use the right one, in doubt ask on the list.
</li><li>"/dev/bus/usb/002/005" is the device file. Ifdhandler will open it and use ioctl() on it for sending and receiving usb packets.
</li></ul><p>
If you have any trouble, please contact us via our mailing lists (see <a class="wiki" href="MailingLists.html" shape="rect">MailingLists</a>).
</p>

        
        
      </div>
    </div><div class="footer"><hr></hr><p><a href="index.html">Back to Index</a></p></div></body></html>