2016-04-08 10:49:28 +02:00
```
2010-12-13 12:58:04 +01:00
*-
2013-03-10 16:15:23 +01:00
* Free/Libre Near Field Communication (NFC) library
2016-04-08 10:49:28 +02:00
*
2013-03-10 16:15:23 +01:00
* Libnfc historical contributors:
* Copyright (C) 2009 Roel Verdult
2015-04-15 17:11:11 +02:00
* Copyright (C) 2009-2015 Romuald Conty
2013-03-10 16:15:23 +01:00
* Copyright (C) 2010-2012 Romain Tartière
* Copyright (C) 2010-2013 Philippe Teuwen
* Copyright (C) 2012-2013 Ludovic Rousseau
* Additional contributors:
* See AUTHORS file
2010-12-13 12:58:04 +01:00
-*
2016-04-08 10:49:28 +02:00
```
2010-12-13 12:58:04 +01:00
General Information
===================
libnfc is a library which allows userspace application access to NFC devices.
The official web site is:
2013-01-31 21:58:29 +01:00
http://www.nfc-tools.org/
2010-12-13 12:58:04 +01:00
The official forum site is:
http://www.libnfc.org/community/
The official development site is:
2015-04-30 14:19:03 +02:00
https://github.com/nfc-tools/libnfc
2010-12-13 12:58:04 +01:00
2016-12-06 17:44:31 +01:00
Important note: this file covers POSIX systems, for Windows please read README-Windows.md
2011-02-07 13:31:08 +01:00
2011-03-06 13:00:33 +01:00
Requirements
============
2013-01-31 21:58:29 +01:00
Some NFC drivers depend on third party software:
2011-03-06 13:00:33 +01:00
2013-01-31 16:44:37 +01:00
* pn53x_usb & acr122_usb:
2020-04-09 05:29:11 +02:00
- libusb-0.1 http://libusb.sf.net
2011-03-06 13:00:33 +01:00
2013-01-31 16:44:37 +01:00
* acr122_pcsc:
2020-04-09 05:29:11 +02:00
2021-01-22 13:08:21 +01:00
- pcsc-lite https://pcsclite.apdu.fr/
2020-04-09 05:29:11 +02:00
- pcsc:
- Support build with pcsc driver, which can be using all compatible readers, Feitian R502 and bR500 already passed the test.
2011-03-06 13:00:33 +01:00
2013-01-31 21:58:29 +01:00
The regression test suite depends on the cutter framework:
2011-03-06 13:00:33 +01:00
http://cutter.sf.net
2021-06-09 14:40:25 +02:00
Building
========
Note: If working directly from a git clone of the repository, some of the files need to be generated first. To do this run
2021-09-20 08:03:57 +02:00
`autoreconf -vis`
2021-06-09 14:40:25 +02:00
Alternatively use a .tar.bz2 version of a packaged release (which already contains ./configure):
https://github.com/nfc-tools/libnfc/releases/
The build should be as simple as running these commands:
./configure
make
To build with specific driver(s), see option `--with-drivers=...` detailed in `./configure --help` .
2010-12-13 12:58:04 +01:00
Installation
============
2021-06-09 14:40:25 +02:00
make install
2010-12-13 12:58:04 +01:00
2021-06-09 14:40:25 +02:00
You may need to grant permissions to your user to drive your device.
2012-10-04 12:12:53 +02:00
Under GNU/Linux systems, if you use udev, you could use the provided udev rules.
e.g. under Debian, Ubuntu, etc.
2016-04-08 10:49:28 +02:00
2017-02-15 00:47:27 +01:00
sudo cp contrib/udev/93-pn53x.rules /lib/udev/rules.d/
2012-10-04 12:12:53 +02:00
Under FreeBSD, if you use devd, there is also a rules file: contrib/devd/pn53x.conf.
2010-12-13 12:58:04 +01:00
2015-04-15 17:11:11 +02:00
Configuration
=============
In order to change the default behavior of the library, the libnfc uses a
configuration file located in sysconfdir (as provided to ./configure).
A sample commented file is available in sources: libnfc.conf.sample
If you have compiled using:
2016-04-08 10:49:28 +02:00
./configure --prefix=/usr --sysconfdir=/etc
2015-04-15 17:11:11 +02:00
you can make configuration directory and copy the sample file:
2016-04-08 10:49:28 +02:00
sudo mkdir /etc/nfc
sudo cp libnfc.conf.sample /etc/nfc/libnfc.conf
2015-04-15 17:11:11 +02:00
To configure multiple devices, you can either modify libnfc.conf or create a
file per device in a nfc/devices.d directory:
2016-04-08 10:49:28 +02:00
sudo mkdir -p /etc/nfc/devices.d
printf 'name = "My first device"\nconnstring = "pn532_uart:/dev/ttyACM0"\n' | sudo tee /etc/nfc/devices.d/first.conf
printf 'name = "My second device"\nconnstring = "pn532_uart:/dev/ttyACM1"\n' | sudo tee /etc/nfc/devices.d/second.conf
2015-04-15 17:11:11 +02:00
2023-02-15 13:33:20 +01:00
Environment Variables
=====================
You can override certain configuration options at runtime using the following environment variables:
+ `LIBNFC_DEFAULT_DEVICE=<connstring>` : `LIBNFC_DEFAULT_DEVICE=pn532_uart:/dev/ttyACM0` will use pn532 on /dev/ttyACM0 as default device
+ `LIBNFC_DEVICE=<connstring>` will ignore all devices in the config files and use only the one defined in the variable
+ `LIBNFC_AUTO_SCAN=<true|false>` overrides `allow_autoscan` option in the config file
+ `LIBNFC_INTRUSIVE_SCAN=<true|false>` overrides `allow_intrusive_scan` option in the config file
+ `LIBNFC_LOG_LEVEL=<0|1|2|3>` overrides `log_level` option in the config file
To obtain the connstring of a recognized device, you can use `nfc-scan-device` : `LIBNFC_AUTO_SCAN=true nfc-scan-device` will show the names & connstrings of all found devices.
2010-12-13 12:58:04 +01:00
How to report bugs
==================
2015-04-30 14:19:03 +02:00
To report a bug, visit https://github.com/nfc-tools/libnfc/issues and fill
2010-12-13 12:58:04 +01:00
out a bug report form.
If you have questions, remarks, we encourage you to post this in the developers
2016-04-08 10:49:28 +02:00
community:
2009-08-26 11:37:12 +02:00
http://www.libnfc.org/community
2010-12-13 12:58:04 +01:00
Please make sure to include:
* The version of libnfc
* Information about your system. For instance:
2020-04-09 05:29:11 +02:00
- What operating system and version
- For Linux, what version of the C library
2010-12-13 12:58:04 +01:00
And anything else you think is relevant.
2013-01-31 21:58:29 +01:00
* A trace with debug activated.
2020-04-09 05:29:11 +02:00
2013-01-31 21:58:29 +01:00
Reproduce the bug with debug, e.g. if it was:
2020-04-09 05:29:11 +02:00
2016-04-08 10:49:28 +02:00
$ nfc-list -v
2020-04-09 05:29:11 +02:00
2013-01-31 21:58:29 +01:00
run it as:
2020-04-09 05:29:11 +02:00
2016-04-08 10:49:28 +02:00
$ LIBNFC_LOG_LEVEL=3 nfc-list -v
2013-01-31 21:58:29 +01:00
* How to reproduce the bug.
2020-04-09 05:29:11 +02:00
2016-04-08 10:49:28 +02:00
Please include a short test program that exhibits the behavior.
2020-04-09 05:29:11 +02:00
2016-04-08 10:49:28 +02:00
As a last resort, you can also provide a pointer to a larger piece
2020-04-09 05:29:11 +02:00
2010-12-13 12:58:04 +01:00
of software that can be downloaded.
* If the bug was a crash, the exact text that was printed out
2020-04-09 05:29:11 +02:00
2010-12-13 12:58:04 +01:00
when the crash occured.
* Further information such as stack traces may be useful, but
2020-04-09 05:29:11 +02:00
2010-12-13 12:58:04 +01:00
is not necessary.
Patches
=======
2015-04-30 14:19:03 +02:00
Patches can be posted to https://github.com/nfc-tools/libnfc/issues
2010-12-13 12:58:04 +01:00
If the patch fixes a bug, it is usually a good idea to include
all the information described in "How to Report Bugs".
Troubleshooting
===============
2010-12-13 14:07:55 +01:00
Touchatag/ACR122:
-----------------
2020-04-09 05:29:11 +02:00
2011-09-29 11:10:14 +02:00
If your Touchatag or ACR122 device fails being detected by libnfc, make sure
2016-04-08 10:49:28 +02:00
that PCSC-lite daemon (`pcscd`) is installed and is running.
2011-09-29 11:10:14 +02:00
2010-12-13 14:07:55 +01:00
If your Touchatag or ACR122 device fails being detected by PCSC-lite daemon
2016-04-08 10:49:28 +02:00
(`pcsc_scan` doesn't see anything) then try removing the bogus firmware detection
2011-02-02 15:20:16 +01:00
of libccid: edit libccid_Info.plist configuration file (usually
2016-04-08 10:49:28 +02:00
`/etc/libccid_Info.plist` ) and locate `<key>ifdDriverOptions</key>` , turn
`<string>0x0000</string>` value into `0x0004` to allow bogus devices and restart
2011-02-02 15:20:16 +01:00
pcscd daemon.
2010-12-13 14:07:55 +01:00
ACR122:
-------
2020-04-09 05:29:11 +02:00
2010-12-13 14:07:55 +01:00
Using an ACR122 device with libnfc and without tag (e.g. to use NFCIP modes or
2011-02-02 15:20:16 +01:00
card emulation) needs yet another PCSC-lite tweak: You need to allow usage of
2016-04-08 10:49:28 +02:00
CCID Exchange command. To do this, edit `libccid_Info.plist` configuration file
(usually `/etc/libccid_Info.plist` ) and locate `<key>ifdDriverOptions</key>` ,
turn `<string>0x0000</string>` value into `0x0001` to allow CCID exchange or
`0x0005` to allow CCID exchange and bogus devices (cf previous remark) and
2010-12-13 14:07:55 +01:00
restart pcscd daemon.
2011-02-02 15:44:38 +01:00
Warning: if you use ACS CCID drivers (acsccid), configuration file is located
2016-04-08 10:49:28 +02:00
in something like: `/usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist`
2011-02-02 15:44:38 +01:00
2010-12-13 14:07:55 +01:00
SCL3711:
--------
2020-04-09 05:29:11 +02:00
2010-12-13 14:07:55 +01:00
Libnfc cannot be used concurrently with the PCSC proprietary driver of SCL3711.
Two possible solutions:
2020-04-09 05:29:11 +02:00
2010-12-13 14:07:55 +01:00
* Either you don't install SCL3711 driver at all
* Or you stop the PCSC daemon when you want to use libnfc-based tools
2010-12-13 12:58:04 +01:00
2012-12-01 17:24:42 +01:00
PN533 USB device on Linux >= 3.1:
---------------------------------
2020-04-09 05:29:11 +02:00
2017-02-18 01:59:27 +01:00
Since Linux kernel version 3.1, a few kernel-modules must not be loaded in order
to use libnfc : "nfc", "pn533" and "pn533_usb".
2012-12-01 17:24:42 +01:00
To prevent kernel from loading automatically these modules, you can blacklist
them in a modprobe conf file. This file is provided within libnfc archive:
2016-04-08 10:49:28 +02:00
sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf
2012-12-01 17:24:42 +01:00
2020-05-21 14:27:13 +02:00
FEITIAN bR500 and R502:
-----------------------
2020-04-09 05:29:11 +02:00
2020-05-21 14:27:13 +02:00
Libnfc can work with PCSC proprietary driver of bR500 and R502, which is already available on most Linux setups.
To activate the PCSC support: `./configure --with-drivers=pcsc` .
Readers known to work:
2020-04-09 05:29:11 +02:00
- Feitian bR500
- Feitian R502 Dual interface reader
- Feitian R502 CL(Contactless) reader
2020-05-21 14:27:13 +02:00
These readers are support by CCID since v1.4.25, make sure your CCID driver version higher or equal to 1.4.25.
2020-04-09 05:29:11 +02:00
2020-05-21 14:27:13 +02:00
On MacOS, you can check your CCID version with the following command, and if required, you can install latest CCID driver from [https://github.com/martinpaljak/osx-ccid-installer/releases ](https://github.com/martinpaljak/osx-ccid-installer/releases )
2020-04-09 05:29:11 +02:00
```
grep -A 1 CFBundleShortVersionString /usr/local/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
```
2020-05-21 14:27:13 +02:00
On Linux, you can check your CCID version with the following command, and if required, you can install latest CCID driver from [https://ccid.apdu.fr/ ](https://ccid.apdu.fr/ )
2020-04-09 05:29:11 +02:00
```
grep -A 1 CFBundleShortVersionString /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist
```
2020-05-21 14:27:13 +02:00
2010-12-13 12:58:04 +01:00
Proprietary Notes
=================
2015-12-04 13:59:59 +01:00
FeliCa is a registered trademark of the Sony Corporation.
2010-12-13 12:58:04 +01:00
MIFARE is a trademark of NXP Semiconductors.
Jewel Topaz is a trademark of Innovision Research & Technology.
All other trademarks are the property of their respective owners.