02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware...

31
PUBLIC JORDI JOFRE NFC READERS NFC EVERYWHERE 28/09/2017 WEBINAR SERIES: NFC SOFTWARE INTEGRATION HOW TO INTEGRATE NFC CONTROLLERS IN LINUX

Transcript of 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware...

Page 1: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

PUBLIC

JORDI JOFRENFC READERS

NFC EVERYWHERE28/09/2017

WEBINAR SERIES:

NFC SOFTWARE INTEGRATION

HOW TO INTEGRATE NFC CONTROLLERS IN LINUX

Page 2: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

1

Agenda

NFC software integration webinar series

Session I, 14th September

How to integrate NFC frontends in Linux.

Session II, 28th September

How to integrate NFC controllers in Linux.

Session III, 11th October

How to port the NFC Reader Library to K64F.

Page 3: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

2

Agenda

NFC software integration webinar series

Session III, 11th October

How to integrate NFC controllers in Linux.

► Recap about last session

► PN7150 NFC controller family

► PN7150 NFC controller concept

► NFC software libraries available for Linux

► Integration in Linux using the Linux libnfc-nci SW stack

► PN7462 NFC controller family

► PN7462 NFC controller concept

► PN7462 NFC integration in Linux

► Wrap up and Q&A

Page 4: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

3

Recap about last session

Page 5: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

4

NFC frontends software integration in Linux

Solutions

• NFC Frontends expose a ‘register interface’ towards the

host controller through the host interface

• High latency: Access the host interface (I2C, SPI,

UART drivers) in Linux Kernel space is slow.

• High CPU load: There is a lot of code involved just to

write one register in Linux context switching.

• The NFC Reader Library can be installed on a generic

GNU/Linux platform.• Increase CPU/SPI clock as much as the MCU can

process.

• Reduce SPI / host interface interactions as much as

possible: Linux driver is optimized for few long

transactions rather than lots of short ones

• Move NFC Reader Library BAL module to Kernel

space.

Page 6: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

5

PN7150 NFC controller

family concept

Page 7: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

6

PN7150 NFC controller family host and contactless interfaces

PN7150 NFC controller family are integrated solutions

combining an NFC frontend together with an MCU

NFC controller

with embedded

firmware

(PN7150)

Ho

st

inte

rface

RF

in

terf

ace

Host interface RF interface

• PN7150 is connected to the host device

through an I2C physical interface.

• PN7150 logical interface (API) is based on

the NCI NFC Forum standard.

• It supports additional , NXP proprietary

extensions specific to the PN7150 chip.

• In few NCI commands, host SW can

configure the PN7150 to notify for card or

peer detection and start data exchange.

• Full NFC Forum compliancy with small form

factor antenna.

• Ultra-low power consumption in polling loop

mode allows without impacting the user

experience.

• Embedded NFC firmware providing all NFC

protocols as pre-integrated feature

• Load modulation schemes: Active & Passive

Page 8: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

7

PN7150 NFC controller family are managed by NCI commands

NFC controller

with integrated

firmware

Ho

st

inte

rface

RF

in

terf

ace

Host controller

Host controller

Matc

hin

g

• SW implementation is required for both

entities, the NFC FW for the controller side,

and the NCI driver from the device host.

• NCI defines a standard communication

channel between the NFC controller and the

host device.

• It provides manufacturers with a standard

interface they can use for whatever kind of

NFC-enabled device they build.

Linux OS

NCI driver

There is NCI driver support for Linux, Android,

Windows IoT, RTOS and bare metal systems.

TODAY: NFC application runs on Linux OS system

NFC

application

PN7150 NFC controller embeds an ARM Cortex-M0

microcontroller core loaded with integrated firmware

supporting the NCI 1.0 host communication.

ARM

Cortex-M0

core

NCI commands RF communication

Page 9: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

8

PN7150 NFC controller family architecture

ROM with NFC

firmware

NFC controller with integrated FW

• Implements NCI 1.0 compliant protocol.

• Runs the NFC stack and RF protocols.

32-bit Cortex-M0

power-efficient

20MHz ARM

Cortex-M0

Key benefits

• Critical timing constraints on host are

handled by the embedded FW.

• Host interactions are reduced since

some functionalities are handled

autonomously by the embedded FW.

Page 10: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

9

PN7150 NFC software integration in Linux

NFC software libraries available for Linux

Page 11: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

10

NFC software libraries available for Linux

• MUSCLE is a project to develop a set of compliant drivers, API's,

and a resource manager for various smart cards and readers for

the GNU environment.

• Middleware to access a smart card using the SCard API.

• Open source implementation of PC/SC (Microsoft OS).

MUSCLE

PC/SC Lite

Library focused on smartcard

integration into computing environment

rather than an NFC SW stack

• Implements NFC Forum specifications for data exchange with NFC

devices and tags.

• Python module for NFC.

• USB and UART devices support.

• EUPL licensed project and available at GitHub.nfcpy

Not reusable for PN7150, NCI

support is not included

Not all NFC functionalities

implemented (e.g. Card

emulation limited to Type 3 tags)

Page 12: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

11

NFC software libraries available for Linux (II)

• Academic LGPL licensed project.

• Written in C.

• USB and UART devices support.

• Open source and community supported.

• Support for various operating systems ( Linux, Mac OS, Windows).

• No ROM memory access on Linux.

Libnfc(From NFC Tools)

• Maintained by Intel open source community.

• Aims to be HW independent (NXP, TI, Inside Secure, etc). Supports

HCI, NCI and USB hardware.

• GPLv2 licensed.

• Split between kernel and user spaces.

Linux

NFC

Not reusable for PN7150 since

NCI support is not included

NXP originally contributed to

this SW stack. Support has

stopped for their NCI-based

NFC controllers.

Page 13: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

12

NFC software libraries available for Linux (III)

Linux

Libnfc-nci

• NDEF tag support

• MIFARE Classic tag support

• P2P, LLCP, SNEP

• WiFi & BT handover

• Raw tag command support

• Proprietary NCI command support

• Host Card Emulation support

Derived from the available

and proven Android stack

Works together with the PN5xx I2C

driver, which is compatible and

offers communication with NXP NFC

controllers through an I2C interface

It is the native library providing NFC

functionality for the extension added to

support NXP proprietary features.

Linux Libnfc-nci is the best choice for

integrating PN7150 NFC controllers in Linux

Optimized in terms of

interoperability with mobile

devices

Page 14: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

13

PN7150 NFC software intregration in Linux

Linux libnfc-nci stack

Page 15: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

14

Linux libnfc-nci stack mapping in Linux architecture

Host controllerH

ost

inte

rface

System Libraries

App 1 App 2 App 3 NFC app

GNU C

LibraryDRM

Library

Generic Kernel

Hardware Dependent Kernel

Process

scheduler

Memory

managerVirtual File

System

Network

Stack

USB driverDisplay

DriverI2C

driver

PN5xx_I2C

driver

Ke

rne

l S

pa

ce

User

Sp

ace

Linux libnfc-nci details

Syscall Interface

Syscall Dispatcher

Linux OS

stack

HW platform

Linux libnfc-nci

stack

Linux libnfc-nci stack consists of a library

running in User space and implement NFC

features (NCI, NDEF, LLCP and SNEP

protocols, Tag Operations, Host Card

Emulation…)

PN5xx_I2c kernel mode driver can be

used to communicate with the

PN7150 NFC controller

Low level access to PN7150 HW

PN7150 NFC

Controller

Ho

st

inte

rface

NCI commands

PN7150 FW autonomously handles part of the NFC activity so it requires much less

interaction on the I2C interface than NFC frontends, reducing context switching.

Page 16: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

15

Linux libnfc-nci stack architecture in detail

$ git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git

Interface Layer: exposes the library API to the user

application.

Libnfc-nci Core: implements the NFC functionality (NCI,

NDEF, LLCP and SNEP protocols, tag operations, Host Card

Emulation…)

Hardware Abstraction Layer: provides connection to the

kernel driver as well as basic functionalities such as self-test or

firmware update.

Libnfc-nci library

*For alternatives to PN5xx_I2C kernel driver, check AN11769

Linux Libnfc-nci repository permanently

updated and maintained by NXP

Page 17: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

16

Integrating the Linux-libnfc-nci stack

into a Linux system

Page 18: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

17

Integrating the Linux libnfc-nci stack into a Linux system

Host controllerH

ost

inte

rface

System Libraries

App 1 App 2 App 3 NFC app

GNU C

LibraryDRM

Library

Generic Kernel

Hardware Dependent Kernel

Process

scheduler

Memory

managerVirtual File

System

Network

Stack

USB driverDisplay

DriverI2C

driver

PN5xx_I2C

driver

Ke

rne

l S

pa

ce

User

Sp

ace

Syscall Interface

Syscall Dispatcher

Linux OS

stack

HW platform

Linux libnfc-nci

stack

PN7150 NFC

Controller

Ho

st

inte

rface

Step 1:

Install the PN51xx I2C driver as

part of the kernel.

Step 2:

Install the Linux libnfc-nci in

user mode.

Integration steps are described in the AN11769 – PN71xx Linux

Software Stack Integration Guidelines in detail.

Page 19: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

18

• Steps to install the PN5xx I2C driver:

1. Download the driver source code

2. Include the driver to the kernel

3. Create the device node

4. Build the driver

5. Change access to device node

Step 1: Installing PN5xx I2C driver

$ git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git

Obj-y +=nxp-pn5xx/Source “drivers/misc/nxp-pn5xx/Kconfig”

ACTION==“add”, KERNEL==“pn544”, MODE=“066”

&i2c{status = "okay";pn547: pn547@28 {compatible = "nxp,pn547";reg = <0x28>;clock-frequency = <400000>;interrupt-gpios = <&gpio2 17 0>;enable-gpios = <&gpio4 21 0>;};

};

Live demo with RaspberryPi: http://youtu.be/TCgCRi-tKxM

Page 20: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

19

• Steps to install the Linux libnfc-nci:

1. Download the driver source code

2. Build the library

3. Install the library

4. Using the application

Step 2: Installing the Linux libnfc-nci

$ ./bootstrap$ ./configure <OPTIONS>$ make

$ make install

$ git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git

$ ./nfcDemoApp <OPTIONS>

Live demo with RaspberryPi: http://youtu.be/TCgCRi-tKxM

Page 21: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

20

PN7462 NFC controllers

family concept

Page 22: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

21

PN7462 NFC controller family host and contactless interfaces

PN7462 NFC controller family are integrated solutions combining an

NFC frontend together with an MCU with customizable firmware

Ho

st

inte

rface

RF

in

terf

ace

Host interface RF interface

• PN7462 can be connected to the host device

through I2C, SPI, USB or HSUART

• The customizable FW gives developers the

widest range of options for functionality and

enables a high degree of design flexibility.

• PN7462 host interface can be used to

interact with a high level API-like offered by

the FW logic programmed into PN7462

internal MCU.

• High RF output power frontend IC for transfer

speed up to 848 Kbps

• Compliance with EMV and NFC Forum

standards.

• Low power card detection mode.

• Dynamic Power Control (DPC) support.

• Load modulation schemes: Active & Passive.

GPIOs &

peripherals

Contact

interface

NFC controller

with customizable

firmware

(PN746x_PN736x)

Page 23: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

22

PN7462 NFC controller family are managed by an API-like interface

NFC controller

with customizable

firmware

Ho

st

inte

rface

RF

in

terf

ace

Host controller

Host controller

Matc

hin

g

• PN7462 can be run stand-alone user

application or be connected to a high-end

platform running an operative system like

Linux.

• PN7462 custom FW can be designed to

provide a higher level protocol or API

instead of exposing a register interface

over host interface (e.g. NFC frontends).

• This solution offers an (almost) latency

independent interface between host SW

stack and the RF frontend.

HW platform

Linux OS

PN7462 firmware can de developed

leveraging on the NFC Reader Library.

Host

application

PN7462 embeds an ARM Cortex-M0 with up to 160kB of flash

memory and can be configured to run fully-custom applications

ARM

Cortex-M0 core

User custom

application

API user-defined

commandsRF communication

Page 24: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

23

PN7462 NFC controller family

NFC software integration in Linux

Page 25: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

24

PN7462 architecture for Linux integration

Host controllerH

ost

inte

rface

System Libraries

App 1 App 2 App 3 Host app

GNU C

LibraryDRM

Library

Generic Kernel

Hardware Dependent Kernel

Process

scheduler

Memory

managerVirtual File

System

Network

Stack

UART USB driver I2C driver SPI driver

Ke

rne

l S

pa

ce

User

Sp

ace

Syscall Interface

Syscall Dispatcher

Other tools….

Linux OS

stack

HW platform

PN7462 NFC

Controller

User- defined application interface

The host application interacts with the

FW defined in PN7462.

Host app

If properly designed, the whole system

requires little context switching,

reducing transaction latency

User-defined application interface

Ho

st

inte

rface

e.g. For a payment application, PN7462 can implement the EMVCo L1 while the

host app can implement the EMVCo L2 payment applications

Page 26: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

25

NFC Reader Library – Simplified APIAn example for developing your application interface-like development

Provides a high level abstraction access to the NFC

Reader Library.

Two different available profiles:

• EMVCo channel: used to transfer ISO 7816 APDU’s

over the ISO 14443-4 protocol, according to EMVCo L1

spec.

• ISO channel: general channel, used to transfer raw data

on block/frame level.

Simplified API functions

phNfcLib_Init(); phNfcLib_SetConfig_Value ();phNfcLib_Activate();phNfcLib_Transmit ();phNfcLib_Receive (); phNfcLib_Deactivate(); phNfcLib_DeInit();

Simplified API

Page 27: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

26

Wrap up & Q&A

Page 28: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

27

PN71xx vs PN7462

NFC controllers with integrated FW

NFC controller

with integrated

firmware

PN71xx

NFC controllers with customizable FW

NFC controller with

application

PN7462

Key benefits Key benefits

► Contactless interface with full NFC

functionality.

► Microcontroller core with fully

customizable firmware.

► One configurable host interface:

I2C, SPI, USB, HSUART.

► Contact card reader (PN7462).

► Two master interfaces: I2C and

SPI and up to 21 GPIOs

► Full NFC Forum-compliant

contactless interface

► Microcontroller core with

integrated firmware.

► Host interface: I2C interface

over NCI protocol.

Page 29: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

28

NFC controllers with integrated FW

PN7150 and PN7462 considerations for Linux integration

NFC controller

with integrated FW

PN71xx family

NFC controllers with customizable FW

NFC controller with

custom application

PN7462 family

► PN7150 logical interface (API) is based on the NCI NFC

Forum standard over an I2C physical interface

► There are few libraries out there, but the Linux libnfc-

nci is NXP NFC stack for Linux systems and the most

complete.

► Host interactions are reduced since some functionalities

are handled autonomously by the FW.

► PN7462 internal flash memory can be used to program

a fully custom FW that exposes a high level protocol or

API towards the host system.

► PN7462 firmware can de developed leveraging on the

NFC Reader Library.

► It offers an (almost) latency independent interface

between host software stack and the RF frontend.

Page 30: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

29

Reference links & info

• PN71xx family

www.nxp.com/products/: PN7150B0HN

• PN746x_PN736x family

www.nxp.com/products/:PN7462AUHN

• NXPNFCLinux GitHub repository

https://github.com/NXPNFCLinux/

• NFC Reader Library

www.nxp.com/pages/:NFC-READER-LIBRARY

Page 31: 02 Webinar slides - how to integrate NFC controllers in Linux · the GNU environment. •Middleware to access a smart card using the SCard API. ... Linux libnfc-nci stack mapping

30

MIFARE applications

End-to-end systems, readers and card-related designs

EMVco applications

Readers, cards, design for test compliancy (including PCI)

Secure Element management

GlobalPlatform compliant backend solutions

Secure services provisioning OTA, TSM services

Software development in Android and iOS

Embedded software for MCUs

JCOP, Java Card operating Systems

Hardware design and development

Digital, analog, sensor acquisition, power management

Wireless communications WiFi, ZigBee, Bluetooth, BLE

Contactless antenna RF design, evaluation and testing

We help companies leverage the mobile

and contactless revolution

MobileKnowledge

Roc Boronat 117, P3M3

08018 Barcelona

(Spain)

Get in touch with us

www.themobileknowledge.com

[email protected]