background image

...the world's most energy friendly microcontrollers

2014-01-23 - an0820_Rev1.00

11

www.silabs.com

a fixed length and a data field with variable length. Many of the messages consists only of the header.
Since the implementation in this application note only implements the T=0 protocol, the data field in the
USB messages typically map directly to the APDU-message going to/from the smart card.

A  detailed  description  of  the  CCID  standard  is  outside  the  scope  of  this  document.  For  detailed
description  of  the  CCID  Class  Descriptor,  exact  message  format,  status/error  codes  and  sequence
diagrams,  please  refer  to  the  specification,  (Reference  1  (p.  20)  ).  An  overview  of  some
implementation details, state-diagrams and sequence diagrams are given later in this chapter.

3.2 Connection of Smart Card to the STK

The EFM32 peripheral used for the physical layer is the USART which has a special 7816 smart card
mode to make the T=0 error detection and retransmission happen in hardware. An additional clock signal
is also required for the card, which is generated using a timer. As the serial communication is a single
line, half duplex, both the TX and the RX pins of the interface are tied together to the smart card I/O line,
this is done internally in the EFM32, using the loop back feature of the asynchronous serial interface.

According to ISO-7816 part 3, the nominal bit duration used on the I/O line is defined as one Elementary
Time  Unit  (ETU)  and  the  initial  ETU  is  1/9600  s.  For  simplicity  reasons,  only  the  9600  bps  speed  is
implemented. Further the bytes are transmitted using 8 data bits, 1 bit even parity and 1.5 stop bits, as
this matches the required format of the 7816 standard.

USART1  in  asynchronous  mode  is  used  and  TIMER0  provides  the  required  clock  signal.  The  clock
frequency is fixed to 3.5712 MHz which is the baud rate multiplied by 372. This is the default factor of
difference between baud rate and clock speed in the 7816 standard.

Further there is a reset pin and power pins allocated as well as a card-insertion detection pin. The 7816
standard defines that the card reader should physically power off the card if ordered to do so by the
host or if card-removal is detected.

The insertion detection pin is usually a separate electrical switch within the smart card socket. It is not
connected directly to the smart card. It is usually a normally closed switch, which opens when a smart
card is inserted all the way in the socket. In this example it is connected to both EFM32 GND and a
gpio-pin with a pull-up. When a card is inserted and the switch breaks the connection, it is expected that
this pin is pulled up. Therefore make sure to connect the other side of the insertion detection switch of
the card socket to EFM32-ground, not the GND pin of the smart card, as this can be tri-stated when
the card is not inserted.

All the pins used are located on the STK3700 expansion header, the exact pins used are described by
the following table:

Table 3.1. STK3700 Smart Card Pinout Description

EFM32GG990F1024

Smart Card Pin

Functionality

PD2

C3

CLK

Clock

PD0

C7

I/O line

TX/RX Serial Data

PD5

C2

Reset

Card reset

PD3

C1

V

cc

Card Power Supply

1

PD4

C5

GND

Ground pin of card

PD1

Insertion Detection

 

Insertion Detect Pin, high
side

GND

Insertion Detection

 

Insertion Detect Pin, low
side

1

In this application example, a GPIO pin is used directly as the card power supply, hence the card Vcc is limited to 3.3V. For 5V

cards, the same application can be used with GPIO pin driving a hardware switch that provides Vcc=5V to the card.

Summary of Contents for EFM32

Page 1: ...tocol of a smart card Along with this document there is a working example of a smart card reader implemented using the EFM32 The included software example implements a USB CCID card reader device using the STK3700 Giant Gecko Starter Kit The software example is developed and tested with an ACS Advanced Card Systems Ltd ACOS 1 3 type of smart card This application note includes This PDF document So...

Page 2: ... ISO 14443 and is available in a variety of form factors including plastic cards fobs SIM cards used in GSM mobile phones and USB tokens Smart cards are used in many applications worldwide including Secure ID employee ID badges citizen ID documents electronic passports driver s licenses online authentication devices Healthcare citizen health ID cards physician ID cards portable medical records car...

