Sie sind auf Seite 1von 39

NXP SW Libraries for NFC Readers Introduction

Index
Introduction to RFID Systems
Typical contactless Reader Architecture
NXP Reader Library
NXP Generic Reader Library.
NXP Export Controlled Reader Library.
NXP NFC Reader Library.

NXP Reader Library Software Stack


BAL, HAL, PAL, AL, Common Layer.
Memory footprint

Setting up the development environment.


Demoboards and samples ordering information.

COMPANY CONFIDENTIAL

Introduction to RFID systems


Application
Defines high level event, manages the data and takes
the required decisions to be executed by the
reader&transponder

Application defines
the system
features

Firmware
Drives the communication
between the reader and the
transponder

Power and commands

Reader
Composed of several blocks
that facilitate the
communication with the
transponder

Serial number / data

RFID TAG
(Transponder)
Holds the information and
usually is a passive device that
responds to the instructions
sent by the reader

The Communication is carried by radio waves

COMPANY CONFIDENTIAL

Typical contactless Reader Architecture


Reader

MCU
FW

SAM

C
Reader IC

Generic
embedded
Controller

Ex: CLRC663,
PN512,

Contactless
object

RFID card, NFC


Analog matching
Tag, NFC phone,
network
or any other NFC
object
13.56MHz loop
Antenna

NXP offers a broad portfolio of MCUs, reader ICs and SAM devices as
well as NFC tags.
COMPANY CONFIDENTIAL

NXP Reader Library


NXP Reader Library is the software written in C language providing an
API that enables the customer to create its own software stack and
applications for their contactless reader.
There are 3 available versions :
NXP Generic Reader Library: To develop applications based on MIFARE Classic,
MIFARE Ultralight, MIFARE Ultralight EV1, MIFARE Ultralight C, ICODE and
products based on ISO/IEC 15693 standard.

Free download in the NXP website.

NXP Export Controlled Reader Library: It provides full support for MIFARE Plus
and MIFARE DESFire cards and enables the usage of Secure Application Module

The whole software is subject to NDA with NXP. Available in DocStore.

NXP NFC Reader Library: It allows contactless readers to communicate with other
NFC devices making use of the Peer to Peer mode according to LLCP and SNEP
protocols, which guarantees interoperability with other P2P implementations.

Available under request.

COMPANY CONFIDENTIAL

NXP Reader Library layered structure

COMPANY CONFIDENTIAL

NXP Generic Reader Library (I)


The NXP Generic Reader Library provides APIs for:
MIFARE Classic, MIFARE Ultralight, MIFARE Ultralight EV1 and MIFARE
Ultralight C
Supported contactless Readers:
ICODE SLI, ICODE ILT.
NXP Pegoda RD70x (FW V2.12 or above),
NXP Pegoda RD710,
ISO/IEC 15693 products

Partial API implementation for:


MIFARE DESFire
FeliCa

NXP CLRC663 Eval Board,


NXP MFRC523 Eval Board
Supported PC/SC contact Readers:
OMNIKEY CardMan 3x21,
OMNIKEY CardMan 5321

Common layer implements utilities independent to any specific card or


hardware
KeyStore, Log, Tools,

The SW package is provided with Microsoft Visual Studio C++ solution to


get started on PC environment.

Project examples for CLRC663 and PN512 Blueboards available in the


website.
COMPANY CONFIDENTIAL

NXP Generic Reader Library (II)

COMPANY CONFIDENTIAL

NXP Export Controlled Reader Library (I)


Products implementing symmetric algorithms with a key length > 56
bits are under export control rules.
United States Department of Commerces Bureau of Industry and Security
(BIS) is responsible for implementing and enforcing the Export
Administration Regulations (EAR), which regulate the export and re-export
of most commercial items.

NXP Export Controlled Reader Library adds all export controlled SW


components on top of the NXP Generic Reader Library components.
The SW package is provided with Microsoft Visual Studio C++ solution
to get started on PC environment.
It can be downloaded from www.docstore.nxp.com

COMPANY CONFIDENTIAL 10

NXP Export Controlled Reader Library (II)

COMPANY CONFIDENTIAL 11

NXP NFC Reader Library (I)


NXP NFC Reader Library implements all those components required to deploy
NFC P2P applications and to operate with the NFC Forum Tag Types.
Compared to the NXP Generic Reader Library, it adds the following
components:
P2P Package.
NFC Activity: Discovery Loop.
NFC Forum Tag Type Operations.
ISO18092 Initiator (Active and Passive) and Target (Active and Passive).
LPC1769 BAL component.
OSAL.

