User Guide for NXP models including: PN7220 Compliant NFC Controller, PN7220, Compliant NFC Controller, NFC Controller, Controller

PN7220 - Android porting guide

AN13971

PN7220, NCI, EMVCo, NFC Forum, Android, NFC

NXP B.V.

PN7220 - Android porting guide

18 sept. 2023 — This document provides guidelines for integrating a PN7220 NXP NCI-based NFC controller into an Android platform from a software perspective.

EMV L1 Compliant NFC Controller with NCI Interface Supporting EMV and NFC Forum Applications | NXP Semiconductors

PDF preview unavailable. Download the PDF instead.

AN13971
AN13971
PN7220 - Android porting guide
Rev. 1.0 -- 18 September 2023

Application note

Document information

Information

Content

Keywords

PN7220, NCI, EMVCo, NFC Forum, Android, NFC

Abstract

This document describes how to port PN7220 middleware release to Android.

NXP Semiconductors

Revision history

Revision history

Rev

Date

v.1.0

20230818

Description Initial version

AN13971
PN7220 - Android porting guide

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
2 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

1 Introduction
This document provides guidelines for integrating a PN7220 NXP NCI-based NFC controller into an Android platform from a software perspective.
It first explains how to install the required kernel driver, and then describes step-by-step how to customize the AOSP sources to add support for the PN7220 NFC controller. Figure 1 shows the architecture of the entire Android NFC stack.

EMVCoModeSwitchApp

EMVCo FW API

NFC Framework

EMVCo Framework

NxpNfcDiscoveryProfile API Nfc Service

LEGEND
AOSP

NXP-EMVCo NXP-Nfc Application

Frameworks

Nfc JNI LibNfc-Nci NFC HAL NFC Stack

EMVCo L2 Loopback CL App

EMVCo L2 Loopback CT App

Native

EMVCo HAL API

EMVCo HAL API EMVCo HAL API Interface

EMVCo HAL API HAL

EMVCo L1 Data Exchange Layer API

EMVCo L1 Data Exchange Layer

EMVCo Stack API Interface

Client Thread

OSAL Message Queue

EMVCo Mode Switch

EMVCo CT 7816 wrapper

Configuration

NCI Interface

Fragment data Handler

Logging

TML Write API Interface

TML Read Thread

HIF SEL

System API

NXP I2C Driver

Mode Switch

VEN

PN7220

I2C Data IRQ SPI

Linux Kernel
Mode Switch HW
SMCU

Figure 1.Android NFC stack PN7220 is separated into single-host and dual-host scenarios. In general, the stack is the same for dual host, we add SMCU. · The NXP I2C Driver is the kernel module that provides access to the hardware resources of the PN7220. · The HAL module is the implementation of the specific HW abstraction layer of the controller NXP NFC. · LibNfc-nci is a native library that provides NFC functionality. · NFC JNI is a glue code between Java and Native classes. · The NFC and EMVCo Framework is an application framework module that provides access to NFC and EMVCo functionality.

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
3 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

2 Kernel driver
The NFC Android stack uses a nxpnfc kernel driver to communicate with the PN7220. It is available here.
2.1 Driver details
The nxpnfc kernel driver offers communication with the PN7220 over an I2C physical interface. When loaded into the kernel, this driver exposes the interface to PN7220 through the device node named /dev/ nxpnfc.
2.2 Getting the source code
Clone the PN7220 driver repository into the kernel directory, replacing the existing implementation:
$rm -rf drivers/nfc $git clone "https://github.com/NXPNFCLinux/nxpnfc.git" -b PN7220-Driver drivers/
This ends up with the folder drivers/nfc containing the following files: · README.md: repository information · Makefile: driver heading makefile · Kconfig: driver configuration file · License: driver licensing terms · nfc subfolder containing:
­ commoc.c: generic driver implementation ­ common.h: generic driver interface definition ­ i2c_drv.c: i2c specific driver implementation ­ i2c_drv.h: i2c specific driver interface definition ­ Makefile: makefile that is included in the makefile of the driver ­ Kbuild => build file ­ Kconfig => driver configuration file
2.3 Building the driver
Including the driver into the kernel and making it load during the device boot is done thanks to the devicetree. After updating the device tree definition, the platform-related device tree must be rebuilt. NXP suggests using kernel version 5.10, since in this version complete validation is done. 1. Download the kernel 2. Get the driver source code. 3. Change the device tree definition (specific to the device that we are using). 4. Build the driver.
a. Through the menuconfig procedure, include the target driver in the build. After rebuilding the complete kernel, the driver will be included in the kernel image. We must make sure that all new kernel images are copied into the AOSP build.

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
4 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

