AN11697
AN11697
Document information
Info Content
Keywords NFC, Linux, Libnfc-nci
Abstract This note describes how to add support for a PN7120 or PN7150 NFC
Controller to a generic GNU/Linux system
NXP Semiconductors AN11697
PN71xx Linux Software Stack Integration Guidelines
Revision history
Rev Date Description
2.4 20180810 Updated to R2.4 software stack version
2.3 20170612 • Updated to R2.2 software stack version
• Added description of NFC Factory Test application
2.2 20160704 • Updated to R2.1 software stack version
• Added description of configuration files
2.1 20160509 Added support for PN7150 NFCC IC
2.0 20160223 • Updated to R2.0 software stack version
• Updated Section 7.3 Licenses
1.1 20150824 Updated to R1.0 software stack version
1.0 20150601 First released version
0.1 20150507 Creation of the document
Contact information
For more information, please visit: http://www.nxp.com
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
1. Introduction
This document provides guidelines for the integration of NXP’s PN7120 and PN7150
NFC Controllers to a generic GNU/Linux platform from software perspective, based on
the Linux NFC stack. The related architecture is depicted in below Fig 1.
NFC Application
Interface Layer
Hardware
NXP’s N CI NFC Controller
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
2. Release note
The present document describes the Linux libnfc-nci stack version R2.2.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
Several different possibilities are offered to allow mapping the Linux NFC stack, depicted
in Fig 1, to the PN71xx NFC Controller.
NFC Application
libnfc-nci
TML I2C
User space
Kernel space
pn5xx_i2c kernel mod ule
Hardware
NXP’s N CI NFC Controller
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
This will create the sub-folder nxp-pn5xx containing the following files:
• pn5xx_i2c.c: driver implementation
• pn5xx_i2c.h: driver interface definition
• README.md: repository comments
• Makefile: driver related makefile
• Kconfig: driver related config file
• LICENSE: driver licensing terms
• sample_devicetree.txt: example of device tree definition
Include the driver config by adding below line to the heading configuration file
(drivers/misc/Kconfig).
source "drivers/misc/nxp-pn5xx/Kconfig"
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
Then the declared nfc_board_info structure must be added to the platform using
dedicated procedure (platform specific).
If <M> option is selected, build the driver and install the generated pn5xx_i2c.ko module.
Otherwise if built-in, build the complete kernel, the driver will be included in the kernel.
If the device tree method was used in previous step, build the platform related device
tree and install generated dtb file.
This will update the device node permission, to r+w to any user, during platform boot.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
NFC Application
libnfc-nci
TML I2C alt
User space
Kernel space
I2C kernel d river GPIO kernel driver
Hardware
NXP’s N CI NFC Controller
When accessing the NFC Controller through the /sys/class/gpio and /dev/i2c-dev rights
must be insured to the NFC application (either the NFC application must be executed as
root or rights must be extended to user).
The I2C and GPIO connection to the NFC Controller is depicted in phTmlNfc_alt.h file
and must be adapted to the targeted platform:
#define I2C_BUS "/dev/i2c-1"
#define I2C_ADDRESS 0x28
#define PIN_INT 23
#define PIN_ENABLE 24
- {I2C_BUS} defines the I2C dev instance the NFC Controller is connected to
- {I2C_ADDRESS} defines the NFC Controller 7 bits I2C slave address
- {PIN_INT} defines the GPIO number the NFC Controller IRQ pin is connected to
- {I2C_ENABLE} defines the GPIO number the NFC Controller VEN pin is
connected to
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
NFC Application
libnfc-nci
TML LPCUSBSIO
User space
Kernel space
HID interface
Hardware
NXP’s N CI NFC Controller
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
4. NFC library
The Linux libnfc-nci stack consists in a library running in User space. It is available from
the following repository: https://github.com/NXPNFCLinux/linux_libnfc-nci
• The Core layer implement NFC features (NCI, NDEF, LLCP and SNEP
protocols, Tag Operations, Host Card Emulation…)
• The Hardware Abstraction Layer provides connection to the kernel driver as well
as basic functionalities like self-test or firmware update
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
This requires the automake, autoconf and libtool packages to be installed on the machine
used for compilation (directly on the target or cross-compiling machine). This can be
done using standard apt-get install procedure.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
When --enable-llcp1_3 option is selected, configuration step will fail if openssldir path
is not set. (e.g. “./configure --enable-llcp1_3 openssldir=/opt/openssl”)
It installs the libnfc-nci-linux library to /usr/local/lib target directory. This path must be
added to LD_LIBRARY_PATH environment variable for proper reference to the library
during linking/execution of application.
It also installs the configuration files (refer to chapter 4.4) to /usr/local/etc.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
These files are loaded by the library, from /usr/local/etc directory of the target, during the
initialization phase. Refer to chapter 4.2.4 for installation procedure, the files can also be
manually copied to the target /usr/local/etc directory.
Pay attention that the configuration files provided as part of the library relates to the NFC
Controller demo boards. These files must be adapted according to the target integration.
Below is the description of the different useful tags in the configuration files (refer to the
example conf files for detailed information about the tag values).
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
5. Example application
5.1 Application details
The Linux libnfc-nci stack offers an application example demonstrating use of the library
to run NFC features. It is available as part of the stack delivery (refer to chapter 4.2 for
installation instructions). Source code is located in demoapp sub-folder of the libnfc-nci
stack directory.
The purpose of this application is to demonstrate NFC features offers by the libnfc-nci
library and provides code example of the library API.
It is built together the libnfc-nci library, following procedure depicted in chapter 4.2.3.
You can get the parameters details by launching the application help menu:
$ ./nfcDemoApp –-help
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
You can get more information about the message format using “-h” or “--help” parameter:
$ ./nfcDemoApp write –-help
You can get more information about the message format using “-h” or “--help” parameter:
$ ./nfcDemoApp share –-help
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
You can get more information about the message format using “-h” or “--help” parameter:
$ ./nfcDemoApp push –-help
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
Using the Makefile recipe file, build the application with the “make” command:
$ make
This will generate the application based on the pn5xx_i2c kernel driver for the
communication to the NFC Controller (see 3.1). If the integration is based on the
alternative option (refer to 3.2), the application must be build using the “alt” parameter:
$ make alt
I2C and GPIO connection details being defined in tml_alt.c file:
#define I2C_BUS "/dev/i2c-1"
#define I2C_ADDRESS 0x28
#define PIN_INT 23
#define PIN_ENABLE 24
Run the application (pay attention that the low level access rights are given) :
$ ./NfcFactoryTestApp
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
7. Legal information
customer’s applications or products, or the application or use by customer’s
7.1 Definitions third party customer(s). Customer is responsible for doing all necessary
testing for the customer’s applications and products using NXP
Draft — The document is a draft version only. The content is still under Semiconductors products in order to avoid a default of the applications and
internal review and subject to formal approval, which may result in the products or of the application or use by customer’s third party
modifications or additions. NXP Semiconductors does not give any customer(s). NXP does not accept any liability in this respect.
representations or warranties as to the accuracy or completeness of
information included herein and shall have no liability for the consequences Export control — This document as well as the item(s) described herein
of use of such information. may be subject to export control regulations. Export might require a prior
authorization from competent authorities.
Translations — A non-English (translated) version of a document is for
7.2 Disclaimers reference only. The English version shall prevail in case of any discrepancy
Limited warranty and liability — Information in this document is believed to between the translated and English versions.
be accurate and reliable. However, NXP Semiconductors does not give any Evaluation products — This product is provided on an “as is” and “with all
representations or warranties, expressed or implied, as to the accuracy or faults” basis for evaluation purposes only. NXP Semiconductors, its affiliates
completeness of such information and shall have no liability for the and their suppliers expressly disclaim all warranties, whether express,
consequences of use of such information. NXP Semiconductors takes no implied or statutory, including but not limited to the implied warranties of non-
responsibility for the content in this document if provided by an information infringement, merchantability and fitness for a particular purpose. The entire
source outside of NXP Semiconductors. risk as to the quality, or arising out of the use or performance, of this product
In no event shall NXP Semiconductors be liable for any indirect, incidental, remains with customer.
punitive, special or consequential damages (including - without limitation - In no event shall NXP Semiconductors, its affiliates or their suppliers be
lost profits, lost savings, business interruption, costs related to the removal or liable to customer for any special, indirect, consequential, punitive or
replacement of any products or rework charges) whether or not such incidental damages (including without limitation damages for loss of
damages are based on tort (including negligence), warranty, breach of business, business interruption, loss of use, loss of data or information, and
contract or any other legal theory. the like) arising out the use of or inability to use the product, whether or not
Notwithstanding any damages that customer might incur for any reason based on tort (including negligence), strict liability, breach of contract, breach
whatsoever, NXP Semiconductors’ aggregate and cumulative liability of warranty or any other theory, even if advised of the possibility of such
towards customer for the products described herein shall be limited in damages.
accordance with the Terms and conditions of commercial sale of NXP Notwithstanding any damages that customer might incur for any reason
Semiconductors. whatsoever (including without limitation, all damages referenced above and
Right to make changes — NXP Semiconductors reserves the right to make all direct or general damages), the entire liability of NXP Semiconductors, its
changes to information published in this document, including without affiliates and their suppliers and customer’s exclusive remedy for all of the
limitation specifications and product descriptions, at any time and without foregoing shall be limited to actual damages incurred by customer based on
notice. This document supersedes and replaces all information supplied prior reasonable reliance up to the greater of the amount actually paid by
to the publication hereof. customer for the product or five dollars (US$5.00). The foregoing limitations,
exclusions and disclaimers shall apply to the maximum extent permitted by
Suitability for use — NXP Semiconductors products are not designed,
applicable law, even if any remedy fails of its essential purpose.
authorized or warranted to be suitable for use in life support, life-critical or
safety-critical systems or equipment, nor in applications where failure or
malfunction of an NXP Semiconductors product can reasonably be expected 7.3 Licenses
to result in personal injury, death or severe property or environmental
damage. NXP Semiconductors and its suppliers accept no liability for Purchase of NXP ICs with NFC technology
inclusion and/or use of NXP Semiconductors products in such equipment or Purchase of an NXP Semiconductors IC that complies with one of the Near
applications and therefore such inclusion and/or use is at the customer’s own Field Communication (NFC) standards ISO/IEC 18092 and ISO/IEC 21481
risk. does not convey an implied license under any patent right infringed by
Applications — Applications that are described herein for any of these implementation of any of those standards. Purchase of NXP
products are for illustrative purposes only. NXP Semiconductors makes no Semiconductors IC does not include a license to any NXP patent (or other
representation or warranty that such applications will be suitable for the IP right) covering combinations of those products with other products,
specified use without further testing or modification. whether hardware or software.
Customers are responsible for the design and operation of their applications
and products using NXP Semiconductors products, and NXP 7.4 Trademarks
Semiconductors accepts no liability for any assistance with applications or
customer product design. It is customer’s sole responsibility to determine Notice: All referenced brands, product names, service names and
whether the NXP Semiconductors product is suitable and fit for the trademarks are property of their respective owners.
customer’s applications and products planned, as well as for the planned MIFARE — is a trademark of NXP B.V.
application and use of customer’s third party customer(s). Customers should
provide appropriate design and operating safeguards to minimize the risks MIFARE Classic — is a trademark of NXP B.V.
associated with their applications and products.
NXP Semiconductors does not accept any liability related to any default,
damage, costs or problem which is based on any weakness or default in the
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
8. List of figures
AN11697 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved.
9. Contents
Please be aware that important notices concerning this document and the product(s)
described herein, have been included in the section 'Legal information'.