The SW package is supplied with LPCXpresso project examples to get started


on real Controller environment (CLRC663 and PN512 Blueboards with
LPC1769).

COMPANY CONFIDENTIAL 12

NXP NFC Reader Library (II)

COMPANY CONFIDENTIAL 13

Introducing NXP Reader Library.chm


The NXP Reader Library.chm is a software documentation file.
It is generated from source file annotations.
The .chm file is the most friendly way to go through the NXP Reader
Library API.
Once the Library has been downloaded, you can find this file here:
C:\Program Files (x86)\NXP Semiconductors\NxpRdLib2.0\NxpRdLib_PublicRelease\docs\14_user_doc

Open NXP Reader Library.chm

COMPANY CONFIDENTIAL 14

NXP Reader Library Initialization


The initialization of each layer generates a data context that is used as
an entry point for the immediate upper layer.
It is necessary to initialize the layers from bottom to top
AL
(Context)

PAL
(Context)

HAL
(Context)

Library
Initialization
order

BAL
(Context)

COMPANY CONFIDENTIAL 15

Bus Abstraction Layer (I)


The BAL implements the interface between Host
Device and Reader IC Device

AL

PAL

HAL

BAL

The host device can be a PC or a MCU


NXP Generic Reader Library
PC/SC (Win): Driver for PC/SC interface running on
windows platform
Supported
interfaces

Rd70x USB Win: Drivers for windows platform to


enable connection to PEGODA reader
RS232 (Win): Serial connection for Windows platform
Stub: Currently it supports SPI, I2C and RS232
interfaces enabling connection to the LPCXpresso
target boards.

COMPANY CONFIDENTIAL 16

AL

Bus Abstraction Layer (II)

PAL

HAL

Implementing the communication interface between


the host device and the contactless reader IC

BAL

Initializing the Reader BAL (Bus Abstraction Layer) component


phbalReg_PcscWin_Init(&balReader,sizeof(phbalReg_PcscWin_DataParams_t));
phbalReg_Rd70xUsbWin_Init(&balReader,sizeof(phbalReg_Rd70xUsbWin_DataParams_t));
phbalReg_SerialWin_Init(&balReader,sizeof(phbalReg_SerialWin_DataParams_t));
phbalReg_Stub_Init(&balReader,sizeof(phbalReg_Stub_DataParams_t));

COMPANY CONFIDENTIAL 17

Hardware Abstraction Layer (I)

AL

PAL

HAL

The specific modules of the target reader chips


are implemented in the HAL.
The functions of this layer are responsible for the
execution of native commands of a particular
contactless reader chip. These functions are
mainly:

BAL

NXP Generic Reader Library

Reading and writing from and into readers


registers.
RF field Management, receiver and transmitter
configuration.
Timers configuration
Resolving interrupt source from reader chip.
FIFO Management.

COMPANY CONFIDENTIAL 18

AL

Hardware Abstraction Layer (II)

PAL

The specific modules of the target reader chips are


implemented in the HAL.

HAL

BAL

The HAL modules init functions includes a pointer to


the underlying BAL component:
phStatus_t phhalHw_Rc523_Init(
phhalHw_Rc523_DataParams_t * pDataParams,
uint16_t wSizeOfDataParams,
void * pBalDataParams,
void * pKeyStoreDataParams,
uint8_t * pTxBuffer,
uint16_t wTxBufSize,
uint8_t * pRxBuffer,
uint16_t wRxBufSize );

[In]
[In]
[In]
[In]
[In]
[In]
[In]
[In]

COMPANY CONFIDENTIAL 19

Protocol Abstraction Layer (I)

AL

PAL

HAL

The PAL contains Hardware-Independent


implementations of various contactless
protocols.
The PAL implements the activation and
exchange operations regarding the protocol
of the contactless communication.

BAL

NXP NFC Reader Library

What PAL components must be initialized if


we use a MIFARE Classic? And, in case of a
MIFARE DESFire?

COMPANY CONFIDENTIAL 20

AL

Protocol Abstraction Layer (II)

PAL

HAL

The PAL implements the activation and exchange


operations regarding the contactless communication
protocol.

BAL

The PAL components init functions include a pointer to the underlying


HAL component:
Init ISO14443-3A
phStatus_t phpalI14443p3a_Sw_Init(
phpalI14443p3a_Sw_DataParams_t * pDataParams,
uint16_t wSizeOfDataParams,
void * pHalDataParams );