3 AOSP adaptation
NXP provides patches on top of the AOSP code. That means that the user can first get an AOSP code and apply patches from NXP. This section describes how to accomplish this. The current AOSP tag that we are using is [1].
3.1 AOSP build
1. We must get the AOSP source code. This we can do with:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_r3
$ repo sync
Note: The repo tool must be installed on the system. Follow the instructions [2]. 2. When we have source code, we can enter the directory and build it:
$cd Android_AROOT $source build/envsetup.sh $lunch select_target #target is DH we want to use for example: db845c-userdebug $make -j
3. When AOSP is successfully built, we must get NXP patches. This we can do with:
$git clone "https://github.com/NXPNFCLinux/PN7220_Android13.git" vendor/nxp/
4. At this point, we have all needed to apply patches for PN7220 support. We can apply patches by running the install_NFC.sh script.
$chmod +x /vendor/nxp/nfc/install_NFC.sh #sometimes we need to add executable rights to script
$./vendor/nxp/nfc/install_NFC.sh
Note: Check the output after running install_NFC.sh. If needed, we must make some changes by hand. 5. We can also add FW binaries:
$git clone xxxxxxx $cp -r nfc-NXPNFCC_FW/InfraFW/pn7220/64-bit/libpn72xx_fw.so AROOT/vendor/nxp/ pn7220/firmware/lib64/libpn72xx_fw.so $cp -r nfc-NXPNFCC_FW/InfraFW/pn7220/32-bit/libpn72xx_fw.so AROOT/vendor/nxp/ pn7220/firmware/lib/libpn72xx_fw.so
6. Adding NFC to build In the device.mk makefile (for example, device/brand/platform/device.mk), include specific makefiles:
$(call inherit-product, vendor/nxp/nfc/device-nfc.mk)
In the BoardConfig.mk makefile (for example, device/brand/platform/BoardConfig.mk), include a specific makefile:
-include vendor/nxp/nfc/BoardConfigNfc.mk

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
5 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

7.Adding DTA application
$git clone https://github.com/NXPNFCProject/NXPAndroidDTA.git $git checkout NFC_DTA_v13.02_OpnSrc $patch -p1 AROOT_system_nfc-dta.patch $ cp -r nfc-dta /system/nfc-dta $<AROOT>/system/nfc-dta/$ mm -j
8.Now we can build AOSP again with all the changes we made:
$cd framework/base $mm $cd ../.. $cd vendor/nxp/frameworks $mm #after this one, we should see com.nxp.emvco.jar inside out/target/ product/xxxx/system/framwework/ $cd ../../.. $cd hardware/nxp/nfc $mm $cd ../../.. $make -j
Now, we are able to flash our device host with the Android image that includes NFC features.

3.2 Android NFC Apps and Lib on targets

In this subsection, we describe where specific compiled files are pushed. If there is any change, we can replace only that one file. Table 1 shows all locations.

Table 1.Compiled files with device target

Project location

Compiled Files

"$ANDROID_ROOT"/packages/ apps/Nfc

lib/NfcNci.apk oat/libnfc_nci_jni.so

"$ANDROID_ROOT"/system/nfc libnfc_nci.so

"$ANDROID_ROOT"/hardware/ nxp/nfc

nfc_nci_nxp_pn72xx.so android.hardware.nfc_72xx@1.2-service android.hardware.nfc_72xx@1.2-service.rc android.hardware.nfc@1.0.so android.hardware.nfc@1.1.so android.hardware.nfc@1.2.so

"$ANDROID_ROOT"/hardware/ nxp/nfc

vendor.nxp.nxpnfc@2.0.so

"$ANDROID_ROOT"/vendor/nxp/ com.nxp.emvco.jar frameworks

"$ANDROID_ROOT"/hardware/ nxp/emvco

emvco_poller.so android.hardware.emvco-service android.hardware.emvco-service.rc android.hardware.emvco-V1-ndk.so android.hardware.emvco-V2-ndk.so

Location in target device
/system/app/NfcNci/ /system/lib64/
/system/lib64/
/vendor/lib64 /vendor/bin/hw/ /vendor/etc/init system/lib64/ system/lib64/ system/lib64/
/system/lib64
/system/framework /vendor/framework
/vendor/lib64 /vendor/bin/hw/ /vendor/etc/init system/lib64/ system/lib64/

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
6 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

3.3 Patch mapping

Every patch must be applied to a specific location. Table 2 shows the patch name and the location where we must apply it and a block name, which shows us where in the NFC stack (Figure 1) is located.

Table 2.Patch location in NFC Stack Block name

Patch name

NFC HAL and EMVCo HAL

AROOT_hardware_interfaces.patch

NFC Stack

AROOT_hardware_nxp_nfc.patch

EMVCo L1 Data Exchange Layer = EMVCo AROOT_hardware_nxp_emvco.patch Stack

LibNfc-Nci

AROOT_system_nfc.patch

NFC JNI

AROOT_packages_apps_Nfc.patch

NFC Service

AROOT_packages_apps_Nfc.patch

NFC Framework

AROOT_frameworks_base.patch

EMVCo Framework

AROOT_vendor_nxp_frameworks.patch

Location to apply hardware/interfaces/ hardware/nxp/nfc/ hardware/nxp/emvco/
system/nfc/ packages/apps/nfc/ packages/apps/nfc/ frameworks/base/ vendor/nxp/frameworks/

3.4 Flashing images
Images can be found in /out/target/product/{selected_DH}. To flash system images, we must run the following commands (tested on the Dragonboard 845c).
$ adb reboot bootloader $ fastboot flash boot boot_uefi.img $ fastboot flash vendor_boot vendor_boot.img $ fastboot flash super super.img $ fastboot flash userdata userdata.img $ fastboot format:ext4 metadata $fastboot reboot
After the images are flashed, we must perform some MW clean-up by running the following commands (tested on the Dragonboard 845c).
$ adb wait-for-device $ adb root $ adb wait-for-device $ adb remount $ adb shell rm -rf vendor/etc/init/android.hardware.nfc@1.1-service.rc $ adb shell rm -rf vendor/etc/init/android.hardware.nfc@1.2-service.rc $ adb push Test_APK/EMVCoAidlHalComplianceTest/EMVCoAidlHalComplianceTest
system/etc $ adb shell chmod 0777 /system/etc/EMVCoAidlHalComplianceTest $ adb push Test_APK/EMVCoAidlHalDesfireTest/EMVCoAidlHalDesfireTest system/etc $ adb shell chmod 0777 /system/etc/EMVCoAidlHalDesfireTest $ adb push Test_APK/EMVCoModeSwitchApp/EMVCoModeSwitchApp.apk system/app/ EMVCoModeSwitchApp/EMVCoModeSwitchApp.apk $ adb shell sync $ adb reboot $ adb wait-for-device

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
7 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

3.5 Config files

In PN7220, we have four different configuration files.
1. libemvco-nxp.conf 2. libnfc-nci.conf 3. libnfc-nxp.conf 4. libnfc-nxp-eeprom.conf
Note: Pay attention that the configuration files provided in the example relate to the NFC controller demo board. These files must be adopted according to the targeted integration.
All four files must be pushed to the specific location.

Table 3.Locations of configuration files Name of configuration file libemvco-nxp.conf libnfc-nci.conf libnfc-nxp.conf libnfc-nxp-eeprom.conf

Location in device vendor/etc vendor/etc system/etc vendor/etc

libnfc-nxp-eeprom.conf

Table 4.libnfc-nxp-eeprom.conf explanation

Name

Explanation

NXP_SYS_CLK_ System clock source selection configuration SRC_SEL

NXP_SYS_CLK_ System clock frequency selection configuration FREQ_SEL

NXP_ENABLE_ DISABLE_ STANBY

Option to enable or disable Standby mode

NXP_ENABLE_ Option to enable or disable LPCD. DISABLE_LPCD

Default value 0x01 0x08 0x00
0x00

Note: If there is no clock configured, either PLL or Xtal, then the MW stack retries in a loop to get the clock and initialize successfully.
libnfc-nci.conf

Table 5.libnfc-nci.conf explanation Name APPL_TRACE_LEVEL PROTOCOL_TRACE_LEVEL NFC_DEBUG_ENABLED NFA_STORAGE HOST_LISTEN_TECH_MASK NCI_HAL_MODULE POLLING_TECH_MASK

Explanation Log levels for libnfc-nci Log levels for libnfc-nci NFC debug enable setting Set the target directory for NFC file storage Configure host listen feature NCI HAL Module name Configuration of the polling technologies

Default value 0xFF 0xFFFFFFFF 0x01 "/data/vendor/nfc" 0x07 "nfc_nci.pn54x" 0x0F

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
8 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

Table 5.libnfc-nci.conf explanation...continued

Name

Explanation

P2P_LISTEN_TECH_MASK

P2P is not supported in PN7220

PRESERVE_STORAGE

Verify the content of all nonvolatile stores.

AID_MATCHING_MODE

Provides different ways to match the AID

NFA_MAX_EE_SUPPORTED

Maximum EE supported number

OFFHOST_AID_ROUTE_PWR_STATE Set the OffHost AID supported state

Default value 0xC5 0x01 0x03 0x01 0x3B

libnfc-nxp.conf

Table 6.libnfc-nxp.conf explanation Name NXPLOG_EXTNS_LOGLEVEL NXPLOG_NCIHAL_LOGLEVEL
NXPLOG_NCIX_LOGLEVEL
NXPLOG_NCIR_LOGLEVEL
NXPLOG_FWDNLD_LOGLEVEL
NXPLOG_TML_LOGLEVEL
NXP_NFC_DEV_NODE MIFARE_READER_ENABLE
NXP_FW_TYPE NXP_I2C_FRAGMENTATION_ ENABLED NFA_PROPRIETARY_CFG NXP_EXT_TVDD_CFG NXP_EXT_TVDD_CFG_1
NXP_EXT_TVDD_CFG_2
NXP_CORE_CONF
NXP_CORE_CONF_EXTN
NXP_SET_CONFIG_ALWAYS
NXP_RF_CONF_BLK_1 ISO_DEP_MAX_TRANSCEIVE

Explanation
Configuration for extns logging level
Configuration for enabling logging of HAL
Configuration for enabling logging of NCI TX packets
Configuration for enabling logging of NCI RX packets
Configuration for enabling logging of FW download functionality
Configuration for enabling logging of TM
NFC Device Node name
Extension for NFC reader for MIFARE enable
Firmware file type
Configure I2C fragmentation
Set Vendor proprietary configuration
Set TVDD configuration mode
Configure TVDD settings according to TVDD mode selected
Configure TVDD settings according to TVDD mode selected
Configure standardized parts of the NFC controller
Configure proprietary parts of the NFC controller
Always send CORE_CONF and CORE_CONF_EXTN (not recommended enabling it.)
RF settings
Define maximum ISO-DEP extended APDU length

Default value 0x03 0x03 0x03 0x03 0x03 0x03 "/dev/nxpnfc" 0x01 0x01 0x00 {05, FF, FF, 06, 81, 80, 70, FF, FF} 0x02 Check config file Check config file { 20, 02, 07, 02, 21, 01, 01, 18, 01, 02 } {00, 00, 00, 00} 0x00
Check config file 0xFEFF

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
9 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

Table 6.libnfc-nxp.conf explanation...continued

Name

Explanation

PRESENCE_CHECK_ALGORITHM

Set the algorithm used for the T4T presence check procedure

NXP_FLASH_CONFIG

Flashing Options Configurations

Default value 2
0x02

libemvco-nxp.conf

Table 7.libemvco-nxp.conf explanation

Name

Explanation

NXP_LOG_EXTNS_LOGLEVEL

Configuration for extns logging level

NXP_LOG_NCIHAL_LOGLEVEL

Configuration for enabling logging of HAL

NXP_LOG_NCIX_LOGLEVEL

Configuration for enabling logging of NCI TX packets

NXP_LOG_NCIR_LOGLEVEL

Configuration for enabling logging of NCI RX packets

NXP_LOG_TML_LOGLEVEL

Configuration for enabling logging of TML

NXP_EMVCO_DEBUG_ENABLED

Enable debugging

NXP_EMVCO_DEV_NODE

EMVCo Device Node name

NXP_PCD_SETTINGS

Configuration to set polling delay between 2 phases

NXP_SET_CONFIG

Option to set config command for debugging purpose

NXP_GET_CONFIG

Option to get config command for debugging purpose

Default value 0x03 0x03 0x03
0x03
0x03 0x03 "/dev/nxpnfc" {20, 02, 07, 01, A0, 64, 03, EC, 13, 06} Check config file
Check config file

3.6 DTA APPLICATION
To allow NFC Forum certification testing, a device test application is provided. It is composed of several components in the different Android layers, which must be built and included in the Android image.
To push the DTA application, we must follow the next steps:
1. Copy all DTA files to one location
$cp -rf "out/target/product/hikey960/system/lib64/libosal.so" /DTA-PN7220 $cp -rf "out/target/product/hikey960/system/lib64/libmwif.so" /DTA-PN7220 $cp -rf "out/target/product/hikey960/system/lib64/libdta.so" /DTA-PN7220 $cp -rf "out/target/product/hikey960/system/lib64/libdta_jni.so" /DTA-PN7220 $cp -rf "out/target/product/hikey960/system/app/NxpDTA/NxpDTA.apk" /DTAPN7220
2. Push the binaries to the device as bellow
adb shell mkdir /system/app/NxpDTA/ adb push libosal.so /system/lib64/ adb push libdta.so /system/lib64/ adb push libdta_jni.so /system/lib64/ adb push libmwif.so /system/lib64/ adb push NxpDTA.apk /system/app/NxpDTA/

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
10 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

After flashing the target, the DTA application should then be present in the list of installed applications. Check UG for a detailed description of how to use the application.

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
11 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

4 i.MX 8M Nano porting

As an example, we show what porting to the i.MX 8M platform looks like. To get more information, check [3].

4.1 Hardware

At the moment, NXP does not provide the adapter board. Check Table 8 to see how to connect boards with wires.

Table 8.PN7220 to i.MX 8M Nano connections

PIN

PN7220

VEN

J27 - 7

IRQ

J27 - 6

SDA

J27 - 3

SCL

J27 - 2

MODE_SWITCH

J43 - 32

GND

J27 - 1

i.MX 8M NANO J003 - 40 J003 - 37 J003 - 3 J003 - 5 J003 - 38 J003 - 39

4.2 Software
The steps described in this section explain how we can port PN7200 to the i.MX 8M Nano platform. Same steps with a bit of modification, it can be used to port to any other DH that is running Android OS.
Note: In this porting example, we are using 13.0.0_1.0.0_Android_Source.
We can reuse patches related to AOSP code. What must be changed is:
1. Device tree (in i.MX 8M Nano, this is AROOT_vendor_nxp-opensource_imx_kernel.patch) 2. Device-specific patch (in i.MX 8M Nano, this is AROOT_device_nxp.patch)
In AROOT_vendor_nxp-opensource_imx_kernel.patch, we can see how the driver is included and how the device tree is built. This is specific to every device host since we must take care of pin configuration, and this is different between boards. We also must take care of menu configuration.
In AROOT_device_nxp.patch, we are including nfc into the build. In general, we are making sure, that all the services are included correctly, etc. When porting to a specific device host, take this patch as a reference and include all the things inside.
One additional thing we did in porting is located in the device-nfc.mk file:

We need to comment out following lines:

# BOARD_SEPOLICY_DIRS += vendor/$(NXP_VENDOR_DIR)/nfc/sepolicy \

#

vendor/$(NXP_VENDOR_DIR)/nfc/sepolicy/nfc

The reason for this is that we are including sepolicy in the device-specific BoardConfig.mk file. Steps to build images:

> Get AOSP code for i.MX8M Nano > Build AOSP > Get NXP patches ([5]) > Apply all patches with install_nfc.sh > cd framework/base > mm

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
12 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

> cd ../.. > cd vendor/nxp/frameworks > mm #after this one, we should see com.nxp.emvco.jar inside out/target/product/ imx8mn/system/framwework/ > cd ../../.. > cd hardware/nxp/nfc > mm > cd ../../.. > make > Download images and use uuu tool to flash i.MX8M Nano

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
13 / 21

NXP Semiconductors

5 Abbreviations

Table 9.Abbreviations

Acronym

Description

APDU

application protocol data unit

AOSP

Android open source project

DH

device host

HAL

hardware abstraction layer

FW

firmware

I2C

inter-integrated circuit

LPCD

lower powerd card detection

NCI

NFC controller interface

NFC

near-field communication

MW

middleware

PLL

phase-locked loop

P2P

peer to peer

RF

radio frequency

SDA

serial data

SMCU

secure microcontroller

SW

software

AN13971
PN7220 - Android porting guide

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
14 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

6 References
[1] AOSP r3 tag: https://android.googlesource.com/platform/manifest -b android-13.0.0_r3 [2] Source control tools: https://source.android.com/docs/setup/download [3] i.MX: https://www.nxp.com/design/software/embedded-software/i-mx-software/android-os-for-i-mx-
applications-processors:IMXANDROID [4] PN7220 kernel driver: https://github.com/NXPNFCLinux/nxpnfc/tree/PN7220-Driver [5] PN7220 MW: https://github.com/NXPNFCLinux/PN7220_Android13

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
15 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

7 Note about the source code in the document
Example code shown in this document has the following copyright and BSD-3-Clause license:
Copyright 2023 NXP Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials must be provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
16 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

8 Legal information
8.1 Definitions
Draft -- A draft status on a document indicates that the content is still under internal review and subject to formal approval, which may result in modifications or additions. NXP Semiconductors does not give any representations or warranties as to the accuracy or completeness of information included in a draft version of a document and shall have no liability for the consequences of use of such information.
8.2 Disclaimers
Limited warranty and liability -- Information in this document is believed to be accurate and reliable. However, NXP Semiconductors does not give any representations or warranties, expressed or implied, as to the accuracy or completeness of such information and shall have no liability for the consequences of use of such information. NXP Semiconductors takes no responsibility for the content in this document if provided by an information source outside of NXP Semiconductors. In no event shall NXP Semiconductors be liable for any indirect, incidental, punitive, special or consequential damages (including - without limitation lost profits, lost savings, business interruption, costs related to the removal or replacement of any products or rework charges) whether or not such damages are based on tort (including negligence), warranty, breach of contract or any other legal theory. Notwithstanding any damages that customer might incur for any reason whatsoever, NXP Semiconductors' aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms and conditions of commercial sale of NXP Semiconductors.
Right to make changes -- NXP Semiconductors reserves the right to make changes to information published in this document, including without limitation specifications and product descriptions, at any time and without notice. This document supersedes and replaces all information supplied prior to the publication hereof.
Suitability for use -- NXP Semiconductors products are not designed, 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 to result in personal injury, death or severe property or environmental damage. NXP Semiconductors and its suppliers accept no liability for inclusion and/or use of NXP Semiconductors products in such equipment or applications and therefore such inclusion and/or use is at the customer's own risk.
Applications -- Applications that are described herein for any of these products are for illustrative purposes only. NXP Semiconductors makes no representation or warranty that such applications will be suitable for the specified use without further testing or modification. Customers are responsible for the design and operation of their applications and products using NXP Semiconductors products, and NXP Semiconductors accepts no liability for any assistance with applications or customer product design. It is customer's sole responsibility to determine whether the NXP Semiconductors product is suitable and fit for the customer's applications and products planned, as well as for the planned application and use of customer's third party customer(s). Customers should provide appropriate design and operating safeguards to minimize the risks 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 customer's applications or products, or the application or use by customer's third party customer(s). Customer is responsible for doing all necessary testing for the customer's applications and products using NXP Semiconductors products in order to avoid a default of the applications and the products or of the application or use by customer's third party customer(s). NXP does not accept any liability in this respect.

Terms and conditions of commercial sale -- NXP Semiconductors products are sold subject to the general terms and conditions of commercial sale, as published at http://www.nxp.com/profile/terms, unless otherwise agreed in a valid written individual agreement. In case an individual agreement is concluded only the terms and conditions of the respective agreement shall apply. NXP Semiconductors hereby expressly objects to applying the customer's general terms and conditions with regard to the purchase of NXP Semiconductors products by customer.
Export control -- This document as well as the item(s) described herein may be subject to export control regulations. Export might require a prior authorization from competent authorities.
Suitability for use in non-automotive qualified products -- Unless this document expressly states that this specific NXP Semiconductors product is automotive qualified, the product is not suitable for automotive use. It is neither qualified nor tested in accordance with automotive testing or application requirements. NXP Semiconductors accepts no liability for inclusion and/or use of non-automotive qualified products in automotive equipment or applications.
In the event that customer uses the product for design-in and use in automotive applications to automotive specifications and standards, customer (a) shall use the product without NXP Semiconductors' warranty of the product for such automotive applications, use and specifications, and (b) whenever customer uses the product for automotive applications beyond NXP Semiconductors' specifications such use shall be solely at customer's own risk, and (c) customer fully indemnifies NXP Semiconductors for any liability, damages or failed product claims resulting from customer design and use of the product for automotive applications beyond NXP Semiconductors' standard warranty and NXP Semiconductors' product specifications.
Evaluation products -- This product is provided on an "as is" and "with all faults" basis for evaluation purposes only. NXP Semiconductors, its affiliates and their suppliers expressly disclaim all warranties, whether express, implied or statutory, including but not limited to the implied warranties of noninfringement, merchantability and fitness for a particular purpose. The entire risk as to the quality, or arising out of the use or performance, of this product remains with customer.
In no event shall NXP Semiconductors, its affiliates or their suppliers be liable to customer for any special, indirect, consequential, punitive or incidental damages (including without limitation damages for loss of business, business interruption, loss of use, loss of data or information, and the like) arising out the use of or inability to use the product, whether or not based on tort (including negligence), strict liability, breach of contract, breach of warranty or any other theory, even if advised of the possibility of such damages.
Notwithstanding any damages that customer might incur for any reason whatsoever (including without limitation, all damages referenced above and all direct or general damages), the entire liability of NXP Semiconductors, its affiliates and their suppliers and customer's exclusive remedy for all of the foregoing shall be limited to actual damages incurred by customer based on reasonable reliance up to the greater of the amount actually paid by customer for the product or five dollars (US$5.00). The foregoing limitations, exclusions and disclaimers shall apply to the maximum extent permitted by applicable law, even if any remedy fails of its essential purpose.
Translations -- A non-English (translated) version of a document, including the legal information in that document, is for reference only. The English version shall prevail in case of any discrepancy between the translated and English versions.

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
17 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

Security -- Customer understands that all NXP products may be subject to unidentified vulnerabilities or may support established security standards or specifications with known limitations. Customer is responsible for the design and operation of its applications and products throughout their lifecycles to reduce the effect of these vulnerabilities on customer's applications and products. Customer's responsibility also extends to other open and/or proprietary technologies supported by NXP products for use in customer's applications. NXP accepts no liability for any vulnerability. Customer should regularly check security updates from NXP and follow up appropriately.
Customer shall select products with security features that best meet rules, regulations, and standards of the intended application and make the ultimate design decisions regarding its products and is solely responsible for compliance with all legal, regulatory, and security related requirements concerning its products, regardless of any information or support that may be provided by NXP.
NXP has a Product Security Incident Response Team (PSIRT) (reachable at PSIRT@nxp.com) that manages the investigation, reporting, and solution release to security vulnerabilities of NXP products.
NXP B.V. - NXP B.V. is not an operating company and it does not distribute or sell products.

8.3 Licenses
Purchase of NXP ICs with NFC technology -- Purchase of an NXP Semiconductors IC that complies with one of the Near Field Communication (NFC) standards ISO/IEC 18092 and ISO/IEC 21481 does not convey an implied license under any patent right infringed by implementation of any of those standards. Purchase of NXP Semiconductors IC does not include a license to any NXP patent (or other IP right) covering combinations of those products with other products, whether hardware or software.
8.4 Trademarks
Notice: All referenced brands, product names, service names, and trademarks are the property of their respective owners. NXP -- wordmark and logo are trademarks of NXP B.V. EdgeVerse -- is a trademark of NXP B.V. i.MX -- is a trademark of NXP B.V. I2C-bus -- logo is a trademark of NXP B.V. Oracle and Java -- are registered trademarks of Oracle and/or its affiliates.

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
18 / 21

NXP Semiconductors

AN13971
PN7220 - Android porting guide

Tables

Tab. 1. Tab. 2. Tab. 3. Tab. 4. Tab. 5.

Compiled files with device target .......................6 Patch location in NFC Stack ............................. 7 Locations of configuration files ..........................8 libnfc-nxp-eeprom.conf explanation ...................8 libnfc-nci.conf explanation ................................. 8

Tab. 6. Tab. 7. Tab. 8. Tab. 9.

libnfc-nxp.conf explanation ................................9 libemvco-nxp.conf explanation ........................ 10 PN7220 to i.MX 8M Nano connections ........... 12 Abbreviations ...................................................14

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
19 / 21

NXP Semiconductors
Figures
Fig. 1. Android NFC stack ............................................3

AN13971
PN7220 - Android porting guide

AN13971
Application note

All information provided in this document is subject to legal disclaimers.
Rev. 1.0 -- 18 September 2023

© 2023 NXP B.V. All rights reserved.
20 / 21

NXP Semiconductors

Contents

1

Introduction ......................................................... 3

2

Kernel driver ........................................................4

2.1

Driver details ......................................................4

2.2

Getting the source code .................................... 4

2.3

Building the driver ..............................................4

3

AOSP adaptation .................................................5

3.1

AOSP build ........................................................ 5

3.2

Android NFC Apps and Lib on targets ............... 6

3.3

Patch mapping ...................................................7

3.4

Flashing images ................................................ 7

3.5

Config files .........................................................8

3.6

DTA APPLICATION ......................................... 10

4

i.MX 8M Nano porting ....................................... 12

4.1

Hardware ......................................................... 12

4.2

Software ...........................................................12

5

Abbreviations .................................................... 14

6

References ......................................................... 15

7

Note about the source code in the

document ........................................................... 16

8

Legal information .............................................. 17

AN13971
PN7220 - Android porting guide

Please be aware that important notices concerning this document and the product(s) described herein, have been included in section 'Legal information'.

© 2023 NXP B.V.

All rights reserved.

For more information, please visit: http://www.nxp.com
Date of release: 18 September 2023 Document identifier: AN13971


Apache FOP Version 2.6