logo资料库

nfc controller interface 安卓技术指导.pdf

第1页 / 共38页
第2页 / 共38页
第3页 / 共38页
第4页 / 共38页
第5页 / 共38页
第6页 / 共38页
第7页 / 共38页
第8页 / 共38页
资料共38页,剩余部分请下载后查看
1. Introduction
2. Kernel driver
2.1 Driver details
2.2 Installation instructions
2.2.1 Getting the driver
2.2.2 Including the driver to the kernel
2.2.3 Creating the device node
2.2.3.1 Device tree
2.2.3.2 Platform data
2.2.4 Building the driver
3. AOSP adaptation
3.1 Android Pie
3.1.1 Step 1: retrieving NXP-NCI NFC delivery
3.1.2 Step 2: installing NXP-NCI delivery
3.1.3 Step 3: updating configuration files
3.1.4 Step 4: adding NFC to the build
3.1.5 Step 5: building and installing NFC
3.1.6 Step 6: verifying NFC functionality
3.2 Android Oreo
3.2.1 Step 1: retrieving NXP-NCI NFC delivery
3.2.2 Step 2: installing NXP-NCI delivery
3.2.3 Step 3: updating configuration files
3.2.4 Step 4: adding NFC to the build
3.2.5 Step 5: changing device owner and permissions
3.2.6 Step 6: building and installing NFC
3.2.7 Step 7: verifying NFC functionality
3.3 Android Nougat
3.3.1 Step 1: retrieving NXP-NCI NFC delivery
3.3.2 Step 2: installing NXP-NCI delivery
3.3.3 Step 3: updating configuration files
3.3.4 Step 4: adding NFC to the build
3.3.5 Step 5: changing device owner and permissions
3.3.6 Step 6: building and installing NFC
3.3.7 Step 7: verifying NFC functionality
3.4 Android Marshmallow
3.4.1 Step 1: retrieving NXP-NCI NFC delivery
3.4.2 Step 2: installing NXP-NCI delivery
3.4.3 Step 3: updating configuration files
3.4.4 Step 4: adding NFC to the build
3.4.5 Step 5: changing device owner and permissions
3.4.6 Step 6: building and installing NFC
3.4.7 Step 7: verifying NFC functionality
3.5 Android Lollipop
3.5.1 Step 1: retrieving NXP-NCI NFC delivery
3.5.2 Step 2: installing NXP-NCI delivery
3.5.3 Step 3: updating configuration files
3.5.4 Step 4: adding NFC to the build
3.5.5 Step 5: changing device owner and permissions
3.5.6 Step 6: building and installing NFC
3.5.7 Step 7: verifying NFC functionality
3.6 Android KitKat
3.6.1 Step 1: getting the release package
3.6.2 Step 2: merging files
3.6.3 Step 3: selecting the NFC Controller
3.6.4 Step 4: adding NFC to the build
3.6.5 Step 5: changing device owner and permissions
3.6.6 Step 6: building and installing NFC
3.6.7 Step 7: verifying NFC functionality
3.7 Others Android versions
4. Configuration Files
4.1 Android Pie
4.2 Android Oreo
4.3 Android Nougat and previous versions
5. Factory Test native application
6. Troubleshooting
6.1 Device node rights
6.2 Configuration files
6.3 NXP’s NFC library
6.4 NFC Controller choice
7. Legal information
7.1 Definitions
7.2 Disclaimers
7.3 Licenses
7.4 Trademarks
8. Contents
AN11690 NXP NCI Android Porting Guidelines Rev. 1.6 — 8 October 2018 333216 COMPANY PUBLIC Application note Document information Info Keywords Abstract Content Android, NFC, NXP, NCI, PN7120, PN7150 This note describes how to add support for a NXP NCI based NFC Controller to an Android system
NXP Semiconductors Revision history Date Rev 1.6 20181008 1.5 1.4 1.3 1.2 1.1 1.0 20180330 20170530 20170512 20160819 20160525 20150602 AN11690 NXP NCI Android Porting Guidelines Description Repositories moved back to GitHub Added support for Android Pie (PN7150 only) Repositories moved to CodeAurora Added support for Android Oreo (PN7150 only) Added description of the NFC Factory Test native application • Added support for Android Nougat • Added note about porting to other Android versions than referenced ones • • Added information about sepolicy definition in the troubleshooting section Fixed typo about kernel driver repository address Added support for Android Marshmallow Update for PN7150 support First release Contact information For more information, please visit: http://www.nxp.com AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 2 of 38
NXP Semiconductors AN11690 NXP NCI Android Porting Guidelines 1. Introduction This document provides guidelines for the integration of NXP NCI based NFC Controller to an Android platform from software perspective. It first explains how install the required kernel driver, then it describes step by step how to adapt the Android Open Source Project sources from the NXP-NCI Android NFC package delivery. Fig 1 shows the architecture of the Android NFC stack. Android NFC API JNI API Kernel API Physical interface Android app using NFC App layer (Java) NFC service NXP extension App framework (Java) Java Native Interface (JNI) NXP extension NFC Controller Interface (libnfc-nci) NXP extension Native libraries (C/C++) Other NCI HAL NXP NCI HAL PN5xx I2C Driver Linux kernel drivers (I2C, GPIO…) Linux kernel NXP NCI NFC Controller Fig 1. Android NFC stack overview • The pn5xx_I2c driver is the kernel module allowing to access NXP NCI based NFC Controller hardware resource. • The NXP NCI HAL module is the implementation of NXP NFC Controller’s specific Hardware Abstraction Layer. • The libnfc-nci is the native library providing NFC functionality for which extension is added to support NXP proprietary features (e.g. support for MIFARE Classic). • The JNI is a glue code between Java and Native classes. Extension exposes related additional interface. • The NFC service is the application framework module providing access to NFC functionality. Extension is delivered to support NXP proprietary features. AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 3 of 38
NXP Semiconductors 2. Kernel driver AN11690 NXP NCI Android Porting Guidelines The NXP-NCI Android stack uses PN5xx I2C kernel mode driver to communicate with the NXP NCI NFC Controller. It is available from the following repository: https://github.com/NXPNFCLinux/nxp-pn5xx. 2.1 Driver details The PN5xx I2C driver offers communication to the NFC Controller connected over I2C physical interface. This is insured through the device node named /dev/pn544. This low- level driver is compatible with a broad range of NXP’s NFC Controllers (e.g. PN544). 2.2 Installation instructions The following instructions assume the driver being installed under the drivers/misc kernel source sub-folder. Below instructions may have to be adapted accordingly in case another path is chosen for the driver installation. 2.2.1 Getting the driver Clone the nxp-pn5xx repository into the kernel directory: $ cd drivers/misc $ git clone https://github.com/NXPNFCLinux/nxp-pn5xx.git 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 2.2.2 Including the driver to the kernel Include the driver to the compilation by adding below line to the heading makefile (drivers/misc/Makefile). obj-y += nxp-pn5xx/ Include the driver config by adding below line to the heading configuration file (drivers/misc/Kconfig). source "drivers/misc/nxp-pn5xx/Kconfig" AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 4 of 38
NXP Semiconductors AN11690 NXP NCI Android Porting Guidelines 2.2.3 Creating the device node Two methods are supported for the creation of the /dev/pn544 device node: device tree and platform data. Any of the two methods can be used, but of course the I2C address (0x28 in the below examples) and GPIO assignments must be adapted to the hardware integration in the platform. 2.2.3.1 Device tree Below is an example of definition to be added to the platform device tree file (.dts file located for instance under arch/arm/boot/dts kernel sub-folder for ARM based platform). &i2c{ status = "okay"; pn547: pn547@28 { compatible = "nxp,pn547"; reg = <0x28>; clock-frequency = <400000>; interrupt-gpios = <&gpio2 17 0>; enable-gpios = <&gpio4 21 0>; }; }; 2.2.3.2 Platform data Below is an example of definition to be added to the platform definition file. The structure pn544_i2c_platform_data being defined in the driver interface header file, pn5xx_i2c.h must be included in the platform definition file, and pn5xx_i2c.h file must be copied to include/linux kernel source sub-folder. static struct pn544_i2c_platform_data nfc_pdata = { .irq_gpio = GPIO_TO_PIN(1,29), .ven_gpio = GPIO_TO_PIN(0,30), .firm_gpio = GPIO_UNUSED .clkreq_gpio = GPIO_UNUSED }; static struct i2c_board_info __initdata nfc_board_info[] = { { I2C_BOARD_INFO("pn547", 0x28), .platform_data = &nfc_pdata, }, }; Then the declared nfc_board_info structure must be added to the platform using dedicated procedure (platform specific). AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 5 of 38
NXP Semiconductors 2.2.4 Building the driver AN11690 NXP NCI Android Porting Guidelines Through menuconfig procedure include the driver to the build, as built-in (<*>) or modularizes features (): Device Drivers ---> Misc devices ---> < > NXP PN5XX based driver If option is selected, build the driver and install the generated pn5xx_i2c.ko module. Otherwise if built-in, rebuild the complete kernel, the driver will be included in the kernel image. If the device tree method was used in previous step, build the platform related device tree and install generated dtb file. AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 6 of 38
NXP Semiconductors 3. AOSP adaptation 3.1 Android Pie AN11690 NXP NCI Android Porting Guidelines Below step-by-step procedure is based on NXP’s Android NFC delivery from https://github.com/NXPNFCLinux/nxpnfc_android_pie repository. The current release is based on Android AOSP 9.0.0 version, porting on other Pie version may requires minor adaptation of API (detected when compiling). Pay attention that the AOSP adaptation of Android Pie is only delivered for PN7150 support. 3.1.1 Step 1: retrieving NXP-NCI NFC delivery Clone repository into AOSP source directory: $ git clone https://github.com/NXPNFCLinux/nxpnfc_android_pie.git vendor/nxp/nfc 3.1.2 Step 2: installing NXP-NCI delivery Run the installation script: $ ./NxpNfcAndroid/install_NFC.sh This will: - Patch the AOSP hardware/nxp/nfc implementation to add PN7150 specific support - Patch the AOSP packages/apps/Nfc to add support for PN7150 AGC debug feature 3.1.3 Step 3: updating configuration files Adapt the libnfc-nci.conf and libnfc-nxp.conf files located in vendor/nxp/nfc/hw/pn7150/conf sub-folder, created at step 1, according to the integration specificities. For instance if using a system clock instead of an on-board crystal, the value of parameter “NXP_SYS_CLK_SRC_SEL” in libnfc-nxp.conf must reflect this configuration. More details about the configuration files can be find in chapter “4 Configuration Files”. 3.1.4 Step 4: adding NFC to the build In the device.mk makefile (e.g. device/brand/platform/device.mk), include specific makefile $(call inherit-product, vendor/nxp/nfc/device-nfc.mk) AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 7 of 38
NXP Semiconductors AN11690 NXP NCI Android Porting Guidelines In the BoardConfig.mk makefile (e.g. device/brand/platform/BoardConfig.mk), include specific makefile -include vendor/nxp/nfc/BoardConfigNfc.mk 3.1.5 Step 5: building and installing NFC Build and flash the system image (the boot image shall already contain the kernel driver as instructed in chapter “2. Kernel driver”). 3.1.6 Step 6: verifying NFC functionality In “Settings” app check NFC is ON. NFC functionality should be then up and running, ready to discover NFC tags or exchange data with remote NFC devices. AN11690 Application note COMPANY PUBLIC 333216 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2018. All rights reserved. Rev. 1.6 — 8 October 2018 8 of 38
分享到:
收藏