Blog moved to

I moved my blog from to . Why? I wanted to move away from Blogger (owne...

Friday, July 30, 2010

pcsc-lite for limited (embedded) systems

Limited or embedded systems

Since Linux is working everywhere some of this everywhere is connected to a smart card reader. And of course pcsc-lite is used.

Example of embedded systems

I am not aware of any projects using pcsc-lite. I will just give two examples.

  • Android: see the seek for android project trying to bring a Smartcard API for Android
  • GCR5500: It is a health care reader for doctors, etc. It is also possible to connect a USB smart card reader and pcsc-lite is used to manage this external reader.
  • Many set top boxes (ADSL modem, home routers, etc.) are using Linux. Some of the boxes have a smart card reader.

Memory optimisations

Starting with pcsc-lite 1.6.0 I worked on memory optimizations. The work is not yet finished since I have other ideas.

Disable unused interfaces

I added --disable-serial and --disable-usb options to remove code that will not be used.

  • --disable-serial removes support of /etc/reader.conf.

    gain: 8.0kB of .text (12%) and 160 bytes of .bss (4%) for pcscd
  • --disable-usb removes support of USB hotplug

    gain: 9.7kB of .text (14%) and 960 bytes of .bss (23%) for pcscd

If you use both options (and use a static driver configuration) gain:
17.7kB of .text (26%) and 1152 bytes of .bss (28%) for pcscd

No logs

Since the embedded systems are not supposed to be directly administered having logs in /var/log/syslog is not useful.

  • Minimal pcsc_stringify_error()

    If NO_LOG is defined a minimal pcsc_stringify_error() is used. The function is still available but only the error code in hex is displayed in this case.

    Gain: 2kB of .text (10%) for libpcsclite

  • No log function

    If NO_LOG is defined then no log are displayed. The log functions are defined (they are also used by the drivers) but are empty.

    With NO_LOG defined we gain 26% (17 kB) for the .text segment of pcscd and 15% (4 kB) for the .text segment of (for i386)

One option to activate the embedded mode

Just use the --enable-embedded (default is no) configure option to build pcsc-lite for an embedded system. This will activate the NO_LOG option to disable logging and limit RAM and disk consumption.


If --enable-embedded is used and you disable the communication interface you do not use (serial or USB) you can expect a gain of 40% on the code size and then a reduced disk/flash space and memory used.

To be followed...