[In]
[In]
[In]

COMPANY CONFIDENTIAL 21

AL

Application Layer (I)

PAL

HAL

The Application Layer contains three main packages:

BAL

Card command sets and the NFC Forum Tag Type


Operations.
MIFARE Classic, Ultralight, DESFire. FeliCa, Jewel.
The NFC Forum Tag Type Operations provides an API
to complete NDEF related operations on top of the four
NFC Forum Type Tags.

NFC Activity: Discovery Loop.


P2P Package: LLCP and SNEP.

*Application Layer belonging to the


NXP NFC Reader Library

COMPANY CONFIDENTIAL 22

AL

Application Layer (II)

PAL

Card commands
Implements the commands of contactless smartcards

HAL

The AL enables the developer to access particular


card API by using its command set (i.e: reading, writing)

BAL

Initializing the MIFARE DESFire component


&palMifare: Pointer to the PAL MIFARE layer parameter structure
phStatus_t phalMfdf_Sw_Init(
phalMfdf_Sw_DataParams_t * pDataParams,
uint16_t wSizeOfDataParams
void * pPalMifareDataParams
void * pKeyStoreDataParams,
void * pCryptoDataParamsEnc
void * pCryptoRngDataParams
void * pHalDataParams );

[In]
[In]
[In]
[In]
[In]
[In]
[In]

COMPANY CONFIDENTIAL 23

Application Layer (III)


NFC Activity - 1
Provides an easy way to set the contactless reader IC in a Discovery
Loop for detecting NFC contactless tags and P2P devices within the
contactless reader IC RF field range
Discovery Loop Init

Discovery Loop Config

Discovery Loop Start

COMPANY CONFIDENTIAL 24

Application Layer (III)


NFC Activity - 2
The Discovery Loop can be configured by the developers according to
their application needs. All the configuration identifiers are listed in the
file NxpRdLib_PublicRelease/intfs/phacDiscLoop.h.
The discovery loop configuration can be set using the
phacDiscLoop_SetConfig() function.

phStatus_t phacDiscLoop_SetConfig(
void
*pDataParams,
uint16_t wConfig,
uint16_t wValue );

[In]
[In]
[In]

COMPANY CONFIDENTIAL 25

Application Layer (III)


NFC Activity - 3
Setting the Polling loop number of iterations:
Use the macro: PHAC_DISCLOOP_CONFIG_NUM_POLL_LOOPS:

Setting the Polling mode options:


Set the PHAC_DISCLOOP_CONFIG_MODE flag with any of these values:
PHAC_DISCLOOP_SET_POLL_MODE | PHAC_DISCLOOP_SET_LISTEN_MODE
PHAC_DISCLOOP_SET_POLL_MODE | PHAC_DISCLOOP_SET_PAUSE_MODE
PHAC_DISCLOOP_SET_LISTEN_MODE

Setting the contactless technology detection:


Set the PHAC_DISCLOOP_CONFIG_DETECT_TAGS flag with these
values:
PHAC_DISCLOOP_CON_POLL_A
PHAC_DISCLOOP_CON_POLL_B
PHAC_DISCLOOP_CON_POLL_F
PHAC_DISCLOOP_CON_POLL_ACTIVE

COMPANY CONFIDENTIAL 26

Application Layer (III)


NFC Activity - 4
Get information about the detected Tags / P2P devices:
phacDiscLoop_GetConfig(
pDataParams,
PHAC_DISCLOOP_CONFIG_TAGS_DETECTED,
&TagsDetected);

Checking whether one particular Tag Type has been detected can be
done by using the defined bitmasks.
MASK (TagsDetected, PHAC_DISCLOOP_TYPEA_DETECTED_TAG_TYPE2))
printf ("Type A T2 tag detected ");

COMPANY CONFIDENTIAL 27

Application Layer (IV)


P2P package - 1

This layer implements the NFC Forum standardized protocol stack for a
Peer to Peer communication with an NFC device.
Includes the correct management of the logical link between peers
(LLCP) and the implementations of a client/server based architecture
for the exchange of NDEF messages (SNEP)
Logical Link Control Protocol (LLCP): It is the link layer protocol that
specifies the procedural means for the transfer of upper layer information
units between two NFC devices.
Simple NDEF Exchange Protocol (SNEP): It is an application-level
protocol running on top of LLCP suitable for the exchange of application
data units. It is a request/response protocol based on a client/server
architecture.