Page 3: ... and establishing a process that embeds the integrated circuit into the card 7816 2 Cards with contacts Dimensions and location of the contacts The following table contains the contact definition of the electrical contacts according to ISO7816 2 Table 2 1 Smart Card Electrical Connection Contact Designation Use C1 Vcc Power connection through which operating power is supplied to the microprocessor...

Page 4: ...card this application note will mainly relate to the electrical waveforms and transportation of messages described in part 3 and 4 of the standard These parts are discussed in detail in the following sections 2 2 Part 3 Electrical Signal and Transmission Protocol Communication with the smart card takes place over a single bi directional half duplex data line The voltage levels for high low states ...

Page 5: ...eleased ATR Received Vcc Clk Reset IO ATR Data Clock Running Wait 40 000 clock cycles 40 000 clock cycles 2 2 3 Byte Transfers During the power on and reset sequence the smart card answers with its Answer to Reset The transmission of this first data packet is carried out with default communication parameters listed below Baud rate Fclock 372 Clock should be approximately 3 57 MHz resulting in 9 6 ...

Page 6: ...the default protocol used during the ATR sequence T1 T2 TK optional historical characters these characters typically hold information about the card manufacturer type of card size etc version number and the state of the card TCK a conditional check character presence of this byte is indicated by the optional interface characters if present it is exclusive OR of all the bytes in the ATR excluding T...

Page 7: ...alled T 0 The name comes from the indication of this protocol in the ATR by having one of the bits in one of the T characters equal to 0 The block oriented protocol is called T 1 In fact there is even a T 2 protocol for full duplex interfaces with T 3 15 reserved for future protocols The T 0 protocol re uses the same byte transmission format used during the ATR sequence The parity error detection ...

Page 8: ...dicating that the reader should wait for further data or the smart card needs more processing time the SW1 is called a procedure byte indicating that it should not be forwarded to the host application as a response Figure 2 6 p 8 illustrates how transmission of a data packet to the smart card looks like following the T 0 protocol In fact for the T 0 protocol the bytes of the APDU directly overlays...

Page 9: ...nts in the T 0 protocol please see the 7816 standard Reference 4 p 20 2 3 3 T 1 Protocol Introduction The T 1 protocol is more complex than the T 0 protocol The physical interface is still half duplex and uses the same configuration as T 0 T 1 is actually built on top of T 0 but it does not use the T 0 error correction functionality rather it uses a block oriented protocol The main benefits of T 1...

Page 10: ...tocol handling the transmission of APDU packets between the card reader and the USB host The EFM32 implementation also includes the T 0 interface protocol for communication with the smart card itself From here on the EFM32 card reader is referred to as the CCID Figure 3 1 Smart Card USB CCID Device Class Standard USB CCID Device Class Standard EFM32 Smart Card Reader 3 1 USB CCID Standard The CCID...

Page 11: ...standard USART1 in asynchronous mode is used and TIMER0 provides the required clock signal The clock frequency is fixed to 3 5712 MHz which is the baud rate multiplied by 372 This is the default factor of difference between baud rate and clock speed in the 7816 standard Further there is a reset pin and power pins allocated as well as a card insertion detection pin The 7816 standard defines that th...

Page 12: ...k depending on host side smart card driver and software Since the firmware on the EFM32 itself is basically only shuffling data packets back and forth between the smart card and the host computer virtually any card supporting the correct speed and T 0 protocol should be able to communicate with the host computer 3 3 2 Software Algorithm The software algorithm is based on a simple state machine fun...

Page 13: ...ly power to the smart card and it expects the ATR in response The PowerOff message from the PC requests the CCID to power off the smart card and expects only a status message in return indicating the new powered off state All actual communication with the card after the Answer to Reset happens upon XfrBlock messages from the PC Each XfrBlock message contains one APDU which the CCID must send to th...

Page 14: ...Rev1 00 14 www silabs com Figure 3 4 Function Handling Command and Data Transfer with Smart Card Send Command Header CLA INS P1 P3 Wait for Procedure Byte from Card Send Receive Data to from Card Wait for SW1 SW2 and Return Yes If P Byte INS Yes No If P Byte NULL 0x60 No ...

