Introduction - Microchip Technology
Application NoteSEC1110/SEC1210- Linux SetupDocument Code: Version: 1.2Date: July 25, 201133889955447030 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.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.2107 North First Street, Suite 660San Jose, California 95131Phone: 1-408-441-0455Fax: 1-408-441-0463Corporate Headquarters80 Arkay DriveHauppauge, NY 11788Telephone: 1-631-435-6000-114300184150 Change InformationDateIssueAuthorDescription of changesJuly 18, 20111.0SMSC TeamInitial versionJuly 22, 20111.1SMSCTeamSmartcard Reader Setup in ARM PlatformJuly 25, 20111.2SMSCTeamDebugging in LinuxOct 10,20111.3SMSC TeamFormattingDecember 20,20111.4Remove ldconfig in ARM setupTable of Contents TOC \o "1-4" \h \z 1Introduction PAGEREF _Toc300049008 \h 52Smartcard reader installation under Linux x86 PAGEREF _Toc300049009 \h 62.1.1Required Libraries PAGEREF _Toc300049010 \h 62.1.2libusb-1.0.8 PAGEREF _Toc300049011 \h 62.1.3libudev-dev PAGEREF _Toc300049012 \h 62.1.4pcsc-lite PAGEREF _Toc300049013 \h 72.1.5pcsc-tools PAGEREF _Toc300049014 \h 72.1.6CCID free software driver PAGEREF _Toc300049015 \h 72.1.7perl-Gtk2 PAGEREF _Toc300049016 \h 82.1.8Other Dependencies PAGEREF _Toc300049017 \h 82.1.9OpenSC PAGEREF _Toc300049018 \h 83Smart Card Reader Installation Under ARM Platform PAGEREF _Toc300049019 \h 103.1Required Libraries and tools PAGEREF _Toc300049020 \h 103.2Extract Libraries Libusb,Pcsclite,Ccid PAGEREF _Toc300049021 \h 113.2.1libusb-1.0.8 PAGEREF _Toc300049022 \h 113.2.2pcsc-lite PAGEREF _Toc300049023 \h 113.2.3CCID free software driver PAGEREF _Toc300049024 \h 123.3Copying the Installed Libraries to the ARM Device: PAGEREF _Toc300049025 \h 123.4Setup In ARM Summary PAGEREF _Toc300049026 \h 134Cross Compilation for Making FileSystem Image PAGEREF _Toc300049027 \h 134.1.1libusb-1.0.8 PAGEREF _Toc300049028 \h 144.1.2pcsc-lite PAGEREF _Toc300049029 \h 144.1.3CCID free software driver PAGEREF _Toc300049030 \h 154.1.4Building the UBI FileSystem Image PAGEREF _Toc300049031 \h 155Debugging in Linux PAGEREF _Toc300049032 \h 155.1USB Traces PAGEREF _Toc300049033 \h 155.2PCSCD debug log PAGEREF _Toc300049034 \h 156Appendix PAGEREF _Toc300049035 \h 166.1SIM explorer for Linux-Fedora PAGEREF _Toc300049036 \h 166.2Scriptor - Perl script to send commands to a smart card PAGEREF _Toc300049037 \h 19IntroductionThis document explains the installation of SEC1110/SEC1210CCID reader in Linux on different platforms.Smartcard reader installation under Linux x86The below described setup was done using Fedora 14 with kernel version 2.6.35.6-45Required LibrariesThe following libraries are prerequisite to install a USB smartcard reader under Linux x86.libusb 1.0.8pcsc-toolslibpcsc-litelibccidFollowing are the dependencies for the installation of above librariesgnu gcc,makelibudevlibtoolperl-Gtk2libusb-1.0.8Obtain the libusb package from projects/libusb/ % tar xvjf libusb-1.0.8.tar.bz2% cd libusb-1.0.8%su #As ROOT perform% ./configure% make% make installNote: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.2. The author has added support for libudev since pcsclite -1.6.8, while removing libhal. case of a Fedora system Install libudev development files as%yum install libudev-develOr in case of Ubuntu use%sudo apt-get install libudev-devpcsc-liteObtain tar file for the pcsc-lite version 1.7.4 from tar xvjf pcsc-lite-1.7.4.tar.bz2% cd pcsc-lite-1.7.4%su #As ROOT perform% ./configure –enable-libusb –disable-libudev --enable-debugatr% make% make installIn case of following with section2.1.3 use below configuration% ./configure –enable-libudev –disable-libusb --enable-debugatr% make% make installpcsc-toolsObtain tar file for pcsc-tools from tar xvf pcsc-tools-1.4.17.tar.gz% cd pcsc-tools-1.4.17%su #As ROOT perform% ./configure% make% make installCCID free software driverObtain a copy of the free driver ccid-1.4.4.tar.bz2 from % tar xvjf ccid-1.4.4.tar.bz2% cd ccid-1.4.4% cd readersHere 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.For Single Slot device# SMSC0x0424:0x1104:USX101x SmartCard ReaderFor Dual Slot device# SMSC0x0424:0x1202:USX101x Dual Slot SmartCard ReaderWhere 0x0424 Stands for SMSC’s VID and following value corresponds to the PID of the Device.Now as ROOT do% ./configure% make% make installperl-Gtk2This dependency will be required to run the tools obtained using pcsc-tools.In Fedora use%su%yum install perl-Gtk2Other DependenciesFor other dependency library installation follow the general steps% tar xvf library.tar.gz (or) % tar xvjf library.tar.bz2% cd libraryAs ROOT perform% ./configure% make% make installOpenSCOpenSC is a tool that can be used to list the smartcard readers installed in a system. This tool can be installed manually as % tar xvf opensc-0.12.0.tar.gz% cd opensc-0.12.0%su#As ROOT perform% ./configure% make% make installNote: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 Card Reader Installation Under ARM PlatformTo 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 SetupHOST DEVICE:Ubuntu Linux 11.04TARGET DEVICE: OpenRD Tasman SystemRequired Libraries and toolsCreate a directory to copy the libraries required for the cross compilation Toolchain.% cd /home/smsc/Desktop/% mkdir toolchainObtain the source tar bals for the libraries from their online repositories1. libusb-1.0.8.tar.bz22. pcsc-lite 1.7.4.tar.bz23. ccid-1.4.4.tar.bz2Copy 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% cp /home/openrd/openrd-tasman-devkit-v1.0/openrd-tasman_host_swsupportpackage/linux/gcc.tar.bz2 /home/smsc/Desktop/toolchain/% cd /home/smsc/Desktop/toolchain/% tar -xjvf /home/smsc/Desktop/toolchain/gcc.tar.bz2 Add this gcc location to the PATH environment variable% export PATH=/home/smsc/Desktop/toolchain/gcc/bin:$PATH 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 The above variables CC, AR, LD, STRIP and the corresponding names will be present as executables in the declared PATH variable Extract Libraries Libusb,Pcsclite,CcidCreate a Separate Directory to install the cross-compiled toolchain.% mkdir –p /home/smsc/Desktop/Target% cd /home/smsc/Desktop/Targetlibusb-1.0.8Obtain the libusb package from 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/Now just make sure that the compiled library files support the ARM platform and not the host architecture i.e X86Cd =/home/smsc/Desktop/Target/lib/File lib*The command output should show that the file is supported for ARM.pcsc-lite% 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/lib/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/Check the compatibility for ARM as done beforeCCID free software driverObtain a copy of the free driver ccid-1.4.4.tar.bz2 from . % tar xvjf ccid-1.4.4.tar.bz2% cd ccid-1.4.4% cd readersHere 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.# SMSC0x0424:0x1011:USX101x SmartCard Reader0x0424:0x1200:USX101x Dual Slot SmartCard ReaderWhere 0x0424 Stands for SMSC’s VID and following value corresponds to the PID of the Device.%cd /home/smsc/Desktop/toolchain/ccid-1.4.4% ./configure --host=arm-none-linux-gnueabi –prefix=/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//(Kindly check NOTE: in section2.3 method1)% 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.soCopying the Installed Libraries to the ARM Device:The Directory used as prefix in the library configuration will now hold the following cross compiled Resources/home/smsc/Desktop/Target/lib/home/smsc/Desktop/Target/include/home/smsc/Desktop/Target/sbin/home/smsc/Desktop/Target/shareThe 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/sbinTo copy the compiled libraries from the host to OpenRD ,two methods can be followedMethod 1:Tar the folder containing the libraries in the host and copy to the OpenRD using a USB storage device and untar the fileTo create a tar file of the location /home/smsc/Desktop/Target type..%tar cvjf tools.bzip2 /home/smsc/Desktop/Target%cp –f /home/smsc/Desktop/Target/tools.bzip2 /media/pendriveMove the pendrive to the OpenRD system and mount it %cp –f /media/pendrive/tools.bzip2 /home/openrd/Desktop%cd /home/openrd/Desktop%tar xvjf tools.bzip2%cd Target%cp –fr include/ /usr/%cp –fr /lib/usr/%cp –fr /sbin /usr/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%mkdir -p /home/smsc/Desktop/Target/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/Now make a copy of the libccid.so file created in section3.2.3 to the new directoryNote: this can be overcome while cross-compiling ccid-1.4.4 , by changing the flag --enable-usbdropdir=/usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/And copy the libccid.so to the OpenRD Method2:If tar is not possible,simply copy the directory /home/smsc/Desktop/TargetWhile 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%cd Target%cp –fr include/ /usr/%cp –fr /lib/usr/%cp –fr /sbin /usr/Now to resolve the missing symbolic links%cd /usr/lib%ln -s libusb-1.0.so.0.0.0 libusb-1.0.so.0%ln -s libusb-1.0.so.0.0.0 libusb-1.0.soSetup In ARM Summary1. Setup a Host Linux System for Cross Compilation using gcc provided by OpenRD2. Obtain the source tars for the Libraries required to setup a smart reader.3. Configure using –host=arm-none-linux-gnueabi and Cross Compile the Libraries to a separate directory4. Move the cross compiled resources from the created directory to the target ARM device.Cross Compilation for Making FileSystem Image%mkdir –p /home/openrd/Debian_Lenny_OpenRD-TasmanObtain the FileSystem source Tar file to /home/openrd%cd /home/openrd/Debian_Lenny_OpenRD-TasmanExtract the FileSystem source tar Debian_Lenny_OpenRD-Tasman.tar.gz here%tar xvf /home/openrd/Debian_Lenny_OpenRD-Tasman.tar.gz /home/openrd/Debian_Lenny_OpenRD-Tasman%export INSTALL_PATH=/home/openrd/Debian_Lenny_OpenRD-Tasman/Follow Section 3.1 to setup gcc cross compilerlibusb-1.0.8Obtain the libusb package from 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 DESTDIR=$( INSTALL_PATH)pcsc-lite% 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 LIBUSB_CFLAGS=-I$( INSTALL_PATH)/usr/include/libusb-1.0LDFLAGS=-L$( INSTALL_PATH)/usr/lib/ LIBUSB_LIBS=-lusb-1.0 % make%make install DESTDIR=$( INSTALL_PATH)CCID free software driverObtain a copy of the free driver ccid-1.4.4.tar.bz2 from . % tar xvjf ccid-1.4.4.tar.bz2% cd ccid-1.4.4%./configure --host=arm-none-linux-gnueabi --prefix=/usr LIBUSB_CFLAGS=-I$( INSTALL_PATH)/usr/include/libusb-1.0LDFLAGS=-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% make%make install DESTDIR=$( INSTALL_PATH)Building the UBI FileSystem ImageOnce 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.Debugging in Linux USB TracesSometimes getting a USB bus trace is required to debug field issues.Some of the manufacturers of USB analyzers have been listed below:Ellisys, LeCroyPCSCD debug logCheck 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”.Start logging using the command “tail –f /var/log/messages > debuglog.txt”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.After the issue scenario has been simulated, stop the logging by pressing ctrl+c in the terminal where “tail -...” is running.Appendix SIM explorer for Linux-FedoraInstall the following packages using yum install in Fedora%yum install gtk-sharp2 libmono-system-runtime2.0-cil%yum install monosimUse a Smartcard to SIM adapter and insert a SIM card in it.Launch monoSIM % monosimSelect Sim -> Connect to SimSelect SMSC smart card reader.The contacts stored in the SIM card can be viewed as shown below.Scriptor - Perl script to send commands to a smart cardscriptor is a program that sends commands to a smart card using a batch file or stdin.USAGE: scriptor [-h] [-r reader] [-p protocol] [file]APDU Commands can be given from command line or a file can also be given instead of stdin to read commands (APDUs) 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.Example: The below sequence of commands can be used on a Airtel SIM card Method 1: From Command prompt.Step 1:[root@localhost Desktop]# scriptor –r “SMSC USX1011 Smart Card Reader (0123456789AF) 00 00 “ -p “T=0”Note:If you get a response as shown below just re-run it .It is a utility issue.Step 2:# reset the cardreset Step 3:# Select MF 3F00A0 A4 00 00 02 3F 00 Step 4:# Get Reponse# 16 is the value of second SW from the previous commandA0 C0 00 00 16 Step 5:# Select DF Telecom (7F10)A0 A4 00 00 02 7F 10 Method 2: Using Batch-file as inputCreate a file having contents like below.# reset the cardreset# Select MF 3F00A0 A4 00 00 02 3F 00 # Get Reponse# 16 is the expected value of second SW from the previous commandA0 C0 00 00 16# Select DF Telecom (7F10)A0 A4 00 00 02 7F 10 Save the file as file.txt (any file name).Step1:root@localhost Desktop]# scriptor –r “SMSC USX1011 Smart Card Reader (0123456789AF) 00 00 “ -p “T=0” file.txtThis 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 ID driver fix for Dual Slot Reader using LibusbAs mentioned in section 2.1.2, The Dual Slot reader does not enumerate properly with PCSC lite compiled using libusb.This issue can be overcome by compiling the ccid driver with a type of hack in its source file CCID_USB.cLocate the following coder = 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;}And make the change asr = 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;}}This code shall try to access the second interface which doesn’t happen in the actual driver. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
Related searches
- introduction to financial management pdf
- letter of introduction sample
- microchip tool tracking gps systems
- technology etfs best technology etfs
- found animals microchip registry reset
- introduction about technology essay
- information technology introduction pdf
- introduction to technology textbook pdf
- introduction to information technology notes
- introduction to information technology textbook
- introduction to information technology pdf
- introduction to technology concepts