2 Smartcard Reader Installation Under Linux X86 6

2 Smartcard Reader Installation Under Linux X86 6

<p> THE INFORMATION CONTAINED HEREIN IS CONFIDENTIAL AND PROPRIETARY TO SMSC, SHALL BE USED SOLELY IN ACCORDANCE WITH THE AGREEMENT PURSUANT TO WHICH IT IS PROVIDED, AND SHALL NOT BE REPRODUCED OR DISCLOSED TO OTHERS WITHOUT THE PRIOR WRITTEN CONSENT OF SMSC. ALTHOUGH THE INFORMATION IS BELIEVED TO BE ACCURATE, NO RESPONSIBILITY IS ASSUMED FOR INACCURACIES. SMSC RESERVES THE RIGHT TO MAKE CHANGES TO THIS DOCUMENT AND TO SPECIFICATIONS AND PRODUCT DESCRIPTIONS AT ANY TIME WITHOUT NOTICE. NEITHER THE PROVISION OF THIS INFORMATION NOR THE SALE OF THE DESCRIBED SEMICONDUCTOR DEVICES CONVEYS ANY LICENSES UNDER ANY PATENT RIGHTS OR OTHER INTELLECTUAL PROPERTY RIGHTS OF SMSC OR OTHERS. THE PRODUCT MAY CONTAIN DESIGN DEFECTS OR ERRORS KNOWN AS ANOMALIES, INCLUDING BUT NOT NECESSARILY LIMITED TO ANY WHICH MAY BE IDENTIFIED IN THIS DOCUMENT, WHICH MAY CAUSE THE PRODUCT TO DEVIATE FROM PUBLISHED SPECIFICATIONS. SMSC PRODUCTS ARE NOT DESIGNED, INTENDED, AUTHORIZED OR WARRANTED FOR USE IN ANY LIFE SUPPORT OR OTHER APPLICATION WHERE PRODUCT FAILURE COULD CAUSE OR CONTRIBUTE TO PERSONAL INJURY OR SEVERE PROPERTY DAMAGE.</p><p>THE CUSTOMER IS THE BEST JUDGE OF THE VALUE AND IMPORTANCE OF THE DATA HELD ON THE SMSC HARDWARE OR SOFTWARE AND SHOULD INSTITUTE AND OPERATE ALL NECESSARY BACKUP PROCEDURES TO ENSURE THAT DATA INTEGRITY CAN BE MAINTAINED IN THE EVENT OF LOSS OF DATA FOR ANY REASON. IN ADDITION, THE CUSTOMER MAY WISH TO CONSIDER TAKING OUT AN INSURANCE POLICY OR OTHER FINANCIAL COVER FOR LOSS OR DAMAGE, WHICH MAY ARISE FROM LOSS OF DATA. SMSC CANNOT BE RESPONSIBLE FOR LOSS OF DATA. Change Information</p><p>Date Issue Author Description of changes July 18, 1.0 SMSC Initial version 2011 Team July 22, 1.1 SMSC Smartcard Reader Setup in ARM Platform 2011 Team July 25, 1.2 SMSC Debugging in Linux 2011 Team Oct 1.3 SMSC Formatting 10,2011 Team December 1.4 Remove ldconfig in ARM setup 20,2011 Table of Contents 1 Introduction This document explains the installation of SEC1110/SEC1210CCID reader in Linux on different platforms.</p><p>1.1 Smartcard reader installation under Linux x86 The below described setup was done using Fedora 14 with kernel version 2.6.35.6- 45</p><p>1.1.1 Required Libraries</p><p>The following libraries are prerequisite to install a USB smartcard reader under Linux x86. 1. libusb 1.0.8 2. pcsc-tools 3. libpcsc-lite 4. libccid</p><p>Following are the dependencies for the installation of above libraries</p><p>1. gnu gcc,make 2. libudev 3. libtool 4. perl-Gtk2</p><p>1.1.2 libusb-1.0.8 Obtain the libusb package from sourceforge.net/projects/libusb/ % tar xvjf libusb-1.0.8.tar.bz2 % cd libusb-1.0.8</p><p>%su #As ROOT perform % ./configure % make % make install</p><p>Note: 1. There is a limitation in using SMSC’s Dual Slot Reader with libusb where the slot with card always present is not accessible or simply stated, the second interface of the reader is not accessible. The limitation is not noticed when tested with pcsclite-1.7.4 compiled using libudev enabled and libusb disabled.</p><p>2. The author has added support for libudev since pcsclite -1.6.8, while removing libhal. http://ludovicrousseau.blogspot.com/2011/02/pcscd-now-uses-libudev-instead- of.html 1.1.3 libudev-dev</p><p>In case of a Fedora system Install libudev development files as</p><p>%yum install libudev-devel</p><p>Or in case of Ubuntu use</p><p>%sudo apt-get install libudev-dev</p><p>1.1.4 pcsc-lite Obtain tar file for the pcsc-lite version 1.7.4 from https://alioth.debian.org/frs/?group_id=30105</p><p>% tar xvjf pcsc-lite-1.7.4.tar.bz2 % cd pcsc-lite-1.7.4</p><p>%su #As ROOT perform % ./configure –enable-libusb –disable-libudev --enable-debugatr % make % make install</p><p>In case of following with section2.1.3 use below configuration</p><p>% ./configure –enable-libudev –disable-libusb --enable-debugatr % make % make install</p><p>1.1.5 pcsc-tools Obtain tar file for pcsc-tools from http://ludovic.rousseau.free.fr/softwares/pcsc-tools/pcsc-tools-1.4.17.tar.gz % tar xvf pcsc-tools-1.4.17.tar.gz % cd pcsc-tools-1.4.17 %su #As ROOT perform % ./configure % make % make install 1.1.6 CCID free software driver Obtain a copy of the free driver ccid-1.4.4.tar.bz2 from http://pcsclite.alioth.debian.org/ccid.html</p><p>% tar xvjf ccid-1.4.4.tar.bz2 % cd ccid-1.4.4 % cd readers</p><p>Here is present a file “supported_readers.txt” containing the list of supported readers. SMSC's smart card reader USX101x needs to be added to this list along with its VID and PID. Add the following at the end of the “supported_readers.txt” for SMSC device to be detected as smartcard reader.</p><p>For Single Slot device # SMSC 0x0424:0x1104:USX101x SmartCard Reader</p><p>For Dual Slot device # SMSC 0x0424:0x1202:USX101x Dual Slot SmartCard Reader</p><p>Where 0x0424 Stands for SMSC’s VID and following value corresponds to the PID of the Device.</p><p>Now as ROOT do % ./configure % make % make install</p><p>1.1.7 perl-Gtk2 This dependency will be required to run the tools obtained using pcsc-tools. In Fedora use %su %yum install perl-Gtk2</p><p>1.1.8 Other Dependencies For other dependency library installation follow the general steps</p><p>% tar xvf library.tar.gz (or) % tar xvjf library.tar.bz2 % cd library As ROOT perform % ./configure % make % make install</p><p>1.1.9 OpenSC OpenSC is a tool that can be used to list the smartcard readers installed in a system. This tool can be installed manually as </p><p>% tar xvf opensc-0.12.0.tar.gz % cd opensc-0.12.0</p><p>%su #As ROOT perform % ./configure % make % make install</p><p>Note:A possible issue while running OpenSC after manual installation would be with accessing libpcsclite.so.In that case, follow the solution mentioned in OpenSC website http://www.opensc-project.org/opensc/wiki/FrequentlyAskedQuestions 2 Smart Card Reader Installation Under ARM Platform To Setup the SmartCard Reader on an embedded ARM platform we will be using a HOST Linux PC to Cross Compile the required libraries and then copy the compiled libraries and resources to the ARM device. In this Setup</p><p>HOST DEVICE : Ubuntu Linux 11.04 TARGET DEVICE : OpenRD Tasman System</p><p>2.1 Required Libraries and tools Create a directory to copy the libraries required for the cross compilation Toolchain.</p><p>% cd /home/smsc/Desktop/</p><p>% mkdir toolchain</p><p>Obtain the source tar bals for the libraries from their online repositories</p><p>1. libusb-1.0.8.tar.bz2</p><p>2. pcsc-lite 1.7.4.tar.bz2</p><p>3. ccid-1.4.4.tar.bz2</p><p>Copy these source files to our toolchain directory (/home/smsc/Desktop/toolchain/) from the place of Download. Copy OpenRD’s gcc compiler for their ARM platform from the given media to the toolchain directory</p><p>% cp /home/openrd/openrd-tasman-devkit-v1.0/openrd- tasman_host_swsupportpackage/linux/gcc.tar.bz2 /home/smsc/Desktop/toolchain/</p><p>% cd /home/smsc/Desktop/toolchain/</p><p>% tar -xjvf /home/smsc/Desktop/toolchain/gcc.tar.bz2 </p><p>Add this gcc location to the PATH environment variable</p><p>% export PATH=/home/smsc/Desktop/toolchain/gcc/bin: $PATH </p><p>Now Set the compiler variables to utilize the OpenRD compiler. % export CC=arm-none-linux-gnueabi-gcc AR= arm-none-linux-gnueabi -ar LD= arm-none-linux-gnueabi -ld STRIP= arm-none-linux-gnueabi-strip </p><p>The above variables CC, AR, LD, STRIP and the corresponding names will be present as executables in the declared PATH variable </p><p>2.2 Extract Libraries Libusb,Pcsclite,Ccid</p><p>Create a Separate Directory to install the cross-compiled toolchain.</p><p>% mkdir –p /home/smsc/Desktop/Target % cd /home/smsc/Desktop/Target</p><p>2.2.1 libusb-1.0.8 Obtain the libusb package from sourceforge.net/projects/libusb/ % tar xvjf libusb-1.0.8.tar.bz2 % cd libusb-1.0.8 %./configure --host=arm-none-linux-gnueabi --prefix=/usr % make %su #As ROOT perform % make install prefix=/home/smsc/Desktop/Target/</p><p>Now just make sure that the compiled library files support the ARM platform and not the host architecture i.e X86</p><p>Cd =/home/smsc/Desktop/Target/lib/ File lib*</p><p>The command output should show that the file is supported for ARM.</p><p>2.2.2 pcsc-lite</p><p>% tar xvjf pcsc-lite-1.7.4.tar.bz2 % cd pcsc-lite-1.7.4 % ./configure --host=arm-none-linux-gnueabi --prefix=/usr –enable-libusb –disable-libudev --enable-debugatr PKG_CONFIG_PATH==/home/smsc/Desktop/toolchain/OpenRD/l ib/pkg-config LIBUSB_CFLAGS=- I/home/smsc/Desktop/Target/include/libusb-1.0/ LIBUSB_LIBS=/home/smsc/Desktop/Target/lib/libusb-1.0.so % make % make install prefix=/home/smsc/Desktop/Target/</p><p>Check the compatibility for ARM as done before</p><p>2.2.3 CCID free software driver Obtain a copy of the free driver ccid-1.4.4.tar.bz2 from http://pcsclite.alioth.debian.org/ccid.html .</p><p>% tar xvjf ccid-1.4.4.tar.bz2 % cd ccid-1.4.4 % cd readers</p><p>Here is present a file “supported_readers.txt” containing the list of supported readers. SMSC's smart card reader USX101x needs to be added to this list along with its VID and PID. Add the following at the end of the “supported_readers.txt” for SMSC device to be detected as smartcard reader.</p><p># SMSC 0x0424:0x1011:USX101x SmartCard Reader 0x0424:0x1200:USX101x Dual Slot SmartCard Reader</p><p>Where 0x0424 Stands for SMSC’s VID and following value corresponds to the PID of the Device.</p><p>%cd /home/smsc/Desktop/toolchain/ccid-1.4.4</p><p>% ./configure --host=arm-none-linux-gnueabi –prefi x=/usr PCSC_CFLAGS=- I/home/smsc/Desktop/Target/include/PCSC/ LIBUSB_CFLAGS=- I/home/smsc/Desktop/Target/include/libusb-1.0/ LIBUSB_LIBS=/home/smsc/Desktop/Target/lib/libusb- 1.0.so --enable- usbdropdir=/home/smsc/Desktop/Target/lib/drivers PCSC_LIBS=/home/smsc/Desktop/Target/lib/libpcsclite.so .1.0.0</p><p>//(Kindly check NOTE: in section2.3 method1)</p><p>% make % make install prefix=/home/smsc/Desktop/Target/ Check the compatibility for ARM as done before .Also check for the driver file at /home/smsc/Desktop/Target//lib/drivers/ifd- ccid.bundle/Contents/Linux/libccid.so</p><p>2.3 Copying the Installed Libraries to the ARM Device:</p><p>The Directory used as prefix in the library configuration will now hold the following cross compiled Resources</p><p>/home/smsc/Desktop/Target/lib /home/smsc/Desktop/Target/include /home/smsc/Desktop/Target/sbin /home/smsc/Desktop/Target/share</p><p>The contents of these directories now need to be copied to their corresponding directories in the ARM device as follows /usr/include /usr/lib /usr/share /usr/sbin</p><p>To copy the compiled libraries from the host to OpenRD ,two methods can be followed</p><p>Method 1: Tar the folder containing the libraries in the host and copy to the OpenRD using a USB storage device and untar the file To create a tar file of the location /home/smsc/Desktop/Target type..</p><p>%tar cvjf tools.bzip2 /home/smsc/Desktop/Target</p><p>%cp –f /home/smsc/Desktop/Target/tools.bzip2 /media/pendrive</p><p>Move the pendrive to the OpenRD system and mount it </p><p>%cp –f /media/pendrive/tools.bzip2 /home/openrd/Desktop</p><p>%cd /home/openrd/Desktop</p><p>%tar xvjf tools.bzip2</p><p>%cd Target %cp –fr include/ /usr/ %cp –fr /lib /usr/ %cp –fr /sbin /usr/</p><p>The current method of setup requires a copy of the driver “libccid.so” to be copied in the same directory structure as in the host. So Create the below directory</p><p>%mkdir -p /home/smsc/Desktop/Target/lib/pcsc/drivers/ifd- ccid.bundle/Contents/Linux/</p><p>Now make a copy of the libccid.so file created in section3.2.3 to the new directory</p><p>Note: this can be overcome while cross-compiling ccid-1.4.4 , by changing the flag </p><p>--enable-usbdropdir=/usr/lib/pcsc/drivers/ifd- ccid.bundle/Contents/Linux/</p><p>And copy the libccid.so to the OpenRD </p><p>Method2: If tar is not possible,simply copy the directory </p><p>/home/smsc/Desktop/Target</p><p>While doing so an error like “the filesystem does not support copying symbolic links”, may be posted if the pendrive is in FAT filesystem. This can be resolved later. Now copy the libraries to the corresponding directory structure in OpenRD</p><p>%cd Target %cp –fr include/ /usr/ %cp –fr /lib /usr/ %cp –fr /sbin /usr/</p><p>Now to resolve the missing symbolic links</p><p>%cd /usr/lib %ln -s libusb-1.0.so.0.0.0 libusb-1.0.so.0</p><p>%ln -s libusb-1.0.so.0.0.0 libusb-1.0.so</p><p>2.4 Setup In ARM Summary</p><p>1. Setup a Host Linux System for Cross Compilation using gcc provided by OpenRD 2. Obtain the source tars for the Libraries required to setup a smart reader.</p><p>3. Configure using –host=arm-none-linux-gnueabi and Cross Compile the Libraries to a separate directory</p><p>4. Move the cross compiled resources from the created directory to the target ARM device.</p><p>3 Cross Compilation for Making FileSystem Image</p><p>%mkdir –p /home/openrd/Debian_Lenny_OpenRD-Tasman</p><p>Obtain the FileSystem source Tar file to /home/openrd</p><p>%cd /home/openrd/Debian_Lenny_OpenRD-Tasman</p><p>Extract the FileSystem source tar Debian_Lenny_OpenRD-Tasman.tar.gz here</p><p>%tar xvf /home/openrd/Debian_Lenny_OpenRD- Tasman.tar.gz /home/openrd/Debian_Lenny_OpenRD-Tasman</p><p>%export INSTALL_PATH=/home/openrd/Debian_Lenny_OpenRD- Tasman/</p><p>Follow Section 3.1 to setup gcc cross compiler</p><p>3.1.1 libusb-1.0.8 Obtain the libusb package from sourceforge.net/projects/libusb/ </p><p>% tar xvjf libusb-1.0.8.tar.bz2 % cd libusb-1.0.8 % . /configure --host=arm-none-linux-gnueabi --prefix=/usr </p><p>% make %su #As ROOT perform % make install DESTDIR=$( INSTALL_PATH)</p><p>3.1.2 pcsc-lite</p><p>% tar xvjf pcsc-lite-1.7.4.tar.bz2 % cd pcsc-lite-1.7.4</p><p>%./configure --host=arm-none-linux-gnueabi --prefix=/usr --enable-libusb --disable-libudev --enable-debugatr LIBUSB_CFLAGS=-I$( INSTALL_PATH)/usr/include/libusb-1.0 LDFLAGS=-L$( INSTALL_PATH)/usr/lib/ LIBUSB_LIBS=-lusb-1.0 </p><p>% make %make install DESTDIR=$( INSTALL_PATH)</p><p>3.1.3 CCID free software driver Obtain a copy of the free driver ccid-1.4.4.tar.bz2 from http://pcsclite.alioth.debian.org/ccid.html .</p><p>% tar xvjf ccid-1.4.4.tar.bz2 % cd ccid-1.4.4</p><p>%./configure --host=arm-none-linux-gnueabi --prefix=/usr LIBUSB_CFLAGS=-I$( INSTALL_PATH)/usr/include/libusb-1.0 LDFLAGS=-L$( INSTALL_PATH)/usr/lib/ LIBUSB_LIBS=-lusb-1.0 PCSC_CFLAGS=-I$( INSTALL_PATH)/usr/include/PCSC/ --enable-usbdropdir=/usr/lib/pcsc/drivers PCSC_LIBS=-lpcsclite</p><p>% make %make install DESTDIR=$( INSTALL_PATH)</p><p>3.1.4 Building the UBI FileSystem Image</p><p>Once the above libraries have been installed in the filesystem directory, follow the steps to build the Filesystem image using MTD-Utils as documented by OpenRD. The resulting build image will need to be flashed onto the OpenRD Flash memory ,the steps for which are provided by OpenRD documentation.</p><p>4 Debugging in Linux</p><p>4.1 USB Traces</p><p>Sometimes getting a USB bus trace is required to debug field issues. Some of the manufacturers of USB analyzers have been listed below:</p><p>Ellisys, LeCroy</p><p>4.2 PCSCD debug log 1. Check whether pcscd is running or not. Use command “ps –ef | grep pcscd”. If it lists any running pcscd, stop the process using the command “service pcscd stop”.</p><p>2. Start logging using the command “tail –f /var/log/messages > debuglog.txt”</p><p>3. Open a new command terminal and run pcscd in debug mode using command “pcscd –df”. All debug messages will be available in a text file named debuglog.txt in current directory.</p><p>4. After the issue scenario has been simulated, stop the logging by pressing ctrl+c in the terminal where “tail -...” is running.</p><p>5 Appendix </p><p>5.1 SIM explorer for Linux-Fedora Install the following packages using yum install in Fedora</p><p>%yum install gtk-sharp2 libmono-system-runtime2.0-cil</p><p>%yum install monosim</p><p>Use a Smartcard to SIM adapter and insert a SIM card in it.</p><p>Launch monoSIM % monosim</p><p>Select Sim -> Connect to Sim Select SMSC smart card reader. The contacts stored in the SIM card can be viewed as shown below. 5.2 Scriptor - Perl script to send commands to a smart card scriptor is a program that sends commands to a smart card using a batch file or stdin. USAGE: scriptor [-h] [-r reader] [-p protocol] [file]</p><p>APDU Commands can be given from command line or a file can also be given instead of stdin to read commands (APDUs) </p><p>The commands are of the form: CLA INS P1 P2 Lc [data] [le].Commands need to be sent according to the type of the smart card.</p><p>Example: The below sequence of commands can be used on a Airtel SIM card </p><p>Method 1: From Command prompt. Step 1: [root@localhost Desktop]# scriptor –r “SMSC USX1011 Smart Card Reader (0123456789AF) 00 00 “ -p “T=0”</p><p>Note: If you get a response as shown below just re-run it .It is a utility issue.</p><p>Step 2: # reset the card reset Step 3: # Select MF 3F00 A0 A4 00 00 02 3F 00 Step 4: # Get Reponse # 16 is the value of second SW from the previous command A0 C0 00 00 16 Step 5:</p><p># Select DF Telecom (7F10) A0 A4 00 00 02 7F 10 </p><p>Method 2: Using Batch-file as input</p><p>Create a file having contents like below.</p><p># reset the card reset # Select MF 3F00 A0 A4 00 00 02 3F 00 # Get Reponse # 16 is the expected value of second SW from the previous command A0 C0 00 00 16 # Select DF Telecom (7F10) A0 A4 00 00 02 7F 10 </p><p>Save the file as file.txt (any file name).</p><p>Step1: root@localhost Desktop]# scriptor –r “SMSC USX1011 Smart Card Reader (0123456789AF) 00 00 “ -p “T=0” file.txt</p><p>This is the output from the Airtel simcard. Note: No need to worry about the error messages below. That is not the proper commands to the card.</p><p>5.3 CCID driver fix for Dual Slot Reader using Libusb</p><p>As mentioned in section 2.1.2, The Dual Slot reader does not enumerate properly with PCSC lite compiled using libusb.</p><p>This issue can be overcome by compiling the ccid driver with a type of hack in its source file CCID_USB.c</p><p>Locate the following code</p><p> r = libusb_claim_interface(dev_handle, interface); if (r < 0) { (void)libusb_close(dev_handle); DEBUG_CRITICAL4("Can't claim interface %d/%d: %d", bus_number, device_address, r); claim_failed = TRUE; interface_number = -1; continue; }</p><p>And make the change as</p><p> r = libusb_claim_interface(dev_handle, interface); if (r < 0) { interface=interface+1; r = libusb_claim_interface(dev_handle, interface); if(r<0) { (void)libusb_close(dev_handle); DEBUG_CRITICAL4("Can't claim interface %d/%d: %d", bus_number, device_address, r); claim_failed = TRUE; interface_number = -2; continue; } }</p><p>This code shall try to access the second interface which doesn’t happen in the actual driver.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    20 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us