Touchatag RFID Reader

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: No standard sections at all, this is mostly shell dumps, partially written in first person (Discuss in Talk:Touchatag RFID Reader)

Touchatag is a RFID Reader

About Touchatag

Touchatag is a RFID tag reader from Touchatag. It is a cheap set consisting of an ACR122U USB tag reader and MiFare Ultralight RFID tags.

It is available here.

Remember: Always put a tag on the reader, otherwise you might encounter problems!

Check hardware version

lsusb shows the device:

Bus 003 Device 004: ID 072f:2200 Advanced Card Systems, Ltd 

lsusb -v shows also the firmware version bcdDevice:

idVendor           0x072f Advanced Card Systems, Ltd
idProduct          0x2200 
bcdDevice            1.00

The Version this howto is about is the above ACS ACR122U PICC firmware 1.0.

Decide how you will access the tag reader

There are two options for connecting the tag reader to libnfc. Difference between them is detailed on stackoverflow.

The summary:

  • libnfc.driver.acr122_usb - Modern and recommended
  • libnfc.driver.acr122_pcsc - Legacy and deprecated

Using direct USB driver for the ACR122U

If you want to use acr122_usb you do NOT need to run the pcsc daemon (libnfc README currently tells you to run it, but this is for PC/SC way). Its enough to install libnfc and stop the conflicting drivers (nfc, pn533, pn533_usb) from loading.

This was verified with ACR122U firmware version (lsusb -v):

 idVendor           0x072f Advanced Card Systems, Ltd
 idProduct          0x2200 ACR122U
 bcdDevice            2.14

Prevent conflicting drivers from loading (blacklisting is not enough):

# echo "install nfc /bin/false" >> /etc/modprobe.d/blacklist.conf
# echo "install pn533 /bin/false" >> /etc/modprobe.d/blacklist.conf
# echo "install pn533_usb /bin/false" >> /etc/modprobe.d/blacklist.conf

Reload udev rules, unload these modules if they were loaded already

# rmmod pn533_usb
# rmmod pn533
# rmmod nfc

or simply reboot.

Then check that device is detected (nfc-list):

# nfc-list
nfc-list uses libnfc 1.7.1
NFC device: ACS / ACR122U PICC Interface opened

Actually reading nfc cards was tested to work as well (nfc-poll):

# nfc-poll 
nfc-poll uses libnfc 1.7.1
NFC reader: ACS / ACR122U PICC Interface opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
    ATQA (SENS_RES): 00  04  
       UID (NFCID1): 42  14  3e  2e  
      SAK (SEL_RES): 08  
Waiting for card removing...nfc_initiator_target_is_present: Target Released
done.

Read on for the second way of using PC/SC daemon to connect ACR122U to libnfc.

Disable pn533 and nfc driver in kernel

When the ACR122U is plugged in, kernel(>3.5) will automatically load the pn533 driver. With the pn533 driver, pcscd will report "Can't claim interface" error. use below command to disable pn533 and nfc driver in kernel.

The pn533 driver together with nfc driver is used by libnfc. This instruction is for using libpcsd-lite (Why not use libnfc, I cannot find any comparative information between libpcsclite and libnfc)

# echo "install nfc /bin/false" >> /etc/modprobe.d/blacklist.conf
# echo "install pn533 /bin/false" >> /etc/modprobe.d/blacklist.conf

Install Touchatag

First install ccid.

Test Touchatag

To test the device run:

# pcscd -f

If you encounter a problem like this:

ccid_usb.c:859:ccid_check_firmware() Firmware (1.00) is bogus! Upgrade the reader firmware or get a new reader.
ifdhandler.c:104:IFDHCreateChannelByName() failed
readerfactory.c:1050:RFInitializeReader() Open Port 200000 Failed (usb:072f/2200:libusb:006)
readerfactory.c:233:RFAddReader() ACS ACR122U PICC Interface init failed.

The libnfc README suggests to do this:

If your Touchatag or ACR122 device fails being detected by PCSC-lite daemon (pcsc_scan does not see anything) 
then try removing the bogus firmware detection of libccid: edit libccid_Info.plist configuration file 
(usually /etc/libccid_Info.plist) and locate "<key>ifdDriverOptions</key>", turn "<string>0x0000</string>" 
value into 0x0004 to allow bogus devices and restart pcscd daemon.

Warning: if you use ACS CCID drivers (acsccid), configuration file is located in something like: 
/usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist
or
/usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist

Optional: Test tags

Install pcsc-tools, start pcscd.service, then put a tag on the reader and try to scan with:

# pcsc_scan

You should get something like this:

PC/SC device scanner
V 1.4.17 (c) 2001-2009, Ludovic Rousseau <ludovic.rousseau@free.fr>
Compiled with PC/SC lite version: 1.6.6
Scanning present readers...
0: ACS ACR122U 00 00

Mon Mar 21 18:16:07 2011
 Reader 0: ACS ACR122U 00 00
  Card state: Card inserted, Shared Mode, 
  ATR: 3B BE 95 00 00 41 03 00 00 00 00 00 00 00 00 00 02 90 00 

ATR: 3B BE 95 00 00 41 03 00 00 00 00 00 00 00 00 00 02 90 00
+ TS = 3B --> Direct Convention
+ T0 = BE, Y(1): 1011, K: 14 (historical bytes)
  TA(1) = 95 --> Fi=512, Di=16, 32 cycles/ETU
    125000 bits/s at 4 MHz, fMax for Fi = 5 MHz => 156250 bits/s                                                                
  TB(1) = 00 --> VPP is not electrically connected
  TD(1) = 00 --> Y(i+1) = 0000, Protocol T = 0 
-----
+ Historical bytes: 41 03 00 00 00 00 00 00 00 00 00 02 90 00
  Category indicator byte: 41 (proprietary format) 

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B BE 95 00 00 41 03 00 00 00 00 00 00 00 00 00 02 90 00
        touchatag SAM card

Install tagEventor

tagEventor runs in the background and executes scripts when a tag enters or leaves your tag reader.

Download a binary version or compile your own.

Run tagEventor to test your installation:

# tagEventor -v 1

The scripts are located in /etc/gtagEventor. Read the tagEventor documentation on how to use them.