Page 15: ...sed CCID If the procedure byte indicates that the smart card is ready to receive data the CCID proceeds with sending the data to the smart card It then waits for a further procedure byte Note that in the case of successful transaction the procedure byte is in fact the SW1 character and therefore part of the response expected from the host The CCID fetches the SW2 character as well and sends both S...

Page 16: ...ction with the addition of insertion and removal of the card Notice that the CCID does not power up the card until it receives a PowerOn messages from the host The CCID can implement automatic power on at insertion of a card but must then also advertise this feature in the USB descriptor When the card is removed the CCID should power off the card to protect from damage It advertises that the card ...

Page 17: ...out error as this will trigger a power off of the smart card which is always safe to do upon error conditions 3 5 Use the Smart Card Reader with a PC In order to make useful communication between a PC and the smart card happening the host computer need software that can interact with the card Typically a windows PC will recognize the card reader as a smart card interface device To get further spec...

Page 18: ...reenshot above demonstrates use of the windows certutil function to read the smart card answer to reset This will verify that the USBCCID device registered correctly with the Windows USBCCID driver The errors above is likely to pop up if the inserted card is not initialized and prepared for further certificate handling in Windows 3 6 Limitations There are some limitations with this implementation ...

Page 19: ...connected to the EFM32 which might make the implementation more prone to electrical faults There exists conditioning devices that can be connected between the mcu and the smart card which handles ESD signal conditioning and the different voltage levels in a proper manner see Figure 3 10 p 19 For further protection of the interface device and also adding support for different voltage levels a level...

Page 20: ... Rev 1 1 2005 http www usb org developers devclass_docs DWG_Smart Card_CCID_Rev110 pdf 2 Online version of ISO 7816 Standard http www cardwerk com smartcards smartcard_standard_ISO7816 aspx 3 Smart Cache Windows software tool for storing data on ACOS 1 3 smart cards http www smartcache net 4 The home of the ISO 7816 standard http www iso org 5 ACOS3 Smart Cards http www acs com hk en products 19 a...

Page 21: ... the world s most energy friendly microcontrollers 2014 01 23 an0820_Rev1 00 21 www silabs com 5 Revision History 5 1 Revision 1 00 2014 01 23 Initial revision ...

Page 22: ...n or fabricate any integrated circuits The products must not be used within any Life Support System without the specific written consent of Silicon Laboratories A Life Support System is any product or system intended to support or sustain life and or health which if it fails can be reasonably expected to result in significant personal injury or death Silicon Laboratories products are generally not...

Page 23: ...00 23 www silabs com B Contact Information Silicon Laboratories Inc 400 West Cesar Chavez Austin TX 78701 Please visit the Silicon Labs Technical Support web page http www silabs com support pages contacttechnicalsupport aspx and register to submit a technical support request ...

Page 24: ...tocol 4 2 3 Part 4 Commands and Exchange of Data Packets 6 3 EFM32 USB CCID Implementation 10 3 1 USB CCID Standard 10 3 2 Connection of Smart Card to the STK 11 3 3 Software Implementation 12 3 4 Typical Transaction Sequences 15 3 5 Use the Smart Card Reader with a PC 17 3 6 Limitations 18 4 References 20 5 Revision History 21 5 1 Revision 1 00 21 A Disclaimer and Trademarks 22 A 1 Disclaimer 22 ...

Page 25: ...sion for the T 0 Protocol 9 3 1 Smart Card USB CCID Device Class Standard 10 3 2 Physical Connection of Card Socket with EFM32 Starterkit 12 3 3 Card Detection and Notification Interrupt 13 3 4 Function Handling Command and Data Transfer with Smart Card 14 3 5 Host Sends Data to Card 15 3 6 Host Requests and Receives Data from Card 16 3 7 Sequence with Card Insertion Removal and Simple Command 17 ...

Page 26: ... the world s most energy friendly microcontrollers 2014 01 23 an0820_Rev1 00 26 www silabs com List of Tables 2 1 Smart Card Electrical Connection 3 3 1 STK3700 Smart Card Pinout Description 11 ...

Page 27: ......

Reviews: