NSLU2 + PCSC HowTo v0.1

Preface

The aim of this howto is to provide some information how a USB smart card reader can be used through PCSC interface with Linksys NSLU2. Note: this information is basically outdated as now it is possible to install vanilla debian to NSLU and there are ready PCSC packages available there.

Prerequisite

It is assumed that you are somewhat familiar with compiling and installing software yourself. Also, the following items will be needed.

Installation

First, you will have to replace the original NSLU2 firmware with a more flexible one. Several alternatives are available and documented at http://www.nslu2-linux.org. I chose OpenSlug 3.10beta. (The instructions may apply to some extent with Unslug or Debian, too, but I can't guarantee anything.) The installation procedure is documented well in the site, so it won't handled here more. Following the the described installation procedure by the letter should give you a working OpenSlug system in less than 30 minutes.

Development environment

Now you should have the OpenSlug up and running. Time to install the tools needed to compile the smart card reader drivers. The compilation could probably be done with some other host, i.e., on your desktop computer, but it is still possible to do it natively on the NSLU2. The easiest way to do this is ipkg install openslug-native. This should install about everything needed to build your own software on the system. The following steps were also required to replace the busybox ar utility with a one enabling building your own libraries:
cd /usr/bin
rm ar
ln -s armeb-linux-ar ar

Drivers

Next we need to get the card reader working. Since I didn't want to open my NSLU2 to add a serial port, I chose to use a USB card reader. The linux support for PCSC is provided by PCSC-Lite. As there is no ready package available for OpenSlug, grab the source package pcsc-lite-1.x.x.tar.gz from here. Unpack it with tar xvfz pcsc-lite-1.x.x.tar.gz, enter the source code directory cd pcsc-lite-1.x.x, and configure the compilation ./configure --prefix=/usr/. Using the --prefix will install the library to the specified directory. If configure doesn't finish without errors, check what is missing and install the libraries or tools. They all should be available through ipkg. Then compile the thing with make and if everything went fine, install the library as root: make install. Now there should be the needed PSCS daemon in /usr/sbin/pcscd.

Time for the actual driver for the reader. It was not a surprise that the manufacturer provided linux drivers for x86, but not for arm (NSLU2). Luckily the CCID (Chip/Smart Card Interface Devices) free software driver supported my reader. (If your reader is not supported by the driver, then you have to try something else.) Again, download the source code ccid-1.x.x.tar.gz from here. Unpack, configure, compile and install with similar steps as the pcsc-lite.

Plug the reader to your NSLU2 and start the pcsc daemon as root: pcscd. That should be it.

Notes

The memory access of the X-Scale CPU in NSLU2 requires the addresses to be aligned (more info). Since this is not the case with some software, they will not work properly. Running them may seem to be ok, but the card access just doesn't work correctly (or they may crash). If you check dmesg, you will see that card access has generated a line starting with "Alignment trap...". This really should be corrected within software, but we can circumvent the problem as root by: echo 2 > /proc/cpu/alignment. This forces the system to fix the alignment problem while running, i.e., the faulty memory accesses are corrected. As such, this causes more work to the system, but in any case, it allows us to run the software. You probably want the pcscd to start automatically after boot. Also, the alignment "fix" will reset at boot time. Some automation for these may be added here at some point.


Valid HTML 4.01 Transitional paulus, 2007/04/30