COMPANY CONFIDENTIAL 28

Application Layer (IV)


P2P package - 2

The NXP NFC Reader Library SNEP Client implements:


PUT request: Command to push data to the SNEP Server.
GET request: Command to retrieve data from the SNEP Server.

The NXP NFC Reader Library SNEP Server implements:


Default Server: The NFC Forum SNEP spec defines a Default SNEP
Server with well-known LLCP service access point (SAP) address number
4 and service name urn:nfc:sn:snep.
The Default SNEP Server only implements the PUT request
Certified NFC Forum devices must have the Default SNEP Server
implemented.

Non-Default Server: PUT and GET requests are supported.

COMPANY CONFIDENTIAL 29

Common Layer
The Common Layer implements a set of utilities independent of any
card and hardware.
Cryptographic keys management, CRC and parity calculation, log
generation and CID.
NXP Generic Reader Library

Cid Manager: This module is used when a CID needs


to be assigned to an ISO 14443-4 PICC or a CID is
released by the PICC
KeyStore: Module for storing of encryption keys used
in the authentication and encryption procedures
Tools: Utility that allows to perform binary operations
related to CRC and bit parity both for various lengths
Log: Software module enabling log files creation.

COMPANY CONFIDENTIAL 30

Key Store
The key store offers the key handling software module for storing
cryptographic keys used in the authentication and encryption
operations.

The Generic Reader Library provides two Key Store implementation


Hardware Key Store: API to store the MIFARE Crypto key in the reader IC.
Software Key Store: API to store secret key into the MCU memory.

Only the NFC Reader Library Export Controlled version supports high
secure key storage capabilities (SAM).
Supports the following symmetric cryptography key types

PH_KEYSTORE_KEY_TYPE_AES128
PH_KEYSTORE_KEY_TYPE_DES
PH_KEYSTORE_KEY_TYPE_2K3DES
PH_KEYSTORE_KEY_TYPE_MIFARE
PH_KEYSTORE_KEY_TYPE_AES192
PH_KEYSTORE_KEY_TYPE_3K3DES
PH_KEYSTORE_KEY_TYPE_AES256

COMPANY CONFIDENTIAL 31

Using the NXP Reader Library


Building a project from bottom to top
Example: Initialization procedure for a MIFARE DESFire application
using a CLRC663 contactless reader and LPC1227.
phalMfdf_Sw_Init(&alMfdf, , &palMifare, );
phpalMifare_Sw_Init(&palMifare, , &halReader, &palI14443p4);

phpalI14443p3a_Sw_Init(&palI14443p3a, , &halReader);
phpalI14443p4a_Sw_Init(&palI14443p4a, , &halReader);
phpalI14443p4_Sw_Init(&palI14443p4, , &halReader);

phhalHw_Rc663_Init(&halReader, &balReader, );

phbalReg_Stub_Init(&balReader, );

Library initialization order

COMPANY CONFIDENTIAL 32

NXP NFC Reader Library


Memory footprint
Layer

Module

AL Tag Operation

T1T - Jewel/Topaz
MIFARE UL (EV1) All CMD
T2T CMD
T3T Felica
T4T DesFire
Tag Operation
MF Classic
DESFire (Partly)
Discovery Loop
SNEP
LLCP
ISO/IEC14443-3A & MIFARE
ISO/IEC14443-3B
ISO/IEC14443-4A & ISO/IEC14443-4
Felica Compliant protocol
IO/IEC18092 Active&Passive Initiator
IO/IEC18092 Active&Passive Target
Hal common
Callback
RC663
PN512/RC523
BAL common
SPI for LPC1769
I2C for LPC1769
Key Store Common
Key store RC663
Key Store SW
ISO/IEC 14443-4 CID Man
Tools (CRC, Parity)
Log Module
OSAL Utils

NFC Activity
P2P
Protocol

HAL

BAL
Common

Code (byte) RAM (byte)


4796
1132

12
18

2012
1274
21824
1328
17124
4390
4943
13864
3250
2316
4114
1172
4496
4479
846
390
15268
11524
358
414
246
719
492
914
170
1575
379
1696

36
20
228
10
96
516
3196
28
35
31
24
27
68
60
96
88
4
4
8
24
16
52

COMPANY CONFIDENTIAL 33

Memory footprint
MIFARE Ultralight Read/Write Project
In order to optimize the memory consumption, all modules that are not
necessary should be excluded
Project from scratch memory footprint is about 11728 bytes
CMSIS source code
MCU drivers

From the previous reference values:


Layer

Component

Code (byte)

Application AL

Type 2 Tag MIFARE UL (EV1)

1132

Protocol PAL

ISO/IEC14443-3A & MIFARE

3250

Hardware HAL

PN512/RC523

11524

Platform BAL

LPC1769SPI

414

Project from scratch memory footprint

Expected memory footprint

11728

28048

COMPANY CONFIDENTIAL 34

Setting up the Development Environment


Download and install an Integrated Development
Environment (IDE):
NXP contributes with a software tool called
LPCXpresso, which allows the :
Development of applications for the NXPs
contactless readers.
Flashing of the application code into the target MCU.
Downloadable here:
http://www.lpcware.com/lpcxpresso/download

Microsoft Visual Studio

Get a Demoboard and/or IC samples.


Import and run the project examples included in
the SW release.

COMPANY CONFIDENTIAL 35

How to order samples and demoboards I


IC samples and demoboards are available via the NXP extranet as well
as via our local distributors.
Samples can be ordered through the eSample desk
(https://extranet.nxp.com/ -> NXP Customer Support -> Samples)
Demoboards for contactless ICs can be ordered via eDemoboard
https://extranet.nxp.com/ -> NXP Customer Support -> Demobards

COMPANY CONFIDENTIAL 36

How to order samples and demoboards II


Product

Description

Devboard

Devboard 12 NC

CLRC663

High Output Power Reader ICs


Latest generation of multiprotocol contactless proximity reader ICs
(ISO/IEC 14443 A&B, ISO/IEC15693, EPC Class-1 HF/ ISO 18000-3M3,
FeliCa,
NFC P2P passive initiator, NFC Tag Type Reader 1,2,3,4)

CLEV663B

9352 978 15699

PNEV512B

9352 981 99699

Documentation and SW can be downloaded from:


http://www.nxp.com/demoboard/CLEV663B.html
NFC Transceiver
(ISO 14443 A&B, FeliCa, ISO/IEC 18092 NFC)

PN512

Documentation and SW can be downloaded from:

http://www.nxp.com/demoboard/PNEV512B.html

LPCXpresso

LPCXpresso boards (12NC)

LPC1114

9352 908 86598

LPC1227

9352 946 03598

LPC1769

9352 919 12598

COMPANY CONFIDENTIAL 37

Wrapping up
NXP Reader Library software A powerful tool for your developers

3 available Libraries addressing different needs:


NXP Generic Reader Library.
NXP Export Controlled Reader Library.
NXP NFC Reader Library.

Main advantages:
The software is written in C language.
Modular and Multi-layer approach, enabling flexibility and scalability.
The Library package includes a set of project examples.

Documentation, Software and materials like Samples and


Demoboards, all available online.

COMPANY CONFIDENTIAL 38

Need More ?
NXP SW Libraries for NFC Readers
Additional reference material
Reader forum:
http://www.mifare.net/en/micommunity/forum/mifare-and-nfc-reader-ics
NXP Reader Library version 2.1 with Visual C++ project:
http://www.nxp.com/documents/software/200312.zip
NXP NFC Reader Library and PN512B / CLRC663B examples for LPC MCUs:
http://www.nxp.com/demoboard/PNEV512B.html#documentation
http://www.nxp.com/demoboard/CLEV663B.html#documentation
please note: an updated version of the library and examples will be available in May
Export controlled library (Docstore):
Doc Number: sw171734

Further questions and support.


Reader forum: http://www.mifare.net/en/micommunity/forum/mifare-and-nfc-reader-ics
Knowledge base NFC & contactless reader ICs: http://www.nxp.com/knowledge-base/53420/41960
Further questions related to this webinar: nfc.readers@nxp.com

COMPANY CONFIDENTIAL 39

MobileKnowledge
Thank you for your attention
www.themobileknowledge.com

We are a global competence team of hardware and software


technical experts in all areas related to contactless technologies
and applications.
Our services include:

Application and system Design Engineering support


Project Management
Technological Consulting
Advanced Technical Training services
We address all the exploding identification technologies that
include NFC, secure micro-controllers for smart cards and mobile
applications, reader ICs, smart tags and labels, MIFARE family
and authentication devices.
For more information
Eric Leroux
eric.leroux@themobileknowledge.com
+34 629 54 45 52

WE LEVERAGE THE
MOBILE REVOLUTION

COMPANY CONFIDENTIAL

Das könnte Ihnen auch gefallen