NFC Knowledge Base

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NFC Knowledge Base

Discussions

Sort by:
This post provides guidance on how to port the example projects from the NXP NCI 2.0 NFC library to the MCXW71 Wireless MCU using SPI interface to communicate with PN7160 SPI EVK. To follow this guide, please use the following environment: MCUXpresso IDE 25.06.136. FRDM-MCXW71 SDK v25.12.00 (last available for MCUXpresso IDE). FRDM-MCXW71. OM27160B1 (PN7160 SPI EVK). Hardware Setup. The MCXW71 complies with the Arduino header standard as the OM27160B1 board, therefore you can connect directly the shield over the FRDM-MCXW71 as the pin connection match among both, allowing an easy connection between the devices. Take into consideration that this setup forces us to use the LPSPI1 instance of the MCXW71, it is possible to use another instance, but we would not be able to connect the boards directly, rather we would need to do the connections with jumpers. Downloading base projects and adapting for MCXW71 port. To start with the porting work, download the NXP-NCI example project from this page. This compressed file contains the base project for different boards that will allow us to do the required modifications to add support for the MCXW71. Once downloaded, extract the SW6705 file into a known path (e.g. the Downloads folder) to later import the project to the IDE. The extracted folder should contain a .zip file with the examples that we will later import to the IDE. Download the FRDM-MCXW71's SDK from the SDK Builder page, make sure to select the 25.12.00 version, as it is the latest SDK available to use along the MCUXpresso IDE. Now we have to import the NXP-NCI2.0_MCUXpresso_examples.zip file we previously extracted to the IDE's workspace, to do so, click on the Import project(s) from file system and in the Project archive (zip) tab, browse for the extracted file of step 1 (NXP-NCI2.0_MCUXpresso_examples.zip) and click on Next >. NOTE: Don’t worry if the IDE shows an error message for not having the SDKs of the default boards (iMXRT1170, LPC55S6x, LPC82x) or having a different version, close the warning message, we only need these examples to copy the NCI library and example files. Your workspace should now look like the following image: Import the hello_world example from the FRDM-MCXW71 SDK: Add the SPI drivers to the imported project by right clicking over the project, hover the cursor over the SDK Management option and select the option Manage SDK Components: Select the driver, click Ok and if you are asked to refresh files accept it, after this you should be able to see the driver in the "drivers" folder of the project. Copy the contents of the source folder of the iMXRT1170 project, as well as the NfcLibrary folder and paste them into the imported hello_world project:          Make sure to delete the hello_world.c and hello_word.mex files as we won't need it again.             After this process your project should look like the following image: To avoid compiling issues, exclude from the build the files nfc_example_P2P.c and nfc_example_RW.c, to do so right click on the file, go to Resource Configurations and select Exclude from Build… and select for all configurations. Do this for each file. Add the preprocessor macro: BOARD_NXPNCI_INTERFACE_SPI, as this is used by the example to select the interface with the board. To do this, right-click on the project and select Properties, then drop-down the C/C++ Build option and go to the Settings tab. Here, add the macro in the Preprocessor option, click on Apply and accept the index rebuild. Add the root folder in C/C++ General > Paths and Symbols > Source Location tab, click on Ok and then Apply: Still in Paths and Symbols, go to the Includes tab and add the source, TML and tool folders from workspace, click Ok and Apply. Make sure to add them one by one. Now, go to C/C++ Build > Settings > Includes and add the following folders from Workspace. You can select all of them and add them at the same time or also do it one by one. Once done, click on Apply and Apply and Close. If you are asked to rebuild the index, do it. "${workspace_loc:/${ProjName}/source/TML}" "${workspace_loc:/${ProjName}/source/tool}" "${workspace_loc:/${ProjName}/NfcLibrary}" "${workspace_loc:/${ProjName}/NfcLibrary/inc}" "${workspace_loc:/${ProjName}/NfcLibrary/NdefLibrary}" "${workspace_loc:/${ProjName}/NfcLibrary/NdefLibrary/inc}" "${workspace_loc:/${ProjName}/NfcLibrary/NdefLibrary/src}" "${workspace_loc:/${ProjName}/NfcLibrary/NxpNci20}" "${workspace_loc:/${ProjName}/NfcLibrary/NxpNci20/inc}" "${workspace_loc:/${ProjName}/NfcLibrary/NxpNci20/src}" Source Code Changes. In the board folder, open the board.h file and add the following definitions to refer to the peripherals and clocks to be used. Please notice that you may change the LPSPI instance, however you would need to connect jumpers instead of connecting directly the shield over the FRDM. #ifdef BOARD_NXPNCI_INTERFACE_SPI #define BOARD_NXPNCI_SPI_CLOCK (CLOCK_GetIpFreq(kCLOCK_Lpspi1)) #define BOARD_NXPNCI_SPI_INSTANCE (LPSPI1) #define BOARD_NXPNCI_SPI_BAUDRATE (400000) #endif #define BOARD_NXPNCI_IRQ_PORT (GPIOC) // J2.10 - GPIO0 [PN7160] - IRQ -> J2.10 GPIOC0 [MCXW71] #define BOARD_NXPNCI_VEN_PORT (GPIOA) // J4.1 - GPIO1 [PN7160] - VEN -> J1.8 GPIOA21 [MCXW71] #define BOARD_NXPNCI_DWL_PORT (GPIOA) // J4.2 - GPIO2 [PN7160] - REQ -> J1.7 GPIOA20 [MCXW71] #define BOARD_NXPNCI_IRQ_PIN (0U) #define BOARD_NXPNCI_VEN_PIN (21U) #define BOARD_NXPNCI_DWL_PIN (20U)   Now we need to add the required clock, peripheral and pin initialization for our board. To do this, go to the hardware_init.c file inside the board folder, and overwrite the BOARD_InitHardware function with the following: void BOARD_InitHardware(void) { BOARD_InitPins(); BOARD_BootClockRUN(); BOARD_InitDebugConsole(); CLOCK_SetIpSrc(kCLOCK_Lpspi1, kCLOCK_IpSrcFro192M); CLOCK_SetIpSrcDiv(kCLOCK_Lpspi1, kSCG_SysClkDivBy16); }   To add the correct pin multiplexing and configuration for our SPI and GPIO pins, go to the pin_mux.c file (also in the board folder) and overwrite the BOARD_InitPins function with the following: void BOARD_InitPins(void) { /* Clock Configuration: Peripheral clocks are enabled; module does not stall low power mode entry */ CLOCK_EnableClock(kCLOCK_GpioA); CLOCK_EnableClock(kCLOCK_GpioC); CLOCK_EnableClock(kCLOCK_PortA); CLOCK_EnableClock(kCLOCK_PortB); CLOCK_EnableClock(kCLOCK_PortC); /*IF SHORTING SH11, SH12, SH13, SH14 needed for LPSPI1*/ const port_pin_config_t portb0_pin46_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_PCS0 */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTB0 (pin 46) is configured as LPSPI1_PCS0 */ PORT_SetPinConfig(PORTB, 0U, &portb0_pin46_config); const port_pin_config_t portb1_pin47_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_SIN */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTB1 (pin 47) is configured as LPSPI1_SIN */ PORT_SetPinConfig(PORTB, 1U, &portb1_pin47_config); const port_pin_config_t portb3_pin1_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_SOUT */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTB3 (pin 1) is configured as LPSPI1_SOUT */ PORT_SetPinConfig(PORTB, 3U, &portb3_pin1_config); const port_pin_config_t portb2_pin48_config = {/* Internal pull-up resistor is enabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPSPI0_SCK */ (uint16_t)kPORT_MuxAlt2, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTA19 (pin 14) is configured as LPSPI1_SCK */ PORT_SetPinConfig(PORTB, 2U, &portb2_pin48_config); /*IF SHORTING SH11, SH12, SH13, SH14 needed for LPSPI1*/ const port_pin_config_t irq_pin = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullUp, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as PTC0 */ (uint16_t)kPORT_MuxAsGpio, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTC0 (pin 37) is configured as PTC0 */ PORT_SetPinConfig(PORTC, 0U, &irq_pin); const port_pin_config_t ven_pin = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as PTA20 */ (uint16_t)kPORT_MuxAsGpio, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTA20 (pin 17) is configured as PTA20 */ PORT_SetPinConfig(PORTA, 20U, &ven_pin); const port_pin_config_t req_pin = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as PTA21 */ (uint16_t)kPORT_MuxAsGpio, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTA21 (pin 18) is configured as PTA21 */ PORT_SetPinConfig(PORTA, 21U, &req_pin); const port_pin_config_t portc2_pin39_config = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPUART1_RX */ (uint16_t)kPORT_MuxAlt3, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTC2 (pin 39) is configured as LPUART1_RX */ PORT_SetPinConfig(PORTC, 2U, &portc2_pin39_config); const port_pin_config_t portc3_pin40_config = {/* Internal pull-up/down resistor is disabled */ (uint16_t)kPORT_PullDisable, /* Low internal pull resistor value is selected. */ (uint16_t)kPORT_LowPullResistor, /* Fast slew rate is configured */ (uint16_t)kPORT_FastSlewRate, /* Passive input filter is disabled */ (uint16_t)kPORT_PassiveFilterDisable, /* Open drain output is disabled */ (uint16_t)kPORT_OpenDrainDisable, /* Low drive strength is configured */ (uint16_t)kPORT_LowDriveStrength, /* Normal drive strength is configured */ (uint16_t)kPORT_NormalDriveStrength, /* Pin is configured as LPUART1_TX */ (uint16_t)kPORT_MuxAlt3, /* Pin Control Register fields [15:0] are not locked */ (uint16_t)kPORT_UnlockRegister}; /* PORTC3 (pin 40) is configured as LPUART1_TX */ PORT_SetPinConfig(PORTC, 3U, &portc3_pin40_config); }   To add the required interfacing APIs specific of our chip, we need to modify the tml.c file from the TML folder, in this file overwrite the functions: INTF_INIT, INTF_WRITE and INTF_READ with the following: static void INTF_INIT(void) { lpspi_master_config_t userConfig; uint32_t srcFreq = 0; /*SPI configuration*/ LPSPI_MasterGetDefaultConfig(&userConfig); userConfig.baudRate = BOARD_NXPNCI_SPI_BAUDRATE; srcFreq = BOARD_NXPNCI_SPI_CLOCK; userConfig.whichPcs = (lpspi_which_pcs_t)kLPSPI_Pcs0; userConfig.pcsActiveHighOrLow = (lpspi_pcs_polarity_config_t)kLPSPI_PcsActiveLow; /*Initialize SPI*/ LPSPI_MasterInit(BOARD_NXPNCI_SPI_INSTANCE, &userConfig, srcFreq); } static status_t INTF_WRITE(uint8_t *pBuff, uint16_t buffLen) { uint8_t temp[1000]; temp[0] = 0x7F; memcpy(temp+1, pBuff, buffLen); masterXfer.txData = temp; masterXfer.rxData = NULL; masterXfer.dataSize = buffLen+1; masterXfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;; return LPSPI_MasterTransferBlocking(BOARD_NXPNCI_SPI_INSTANCE, &masterXfer); } static status_t INTF_READ(uint8_t *pBuff, uint16_t buffLen) { status_t status; uint8_t temp[257]; temp[0] = 0xFF; masterXfer.txData = temp; masterXfer.rxData = temp; masterXfer.dataSize = buffLen+1; masterXfer.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous | kLPSPI_MasterByteSwap;; status = LPSPI_MasterTransferBlocking(BOARD_NXPNCI_SPI_INSTANCE, &masterXfer); if(status == kStatus_Success) memcpy(pBuff, temp+1, buffLen); SDK_DelayAtLeastUs(10, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY); return status; } #endif   We also need to overwrite the functions: tml_Init, tml_DeInit and tml_Reset to adapt them to use the specific APIs for the GPIOs of our board. static Status tml_Init(void) { gpio_pin_config_t in_config = {kGPIO_DigitalInput, 0}; gpio_pin_config_t out_config = {kGPIO_DigitalOutput, 0}; GPIO_PinInit(BOARD_NXPNCI_IRQ_PORT, BOARD_NXPNCI_IRQ_PIN, &in_config); GPIO_PinInit(BOARD_NXPNCI_VEN_PORT, BOARD_NXPNCI_VEN_PIN, &out_config); GPIO_PinInit(BOARD_NXPNCI_DWL_PORT, BOARD_NXPNCI_DWL_PIN, &out_config); INTF_INIT(); return SUCCESS; } static Status tml_DeInit(void) { GPIO_PortClear(BOARD_NXPNCI_VEN_PORT, 1U << BOARD_NXPNCI_VEN_PIN); return SUCCESS; } static Status tml_Reset(void) { /* Set DWL_REQ low for NCI protocol */ GPIO_PortClear(BOARD_NXPNCI_DWL_PORT, 1U << BOARD_NXPNCI_DWL_PIN); GPIO_PortClear(BOARD_NXPNCI_VEN_PORT, 1U << BOARD_NXPNCI_VEN_PIN); Sleep(10); GPIO_PortSet(BOARD_NXPNCI_VEN_PORT, 1U << BOARD_NXPNCI_VEN_PIN); Sleep(10); return SUCCESS; }   Finally, modify the main file so it uses the APIs to initialize our board clocks and pins: #include <stdio.h> #include <string.h> #include "app.h" #include "board.h" #include "pin_mux.h" #include "fsl_debug_console.h" extern void nfc_example (void); int main(void) { BOARD_InitHardware(); #ifdef BOARD_NXPNCI_INTERFACE_I2C PRINTF("\nRunning the NXP-NCI2.0 example (I2C interface)\n"); #else PRINTF("\nRunning the NXP-NCI2.0 example (SPI interface)\n"); #endif nfc_example(); } Testing the example. At this point we have everything set to build and flash our example with SPI interface, you may proceed to build and debug/flash the example by pressing the blue beetle button: Once the example is flashed, open a serial terminal such as Teraterm with the following settings: Baudrate: 115200. Data: 8 bits. Parity: None. Stop bits: 1 bit. No flow control. While running, the example should output the following logs to the terminal: When a tag is placed near the antenna, the example should print the tag information in the terminal as shown:  
View full article
RF power regulation is a critical factor in the development of NFC devices, as it directly influences performance, reliability, and compliance with industry standards. There are three main reasons for this:  If the PN7642 VUP current exceeds the limit given by the product Data sheet, the PN7642 can be damaged. If too high RF power is radiated from the antenna, there exists a risk for NFC Cards. Too high RF power might lead to exceeding a given RF limit (NFC Forum, ISO, EMVCo). NXP provides comprehensive documentation on Dynamic Power Control for the PN7642 and PN5190. Designers are expected to adhere to these guidelines, especially when aiming for compliance with standards such as EMVCo. PN5190 Dynamic Power Control Quick Calibration and TxShaping Demo Automatic DPC Calibration for PN7642 and PN5190 However, if the user's design is intended for infrastructure applications, such as a smart lock. At a minimum, Dynamic Power Control (DPC) should be enabled to serve as a current limiter. The evaluation can be done with the help of NFC Cockpit.  1// Start DPC Calibration  "Press" Start DPC Calibration  "Press" Load protocol  Make sure that the DPC is "Enabled" 2// Adjust current reduction table  Set all entries to "0" Write into EEPROM   3// Set the "Target" current Use approx. the same current as "TxLDO Values"  The limit may be set higher, e.g., to 300 mA, if the purpose is solely to provide overcurrent protection for the IC. Save to EEPROM Restart the board (Close port -> Press VEN->Open port)   4// Check the power regulation  Start DPC Calibration  Place a card or any metal object in the antenna's proximity  Observe VDDPA and "TxLDO" current  The current should stay around the given target  The VDDPA will drop once the antenna is loaded  5// Set a minimum VDDPA in DPC  In the case that the current is still too high, a user can define a minimum VDDPA that is used for the DPC regulation. By default, this value is set to 2.2V. The user can decrease it up to 1.5V.  In that case, NXP also recommends disabling the RDOn control.  Note: The User has to consider the "DPC_TXLDO_MAX_DROPOUT" parameter, which defines the maximum voltage drop on TXLDO. By default, it is set to 3.6 V. That means if the user wants to use the minimum VDDPA 1.5 V, then the maximum TXLDO input shall not exceed 5.1 V. This feature protects the TXLDO from overheating.    Once the evaluation is done, the customer shall program the following EEPROM entries in their application. For more info, see PN7642 Product Data sheet.  DPC_CONFIG (Address: 0x0068) -> example: enabled -> 0x01 DPC_TARGET_CURRENT (Address: 0x0069) -> example: 229 mA -> 0xE5 DPC_TXLDO_MAX_DROPOUT (Addresses: 0x0073 - 0x0074) -> example: 3.6 V -> 0x10,0x0E DPC_TXLDOVDDPALow (Address: 0x006F) -> example: 1.5 V -> 0x00 DPC_HYSTERESIS_LOADING (Address: 0x006B) -> example: 20 mA -> 0x14 DPC_HYSTERESIS_UNLOADING (Address: 0x006E) -> example: 10 mA - 0x0A DPC lookup table entries (Addresses: 0x007D - 0x0125) -> example: for current limitation only -> all 0x00 If a user does not want to use a maximum range of VDDPA during DPC (5.7V), e.g., their system uses a 3.3V supply domain. Then, the maximum VDDPA in DPC can be limited by the following EEPROM settings:  TXLDO_VDDPA_MAX_RDR (Address: 0x0007)-> example: 3.0 V -> 0x0F Note: TXLDO has approx. 0.3V voltage drop. Always set this parameter 0.3V lower. Once this is done, the user has to check the "TxLDO" current and adjust the target current accordingly. In this case, to approximately 150 mA. If you don´t change it, the DPC starts to limit the power around 229 mA, as has been set in a previous step. 
View full article
This article provides information on the expected NFC communication range for NXP products (Connected tags) when used with various mobile phones and the CLRC663 reader.   1// NFC Antenna 54 mm vs 27 mm (NTAG 5 Boost Antenna 10 mm vs 10 mm)    1.1// Used antenna   1.2// Results  Note: NTAG5 Link - Energy harvesting is disabled      2// NFC Antenna 25 mm vs 18 mm    2.1// Used antenna   2.2// Results Note: NTAG5 Link - Energy harvesting is disabled      3//NFC Antenna 25 mm vs 18 mm with "filling"    3.1// Used antenna    3.2// Results    Note: NTAG5 Link - Energy harvesting is disabled 
View full article
this is a step by step guider to port PN7160 to Android 14 on i.MX 8M Nano board
View full article
The Raspberry Pi Foundation released the Raspberry Pi 5 in October 2023, Raspberry Pi 5 features the Broadcom BCM2712 quad-core Arm Cortex A76 processor @2.4GHz, making it up to three times fast than Raspberry Pi 4.   The latest version of Raspberry Pi OS is Bookworm. However, some customers found the PN7160 is not detected over I2C/SPI on the Raspberry Pi 5. Running "i2cdetect -y 1" produces a blank table, and running "nfcDemoApp poll" results in an "nfcservice init fail" message. The incompatibility appears to be between the PN7160 and the new Raspberry Pi OS—Bookworm.  This reason is Raspberry Pi OS received a major update in Linux Kernel 6.6,  the classic way of GIPO handling no long work.   In step 6, a new GPIO interface is introduced to resolve the incompatibility issue. This article is a step-by-step guide to port PN7160 NCI2 stack to Raspberry Pi OS--Bookworm.   Hardware setup: For detail information about Raspberry Pi 5, please refer to below link.  https://www.raspberrypi.com/products/   The PN7160 EVK board must be connected to Raspberry Pi using the following instructions:   Raspberry Pi 5 board pin NFC controller board signal #1 3.3V PWR VDD (PAD) +5V VBAT and VDD (UP) #16 GPIO23 IRQ #18 GPIO24 VEN #22 DWL_REQ #6 GND #5 I2C_SCL #3 I2C_SDA     This matches the Raspberry Pi version of OM27160A1EVK (I2C variant).  The kit can then be plugged on Raspberry Pi 5 board to run the example. First of all, assemble the PN7160 NFC controller board (OM27160A1HN or OM27160B1HN) with the Raspberry Pi interface board (OM29110RPI)      Then stacked together the boards with the Raspberry Pi board.     Software Setup: 1    Install Rasp 5 OS -Bookworm We use Raspberry Pi Imager tool to install Raspberry Pi OS (64bit, Bookworm). Click choose device and select Raspberry Pi 5, next click choose OS and select an operating system –Raspberry Pi OS (64-bit) , and select Micro SD card. Next we can write the Image to the Micro SD card.   2 Enable i2c interface 1). Run command:     sudo raspi-config     2). Use the down arrow to select "Interface Options"   3). Arrow down to "I5 I2C"     4). Select "yes" when it asks you to enable I2C 5). Use the right arrow to select the <Finish> button To verify the i2c interface is enabled, enter the following command: $ ls /dev/i2c* The Pi should respond with “ /dev/i2c-1” which represents the user-mode i2c interface to which is connected the PN7160    3 Install necessary tools   We need to use APT commands to install , update software package in Raspberry Pi OS, please refer to  below link. https://www.raspberrypi.com/documentation/computers/os.html Libtool needs to be installed to run the NCI stack.    4 Clone Linux libnfc-nci library repository NFC NCI library is available from the following repository: https://github.com/NXPNFCLinux/linux_libnfc-nci $ git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git -b NCI2.0_PN7160     5 Apply 64bit patch To install on 64bit OS, we need to apply 64bit patch.  It is under folder linux_libnfc-nci/64bit_patch/ROOT_src.patch   6 Modifications for GPIO Raspberry Pi OS (Bookworm) received a major update which includes the Linux kernel 6.6.   In the new OS update, the classic way of interfacing with GPIO has been deprecated.  Unfortunately our PN7160 NCI stack still interact with GPIO using /sys/class/gpio pseudo-filesystem,  low level control of GPIOs no longer work with Bookworm.  So we need to use the new GPIO interface on the Raspberry PI: libgpiod.  At this point Raspberry OS with a kernel 6.6 both libgpiod and gpiod are not pre-packaged and we need to install them.   6.1  Installation of gpiod tools We can look more into what is installed   The output of gpioinfo reports all of the available GPIO lines, by default for all chips. 6.2 Installation of the gpio libraries If we want to install libraries for development we need to do the following   Here is the info on libgpiod-dev     The development package installs the C libraries and header files for us to use. Namely, the /usr/include/gpiod.h C header file and the /usr/lib/arm-linux-gnueabihf/libgpiod.so Shared Library.   6.3 Modifications in PN7160 NCI2 library. In source code, we need to add the gpiod library support 6.3.1 Makefile.am    6.3.2 src/nfcandroid_nfc_hidlimpl/halimpl/tml/transport/NfccAltTransport.cc    ......     and src/nfcandroid_nfc_hidlimpl/halimpl/tml/transport/NfccAltTransport.h   If you need the modified source code files, please let me know. I can send the source code changes to you.    7 Configure the library       8 Set the library to map i2c interface   9 Build and install the library   $ make $ sudo make install $ export LD_LIBRARY_PATH=/usr/local/lib   10 Run & Verify the NFC functionality     This demo works as expected.   Summary: Porting PN7160 NCI2 stack to Raspberry Pi 5, we need to follow PN7160 Linux porting guide and update the classic GPIO interface to gpiod libraries.   Happy porting 😊
View full article
In the case, the Reader output power cannot be further reduced with the help of the tuning and TXLDO settings (e.g. EMI reasons)  Then further reduction can be done using DPC settings. The idea is to use just one DPC entry and adjust the GSN value as shown below: DPC Settings:    The DPC Entries (1-19) have been deactivated (Index Activate ->0), and only Entry 00 stays active.    An example (RF Field measured using a scope probe): No DPC, TXLDO 5V    NO DPC, TXLDO 2.7V   DPC Activated, One Entry, GSN-> 0x05   DPC Activated, One Entry, GSN-> 0x01   Please consider that the reading performance will be impacted. 
View full article
There is a basic GUI for PN7160 RF Settings available.
View full article
Extended NFC Factory Test Application includes:  Get Current value (current measurement in mA) DPC Check (Available from FW. Version 12.50.06) Get AGC Value  Get AGC Value NFCLD (AGC value reading with fixed NFC Level Detector level) Dump EEPROM settings    How to get it:  Just download the app from Github. Replace the "NfcFactoryTestApp.c" with the file which is here in the attachment.  Run the application as described in ->AN13287.   Tomas Parizek  Customer Application Support 
View full article
AN13189 provides guidelines for the integration of PN7160 NXP NCI-based NFC controller to an Android platform from software perspective. But some developers found some compile issues when integrating PN7160 NFC package into Android 11.   This article describes how to fix the build error when you integrating PN7160 NXP NCI-based NFC controller to Android 11 system.  You need to follow the AN13189 (PN7160 Android porting guide ) first.  After you run the installation script install_NFC.sh, the following modification should be added to the source code. 1) Open package/apps/Nfc/nci/jni/Android.bp Add  "-DNXP_EXTNS=TRUE",   2 )  open system/nfc/src/Android.bp Add   "-DNXP_EXTNS=TRUE",     3 )   open packages/apps/Nfc/src/com/android/nfc/NfcService.java And add this: between isNfcSecureEnabled and setNfcSecure methods:             @Override         public IBinder getNfcAdapterVendorInterface(String vendor) {             if(vendor.equalsIgnoreCase("nxp")){                     return (IBinder) mNfcAdapter;             } else {                    return null;             }         }     Next, follow AN13189, complete the following steps in section 4.2. Then you can build the package successfully.  Thanks  @andraz_skupek .      
View full article
A Quick Solution for link issue of "missing --end-group" when you use the latest MCUXpresso IDE to compile the NFC reader library projects.
View full article
https://community.nxp.com/docs/DOC-340244 
View full article
This post contains a guide of how to use the NFC Reader Library with LPC55S69. A ready to use package for using the “Basic Discovery Loop” example from the NFC Reader Library with LPC55S69 and CLRC663 plus frontend is attached with this document. This document is structured as follows: Overview of LPC55S69: The LPCXpresso55S69 development board provides the ideal platform for evaluation of and development with the LPC55S6x MCU based on the Arm® Cortex®-M33 architecture. The board includes a high performance onboard debug probe, audio subsystem and accelerometer, with several options for adding off-the-shelf add-on boards for networking, sensors, displays and other interfaces. The LPCXpresso55S69 is fully supported by the MCUXpresso suite of tools, which provides device drivers, middleware and examples to allow rapid development, plus configuration tools and an optional free IDE. MCUXpresso software is compatible with tools from popular tool vendors such as Arm and IAR, and the LPCXpresso55S69 may also be used with the popular debug probes available from SEGGER and P&E Micro. Hardware Requirements: Following hardware is required to run the project: LPC55S69-EVK development board. CLEV6630B board or BLE-NFC-V2 board. BLE-NFC-V2: It is easier to use the BLE-NFC-V2 board since it can be just plugged on top of the arduino interface available on the LPCXpresso55S69 board. The following figure shows the pin mapping between the two boards. CLEV6630B board: The CLEV6630B board consists of CLRC663 plus (NFC frontend) connected by default to an LPC1769 µC via SPI. However, the board is made in such a way that the LPC1769 MCU can be bypassed to connect to an external MCU (in our case the LPC55S69) easily. For doing so: Six resistors from the board need to be removed. These are highlighted in red in the Figure 1: Use the SPI pin connectors available on the left-hand side, on the board edge to connect to external MCU (LPC55S69 in this case) Solder jumper wires onto the following pins of CLEV6630B Board:  GND IRQ CLRC_NRST SSEL MOSI MISO SCK IF0 IF1      The CLEV6630B is shown in Figure 2 after the required changes have been made to it (Removal of resistors and soldering of wires).   Now connect the two boards as follows:   Running Basic Discovery Loop on LPC55S69:   If this is the first time you’re using LPC55S69-EVK board, follow the getting started guide first à  LPC55S69-EVK | NXP . Make sure to install the SDK package for LPC55S69-EVKboard which is required for the project below to run. Download either‘lpcxpresso55s69_BasicDiscoveryLoop_CLEV6630b' or 'lpcxpresso55s69_BasicDiscoveryLoop_BLE-NFC' package which you will find attached to this post. Drag and drop the downloaded package to the “Project Explorer” tab of your MCUXpresso IDE workspace (If you don’t have MCUXpresso, it can be downloaded for free from here: https://www.nxp.com/support/developer-resources/software-development-tools/mcuxpresso-software-and-tools/mcuxpresso-integrated-development-environment-ide:MCUXpresso-IDE Now that the package has been imported to the MCUXpresso IDE (via drag and drop), click on Debug icon from the Quickstart panel to begin a debug session. Once the debug session has started, click on the run icon to run the code: The project should be running now. The project contains basic discovery loop functionality. Here is how the output looks like in the terminal. Bring any NFC card near the frontend’s antenna and the output console will show the detection and type of the card. For example, in the picture below, we can see that type 4A card was detected:     Running other NFC Reader Library examples on LPC55S69: Once the “lpcxpresso55s69_BasicDiscoveryLoop” project is running on the LPC55S69. Running other examples from is simple. First step is to install the NFC Reader Library : Installing the NFC Reader Library: Go to www.nxp.com/pages/:NFC-READER-LIBRARY Go to the Downloads tab and click on the download button Click download on the NFC Reader Library for Kinetis K82F package. Import the library package in the workspace. The easiest way is to use the Quick Start Panel on the left-hand side: Click on Import project from file system Then, browse the library package in your file system. Click Finish to import it all to your workspace. After completing the import wizard, all projects are listed in the “Project Explorer” window. As can be seen in the screenshot, it contains different folders: API documentation folder Driver Abstraction Layer FreeRTOS support The platform support (in the screenshot, corresponding to the LPC support) The software examples  The Reader Library implementation And the OS abstraction layer   Running "NfcrdlibEx9_NTagI2C" on LPC55S69: Here we use the “NfcrdlibEx9_NTagI2C” example from the reader library to describe the method. The same method can be used to run other examples from the NFC Reader Library.  To run "NfcrdlibEx9_NTagI2C" on LPC55S69, we look at "lpcxpresso55s69_BasicDiscoveryLoop" project (available as a download below) and "NfcrdlibEx9_NTagI2C" project (from the Reader Library). We make changes to the following folders: In “intfs” folder remove everything except the “phaApp_Init.h” file. Then go to the “intfs” folder of the NFC Reader Library example you want to run (“NfcrdlibEx9_NTagI2C” in this case), and copy all the files except “phaApp_Init.h” and paste them in the original “intfs” folder. In line 57 of the “ph_NxpBuild_App.h” file in “intfs” folder, replace #if defined(PHDRIVER_LPC1769RC663_BOARD) \     || defined(PHDRIVER_FRDM_K82FRC663_BOARD)\ #   define NXPBUILD__PHHAL_HW_RC663 #endif with #if defined(PHDRIVER_LPC1769RC663_BOARD) \     || defined(PHDRIVER_FRDM_K82FRC663_BOARD)\     || defined(PHDRIVER_LPC55S69RC663_BOARD) #   define NXPBUILD__PHHAL_HW_RC663 #endif Go to “source” folder and remove every file except “phApp_Init.c“ and “semihost_hardfault.c” files. Then go to “src” folder of the example you want to run (“NfcrdlibEx9_NTagI2C” in this case) and copy all the files except “phaApp_Init.c” and paste them into the “source” folder. Finally, copy the main file of the example you want to run (NfcrdlibEx9_NTagI2C in this case) and paste it into the “source” folder as well. The project is ready to build and run on LPC55S69.       Available Resources: Porting NFC Reader Library to i.MX RT1050. (Detailed Description of porting) https://community.nxp.com/docs/DOC-341843 LPC55S69 https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc5500-cortex-m33/lpcxpresso55s69-development-board:LPC55S69-EVK BLE-NFC-V2 https://www.nxp.com/products/identification-security/rfid/nfc-hf/nfc-readers/clrc663-iplus-i-and-qn902x-nfc-bluetooth-low-energy-solution-for-consumer-applications:BLE-NFC
View full article
Introduction I am trying to make one page that contain all the useful information about NFC Antenna Design. I will keep update and add the information to this page when I found something useful.   Training First of all, there are 6 webinars about NFC Antenna Design. It is a good training before to start your antenna design for NFC. Training & Events | NXP  (Search "Antenna design")   Application Notes AN11740 : PN5180 Antenna design guide AN11706 : PN7462AU Antenna design guide AN11019 : CLRC663, MFRC630, MFRC631, SLRC610 Antenna Design Guide AN11755 : PN7150 Antenna Design and Matching Guide AN11564 : PN7120 Antenna Design and Matching Guide AN11741 : How to design an antenna with DPC AN11535 : Measurement and tuning of a NFC and Reader IC antenna with a MiniVNA Tools NFC Antenna Design Hub
View full article
Hello NFC enthusiasts,   In the NFC communication protocol, when a device acts as a NFC reader (it provides its own field), it is waiting for a tag to approach. When this occurs, the reader energizes the tag and depending on the application, it can read from or write to a tag.   When multiple tags are in the field, the power decreases according to the number of tags being energized, for which the tag operations will not work properly. For this, there is a process called anti-collision, in which the reader decides, from the detected tags, one to work with.   The purpose of this document is to demonstrate the activation of each tag at a given index.   This demonstration is going to be made with two NTAG 216.     This demonstration is based on NXP NFC Reader Library v05.02.00, NfcrdlibEx3_NFCForum project for PNEV7462B, in which some modifications are going to be made in order to carry this out. These tags are compliant with NFC Forum Type 2 Tag and ISO/IEC14443 Type A specifications.    In phacDiscLoop.h modify the max number of cards supported (two cards for this demonstration):   #define PHAC_DISCLOOP_CFG_MAX_CARDS_SUPPORTED 0x02U      In NfcrdlibEx3_NFCForum.c add the following code in LoadDiscoveryConfiguration():   static phStatus_t LoadDiscoveryConfiguration() { ... /*Passive max typea devices*/ status = phacDiscLoop_SetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TYPEA_DEVICE_LIMIT, 2); CHECK_STATUS(status); }   A fix to the SW stack has to be made (Fix will be implemented in the next release): open "phacDiscLoop_Sw_Int_A.c", line 511, change if statement as below.     if((pDataParams->sTypeATargetInfo.bTotalTagsFound > 1) && ((bTypeATagIdx) < pDataParams->sTypeATargetInfo.bTotalTagsFound))     Until now, the reader is able to detect a maximum of two tags and work with up to two type A devices.   The activation of a tag at a given index is possible to the phacDiscLoop_ActivateCard() function.   Once this function is called, it will receive the discovery loop data parameters, the type of tag and the index of a tag to be activated.   The code will be added after knowing that multiple tags are detected and resolved in the NfcrdlibEx3_NFCForum.c file.   else if((status & PH_ERR_MASK) == PHAC_DISCLOOP_MULTI_DEVICES_RESOLVED) { /* * Multiple cards resolved. It enters here if DEVICE LIMIT > 1 and more than one devices are * detected and resolved. */ DEBUG_PRINTF (" \n Multiple cards resolved: \n"); /* Get detected technology type */ status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED, &wTagsDetected); CHECK_STATUS(status); /* Get number of tags detected */ status = phacDiscLoop_GetConfig(pDiscLoop, PHAC_DISCLOOP_CONFIG_NR_TAGS_FOUND, &wNumberOfTags); CHECK_STATUS(status); DEBUG_PRINTF ("\tNumber of tags: %d \n",wNumberOfTags); /* Code */ ... } Note: The code to be inserted in the comment /* Code */ is below in the Code section of this document.   The demonstration will be as simple as activating one tag, read its NDEF message, activate the second tag and read its NDEF message as well so that we make sure the activation process is performed correctly.   Each tag was previously written with a text NDEF message respectively.   Tag 1: Text: Hallo! Language: de   Tag 2: Text: ¡Hola! Language: es   Writing to a tag can be done by making use of our TagWriter app available in the play store: NFC TagWriter by NXP - Aplicaciones de Android en Google Play    Code section:   uint8_t bTagState1; /* Tag 1 */ /* Activate tag at index 0 */ status = phacDiscLoop_ActivateCard(pDataParams, PHAC_DISCLOOP_TECH_TYPE_A, 0x00); /* Check for NDEF presence */ status = phalTop_CheckNdef(palTop, &bTagState1); /* Read NDEF message */ status = ReadNdefMessage(PHAL_TOP_TAG_TYPE_T2T_TAG); DEBUG_ERROR_PRINT(status); /* Tag 2 */ /* Activate tag at index 1 */ status = phacDiscLoop_ActivateCard(pDataParams, PHAC_DISCLOOP_TECH_TYPE_A, 0x01); /* Check for NDEF presence */ status = phalTop_CheckNdef(palTop, &bTagState1); /* Read NDEF message */ status = ReadNdefMessage(PHAL_TOP_TAG_TYPE_T2T_TAG); DEBUG_ERROR_PRINT(status);   Behavior shown in the console monitor:   NFC Forum Example:       This implementation demonstrated the activation of two type A tags at a given index. I hope this is of great help!   Best regards, Ivan. Original Attachment has been moved to: Project-files.zip
View full article
This post contains a step by step guide of how to use PN7150 with i.MX RT1060. This document is structured as follows: Overview of PN7150 PN7150 is a Plug-and-Play all-in-one NFC solution for easy integration into any OS environment like Linux and Android, reducing Bill of Material (BoM) size and cost. The embedded Arm® Cortex®-M0 microcontroller core is loaded with the integrated firmware, simplifying the implementation as all the NFC real-time constraints, protocols and the device discovery (polling loop) are processed internally. In few NCI commands, the host SW can configure the PN7150 to notify for card or peer detection and start communicating with them. It has the following salient features: Full NFC forum compliancy with small form factor antenna Embedded NFC firmware providing all NFC protocols as pre-integrated feature Direct connection to the main host or microcontroller, by I2C-bus physical and NCI protocol Ultra-low power consumption in polling loop mode Highly efficient integrated power management unit (PMU) allowing direct supply from a Battery Hardware Requirements      1. OM5578/PN7150ARD      2. i.MX RT1060 EVK Evaluation Board + usb micro cable        Using PN7150 with i.MX RT1060 Hardware Connections The hardware connections are simple. Both the EVKB-IMXRT1060 board and OM5578/PN7150ARD board have an Arduino interface. So, mount the PN7150ARD board with male Arduino connector onto the female Arduino connector of the EVKB-IMXRT1060 board.  Running the Demo If this is the first time you’re using EVK-MIMXRT1060 board, follow the getting started guide first: i.MX RT1060 Evaluation Kit | NXP . Make sure to install the SDK package for EVK-MIMXRT1060 board which is required for the project to run.   Download the ‘evkbimxrt1060_PN7150’ package which you will find attached to this post. Drag and drop the downloaded package to the “Project Explorer” tab of your MCUXpresso IDE workspace (If you don’t have MCUXpresso, it can be downloaded for free from here: https://www.nxp.com/support/developer-resources/software-development-tools/mcuxpresso-software-and-tools/mcuxpresso-integrated-development-environment-ide:MCUXpresso-IDE Now that the package has been imported to the MCUXpresso IDE (via drag and drop), click on Debug icon from the Quickstart panel to begin a debug session. Once the debug session has started, click on the run icon to run the code: After step 3, the project should be running now. The project contains basic discovery loop functionality. Here is how the output looks in the console tab on MCUXpresso: Bring any NFC card near the PN7150 board’s antenna and the output console will show the detection and type of the card. For example, in the picture below, we can see that type 4 card was detected: Available Resources AN11990 NXP-NCI MCUXpresso example document. (https://www.nxp.com/docs/en/application-note/AN11990.pdf) The example project explained in this project was ported to i.MX RT1060 using section 5.3 and 6 of the above mentioned document. PN7150 datasheet (https://www.nxp.com/docs/en/data-sheet/PN7150.pdf) PN7150 User Manual (https://www.nxp.com/docs/en/user-guide/UM10936.pdf) PN7150 NFC Controller SBC Kit User Manual  (https://www.nxp.com/docs/en/user-guide/UM10935.pdf)
View full article
This page contains information about the supported NXP MCU/MPU and NXP NFC product combinations which have ready to use packages. These can be used as a reference. The table below contains link to where you can find the projects as well.    MCU ↓   NFC IC →  NTAG I²C  plus NTAG 5 PN7150 CLRC663 plus family* PN5180 i.MX RT1050 i.MX RT1050 + NTAG I²C plus i.MX RT1050 + CLRC663 plus   Video: Using i.MX RT1050 with CLRC663 plus family and the NFC Reader Library | NXP  i.MX RT1060 i.MX RT1060 + NTAG I²C plus  i.MX RT1060 + PN7150 i.MX 8M Mini i.MX 8M Mini + PN7150 (Andriod) i.MX 8M Mini + PN7150 (linux-yocto) i.MX 7 Dual Sabre i.MX7 Dual Sabre + PN5180 LPC1769 LPC1769 + CLRC663 plus LPC1769 + PN5180 LPC55S69 LPC55S69 + NTAG I²C plus LPC55S69 + NTAG 5 LPC55S69 + PN7150 LPC55S69 + CLRC663 plus LPC55S69 + CLRC663 plus + SE050 (smart lock) LPC11u37h LPC11u37 + PN7150 LPC11u37h + CLRC663 plus LPC11u68 LPC11u68 + PN7150 LPC82X LPC82X + PN7150 LPC845 LPC845 + CLRC663 plus Kinetis K82F K82F + CLRC663 plus K82F + PN5180 Kinetis K64F K64F + PN7150 K64F + CLRC663 plus Kinetis K63 K63 + PN7150 Kinetis K24 K24 + PN7150 KW41Z KW41Z + NTAG I²C plus KW41Z + NTAG 5 KW41Z + PN7150 *CLRC663 plus family: CLRC663 plus, MFRC630 plus, MFRC631 plus, SLRC610 plus For more information on the NFC products, please visit https://www.nxp.com/nfc
View full article
Introduction Many customers are using PN7220 + Android 16 recently. In this document, I will show you how to porting the PN7220 to Android 16. I use the i.MX95 FRDM board as a reference target board.   NOTE :  All the modifications are just for reference. They are NOT a NXP official patches for the newer release of AOSP porting. So the modifications may not be the best solution. Customer please base on their needs to modify the AOSP source code. This is not for production. Customer still need to perform full testing after the porting.    Hardware boards: i.MX95 FRDM Board (FRDM i.MX 95 Development Board | NXP Semiconductors)   PN7220 EVK -- PNEV7220BP1 (PNEV7220BP1 Development Board for PN7220 NFC Controller | NXP Semiconductors)   There is a 40pins connector on both PN7220 EVK and i.MX95 FRDM board. So PN7220 + i.MX95 FRDM connecting together is like this:   Build the Android BSP for i.MX95 FRDM board: The i.MX Android BSP that I used is Android 16.0.0_1.4.0 (L6.12.49_2.2.0 BSP). It could be downloaded from here: Android OS for i.MX Applications Processors | NXP Semiconductors   1. Download the "Documentation" and the "Install Source Package".  2. Follow the steps in Android User's Guide to build the Android BSP for "evk_95" first.  $ export MY_ANDROID=`pwd` $ source build/envsetup.sh $ lunch evk_95-nxp_stable-userdebug $ export TARGET_RELEASE=nxp_stable $ build_build_var_cache $ ./imx-make.sh -j4 2>&1 | tee build-log.txt   According to the android_build/.repo/manifests/aosp-android-16.0.0_1.4.0.xml, you will see the AOSP version is android-16.0.0_r4. According to the PN7220 Android 16 porting guide (PN7160/PN7220 – Android 16 porting guide), the patches is for AOSP release android-16.0.0_r2. So fortunately, the AOSP release version between them is not big different.    Now, we start the porting: 1. Kernel Driver To establish connection with the PN7220, the Android stack uses the nxpnfc kernel driver.  You could download the driver from github below: nfcandroid_platform_drivers/drivers at br_ar_16_comm_infra_dev · nxp-nfc-infra/nfcandroid_platform_drivers · GitHub   The command is : git clone "https://github.com/nxp-nfc-infra/nfcandroid_platform_drivers.git" -b br_ar_16_comm_infra_dev There is driver for Kernel 6.6 and 6.12. So, please download the correct one for your porting. For example, the kernel in i.MX Android BSP Android 16.0.0_1.4.0 is 6.12. So I will use the 6.12 driver for my porting.   In your porting, make sure the PATH in Makefile and Kconfig files are setting properly.  For example in my porting: android_build/vendor/nxp-opensource/kernel_imx/drivers/nfc/pn7220$ tree . ├── common.c ├── common.h ├── i2c_drv.c ├── i2c_drv.h ├── Kbuild ├── Kconfig └── Makefile 0 directories, 7 files   For simplifying everything, we will only add a support for I2C and not SPI. Replace drivers/nfc/pn7220/Makefile default code with following code (for easier understanding) nxpnfc-i2c-objs = i2c_drv.o common.o obj-$(CONFIG_NXP_NFC_I2C) += nxpnfc_i2c.o   The contents of drivers/nfc/Makefile. Add the PN7220 like below: # SPDX-License-Identifier: GPL-2.0 # # Makefile for nfc devices # obj-$(CONFIG_NXP_NFC_I2C) += pn7220/ obj-$(CONFIG_NFC_FDP) += fdp/ obj-$(CONFIG_NFC_PN544) += pn544/ obj-$(CONFIG_NFC_MICROREAD) += microread/ obj-$(CONFIG_NFC_PN533) += pn533/ obj-$(CONFIG_NFC_MEI_PHY) += mei_phy.o obj-$(CONFIG_NFC_SIM) += nfcsim.o obj-$(CONFIG_NFC_PORT100) += port100.o obj-$(CONFIG_NFC_MRVL) += nfcmrvl/ obj-$(CONFIG_NFC_TRF7970A) += trf7970a.o obj-$(CONFIG_NFC_ST21NFCA) += st21nfca/ obj-$(CONFIG_NFC_ST_NCI) += st-nci/ obj-$(CONFIG_NFC_NXP_NCI) += nxp-nci/ obj-$(CONFIG_NFC_S3FWRN5) += s3fwrn5/ obj-$(CONFIG_NFC_ST95HF) += st95hf/ obj-$(CONFIG_NFC_VIRTUAL_NCI) += virtual_ncidev.o   The contents of drivers/nfc/Kconfig. Add the PN7220 like below: source "drivers/nfc/microread/Kconfig" source "drivers/nfc/nfcmrvl/Kconfig" source "drivers/nfc/st21nfca/Kconfig" source "drivers/nfc/st-nci/Kconfig" source "drivers/nfc/nxp-nci/Kconfig" source "drivers/nfc/s3fwrn5/Kconfig" source "drivers/nfc/st95hf/Kconfig" source "drivers/nfc/pn7220/Kconfig" endmenu   2. Adding the "nxpnfc" to the i.MX95 FRDM board device tree file android_build/vendor/nxp-opensource/kernel_imx/arch/arm64/boot/dts/freescale/imx95-15x15-frdm.dts   We need to check the connection between two boards and then to decide which pins to use in the device tree file. Here is the 40 pins connector on the PN7220: Here is the 40 pins connector on the i.MX95 FRDM board. According to the 40 pins connection between PN7220 EVK and the i.MX95 FRDM board, I decided to use the I2C6 and the GPIO2_20, GPIO2_21 and GPIO2_26. So, in the imx95-15x15-frdm.dts, I added: &lpi2c6 { clock-frequency = <400000>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_lpi2c6>; status = "okay"; nxpnfc@28{ compatible = "nxp,nxpnfc"; reg = <0x28>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_nfc>; nxp,nxpnfc-irq = <&gpio2 26 0>; nxp,nxpnfc-ven = <&gpio2 21 0>; nxp,nxpnfc-mode_sw = <&gpio2 20 0>; }; }; And the IOMUX settings in the imx95-15x15-frdm.dts. pinctrl_nfc: nfcgrp { fsl,pins = < IMX95_PAD_GPIO_IO26__GPIO2_IO_BIT26 0x39e // IRQ IMX95_PAD_GPIO_IO21__GPIO2_IO_BIT21 0x39e // VEN IMX95_PAD_GPIO_IO20__GPIO2_IO_BIT20 0x39e // MODE_SW >; }; pinctrl_lpi2c6: lpi2c6grp { fsl,pins = < IMX95_PAD_GPIO_IO02__LPI2C6_SDA 0x40000b9e IMX95_PAD_GPIO_IO03__LPI2C6_SCL 0x40000b9e >; };   3. Modify the imx95_gki.fragment File:  android_build/vendor/nxp-opensource/kernel_imx/arch/arm64/configs/imx95_gki.fragment Add the "CONFIG_NXP_NFC_I2C=m" into the imx95_gki.fragment   4. Add the settings in your corresponding board configuration files in Android - Go to the android_build/device/nxp/imx9/evk_95/  - Modify the BoardConfig.mk. # Add KVM support BOARD_BOOTCONFIG += androidboot.hypervisor.vm.supported=true + # ---- selinux permissive ---- + BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive # -------@block_sepolicy------- BOARD_SEPOLICY_DIRS := \ $(CONFIG_REPO_PATH)/imx9/sepolicy \ $(IMX_DEVICE_PATH)/sepolicy \ + vendor/nxp/nfc/sepolicy \ + vendor/nxp/nfc/sepolicy/nfc +include vendor/nxp/nfc/BoardConfigNfc.mk    - Add the "nxpnfc_i2c.ko" to the ShareBoardConfig.mk. Make sure the path and the filename are correct. ifeq ($(LOADABLE_KERNEL_MODULE),true) IMX_ANDROID_FIRST_STAGE_MODULES += \ $(KERNEL_OUT)/drivers/hwmon/hwmon.ko \ $(KERNEL_OUT)/drivers/hwmon/scmi-hwmon.ko \ .... .... .... $(KERNEL_OUT)/drivers/soc/imx/soc-imx9.ko \ $(KERNEL_OUT)/drivers/gpio/gpio-adp5585.ko \ $(KERNEL_OUT)/drivers/gpio/gpio-pca953x.ko \ $(KERNEL_OUT)/drivers/gpio/gpio-vf610.ko \ + $(KERNEL_OUT)/drivers/nfc/pn7220/nxpnfc_i2c.ko .... .... BOARD_VENDOR_KERNEL_MODULES += \ $(KERNEL_OUT)/drivers/media/i2c/ap1302.ko \ $(KERNEL_OUT)/drivers/media/i2c/ox03c10.ko \ $(KERNEL_OUT)/drivers/media/i2c/max96717_lib.ko \ .... .... $(KERNEL_OUT)/drivers/net/ethernet/freescale/enetc/fsl-enetc-vf.ko \ $(KERNEL_OUT)/drivers/net/ethernet/freescale/enetc/fsl-enetc4.ko \ $(KERNEL_OUT)/drivers/net/phy/realtek.ko \ $(KERNEL_OUT)/drivers/hwmon/pwm-fan.ko \ + $(KERNEL_OUT)/drivers/nfc/pn7220/nxpnfc_i2c.ko   - Add the following to the compatibility_matrix.xml <compatibility-matrix version="1.0" type="device"> <hal format="native" optional="false"> <name>netutils-wrapper</name> <version>1.0</version> </hal> <hal format="aidl" optional="true"> <name>android.hardware.emvco</name> <version>1</version> <interface> <name>IEmvco</name> <instance>default</instance> </interface> </hal> </compatibility-matrix>   - Add the INxpNfc and IEmvco to the device_framework_matrix.xml <compatibility-matrix version="1.0" type="framework"> <hal format="aidl" optional="true"> <name>nxp.hardware.secureime</name> <version>1</version> <interface> <name>ISecureIME</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>nxp.hardware.ele</name> <version>1</version> <interface> <name>ISecureEnclave</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>nxp.hardware.imx_dek_extractor</name> <version>1</version> <interface> <name>IDek_Extractor</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>vendor.nxp.nxpnfc_aidl</name> <version>2</version> <interface> <name>INxpNfc</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>android.hardware.emvco</name> <version>1</version> <interface> <name>IEmvco</name> <instance>default</instance> </interface> </hal> </compatibility-matrix>    - Add the following to the evk_95.mk # ------nfc------- $(call inherit-product, vendor/nxp/nfc/device-nfc.mk) $(call inherit-product, vendor/nxp/emvco/device-emvco.mk) PRODUCT_PACKAGES += \ android.hardware.nfc2-service.nxp PRODUCT_PACKAGES += \ com.nxp.emvco \ com.nxp.nfc \ nfc_nci_nxp_pn72xx   - Add the nxpnfc_i2c in init.rc exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d \ /vendor/lib/modules nxpnfc_i2c write /sys/power/wake_lock nosleep   - Add nxpnfc to ueventd.nxp.rc /dev/ttymxc1 0666 nfc nfc /dev/ttymxc2 0666 nfc nfc /dev/nxpnfc 0666 nfc nfc   5. Apply the NXP AOSP patches I write a script to download the patches from the github. The script file and the android_build folder is on the same directory. Run the AOSP_adaptation.sh.  AOSP_adaptation.sh # nfcandroid_nfc_modules git clone "https://github.com/nxp-nfc-infra/nfcandroid_modules_nfc.git" cd nfcandroid_modules_nfc git checkout br_ar_16_comm_infra_dev cp -rf * ../android_build/packages/modules/Nfc cd .. # nfcandroid_nfc_hidlimpl git clone "https://github.com/nxp-nfc-infra/nfcandroid_nfc_hidlimpl.git" cd nfcandroid_nfc_hidlimpl git checkout br_ar_16_comm_infra_dev cp -rf * ../android_build/hardware/nxp/nfc cd .. # nfcandroid_frameworks git clone "https://github.com/nxp-nfc-infra/nfcandroid_frameworks.git" cd nfcandroid_frameworks git checkout br_ar_16_comm_infra_dev mkdir ../android_build/packages/modules/Nfc/framework cp -rf * ../android_build/packages/modules/Nfc/framework cd .. # nfcandroid_emvco_aidlimpl git clone "https://github.com/nxp-nfc-infra/nfcandroid_emvco_aidlimpl.git" cd nfcandroid_emvco_aidlimpl git checkout br_ar_16_comm_infra_dev mkdir ../android_build/hardware/nxp/emvco cp -rf * ../android_build/hardware/nxp/emvco cd .. # nfcandroid_platform_reference git clone "https://github.com/nxp-nfc-infra/nfcandroid_platform_reference.git" cd nfcandroid_platform_reference git checkout br_ar_16_comm_infra_dev cp -rf vendor/nxp/* ../android_build/vendor/nxp/ cd ..   Apply a patch. $ cd android_build/system/logging $ patch -p1 < ../../../nfcandroid_platform_reference/build_cfg/build_pf_patches/AROOT_system_logging.patch   Add TDA Test support: # Clone repositories for test applications and TDA support # nfcandroid_infra_test_apps git clone https://github.com/nxp-nfc-infra/nfcandroid_infra_test_apps.git cd nfcandroid_infra_test_apps/ git checkout br_ar_16_comm_infra_dev cd test_apps/ cp -rf SMCU_Switch/ ../../android_build/packages/apps/ cp -rf EMVCoModeSwitchApp/ ../../android_build/packages/apps/ cd ../.. # nfcandroid_infra_comm_libs git clone "https://github.com/nxp-nfc-infra/nfcandroid_infra_comm_libs.git" cd nfcandroid_infra_comm_libs git checkout br_ar_16_comm_infra_dev cp -rf nfc_tda/ ../android_build/packages/modules/Nfc/libnfc-nci/ cp -rf emvco_tda/ emvco_tda_test/ ../android_build/hardware/nxp/emvco/ cp -rf NfcTdaTestApp/ ../android_build/packages/apps/ cd ..   6. Put changes into hardwatre/interfaces/compatibility_matrices  File: hardware/interfaces/compatibility_matrices/compatibility_matrix.202504.xml <hal format="aidl"> <name>android.hardware.audio.effect</name> <version>1-3</version> <interface> <name>IFactory</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>nxp.hardware.imx_dek_extractor</name> <version>1</version> <interface> <name>IDek_Extractor</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>nxp.hardware.ele</name> <version>1</version> <interface> <name>ISecureEnclave</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>vendor.nxp.nxpnfc_aidl</name> <version>2</version> <interface> <name>INxpNfc</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>vendor.nxp.emvco</name> <version>1</version> <interface> <name>INxpEmvco</name> <instance>default</instance> </interface> </hal> <hal format="aidl" updatable-via-apex="true"> <name>android.hardware.authsecret</name> <version>1</version> <interface> <name>IAuthSecret</name> <instance>default</instance> </interface> </hal>   7. Add the firmware $ git clone https://github.com/NXP/nfc-NXPNFCC_FW.git $ cp -r nfc-NXPNFCC_FW/InfraFW/pn7220/64-bit-2.5/pn7220_64bits.so android_build/vendor/nxp/pn7220/firmware/lib64/libpn72xx_fw.so   8. Add the NXPAndroidDTA $git clone https://github.com/NXPNFCProject/NXPAndroidDTA.git $cd NXPAndroidDTA $git checkout br_ar_new_dta_arch cp -r NXPAndroidDTA android_build/vendor/nxp/   9. Some fixes before build: $ cd android_build $ mv hardware/nxp/nfc/snxxx/Android.bp hardware/nxp/nfc/snxxx/_Android.bp $ mv hardware/nxp/nfc/snxxx/halimpl/power-tracker/Android.bp hardware/nxp/nfc/snxxx/halimpl/power-tracker/_Android.bp $ mv hardware/nxp/secure_element/snxxx/aidl/Android.bp hardware/nxp/secure_element/snxxx/aidl/_Android.bp $ cd hardware/nxp/nfc $ rm pn8x -rf   Now, build the Android BSP again. Use "mm" to build the Android source code. After fixed all the errors of the AOSP build, use "imx-make.sh" to build the whole i.MX Android image.    When building the Android, there may have some errors during the build. I listed some errors and the workaround below for your reference.   Error: error: packages/modules/Nfc/tests/cts/tests/Android.bp:20:1: "CtsNfcTestCases" depends on undefined module "CtsAppTestStubsShared". Workaround : Comment out "CtsAppTestStubsShared" in packages/modules/Nfc/tests/cts/tests/Android.bp     Error: error: hardware/nxp/nfc/snxxx/halimpl_v2/power-tracker/Android.bp:17:1: "power_tracker_v2" depends on undefined module "nfc_nci_nxp_snxxx_headers_v2". Workaround: mv hardware/nxp/nfc/snxxx/halimpl_v2/power-tracker/Android.bp hardware/nxp/nfc/snxxx/halimpl_v2/power-tracker/_Android.bp     Error: error: platform_testing/Android.bp:255:1: module "continuous_native_tests" variant "android_common": depends on //packages/modules/Nfc/NfcNci/nci/jni:libnfc-nci-jni-tests which is not visible to this module You may need to add "//platform_testing" to its visibility error: platform_testing/Android.bp:255:1: module "continuous_native_tests" variant "android_common": depends on //packages/modules/Nfc/libnfc-nci/tests:libnfc-nci-tests which is not visible to this module You may need to add "//platform_testing" to its visibility Workaround: nano packages/modules/Nfc/NfcNci/nci/jni/Android.bp In cc_test {     name: "libnfc-nci-jni-tests", .. ..     visibility: [         "//platform_testing:__subpackages__",     ], Same in packages/modules/Nfc/libnfc-nci/tests/Android.bp     Error: FAILED: out/soong/.intermediates/packages/modules/Nfc/framework/framework-nfc.stubs.source.system/android_common/exportable/framework-nfc.stubs.source.system-stubs.srcjar out/soong/.intermediates/packages/modules/Nfc/framework/framework-nfc.stubs.source.system/android_common/exportable/framework-nfc.stubs.source.system_annotations.zip out/soong/.intermediates/packages/modules/Nfc/framework/framework-nfc.stubs.source.system/android_common/exportable/framework-nfc.stubs.source.system_api.txt out/soong/.intermediates/packages/modules/Nfc/framework/framework-nfc.stubs.source.system/android_common/exportable/framework-nfc.stubs.source.system_removed.txt out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:52: error: Binary breaking change: Removed method android.nfc.NfcOemExtension.emulateNfcTechnologyATag(boolean,byte,byte,byte,byte[],byte,byte[]) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:64: error: Binary breaking change: Removed method android.nfc.NfcOemExtension.overwriteRoutingTable(int,int,int,int,int) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:77: error: Binary breaking change: Removed field android.nfc.NfcOemExtension.EMULATE_NFC_A_TAG_STATUS_FAILED_INTERNAL [RemovedField] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:78: error: Binary breaking change: Removed field android.nfc.NfcOemExtension.EMULATE_NFC_A_TAG_STATUS_FAILED_NFC_NOT_ENABLED [RemovedField] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:79: error: Binary breaking change: Removed field android.nfc.NfcOemExtension.EMULATE_NFC_A_TAG_STATUS_OK [RemovedField] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:120: error: Binary breaking change: Removed method android.nfc.NfcOemExtension.Callback.onRoutingChangeCompleted() [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest:160: error: Binary breaking change: Removed method android.nfc.RoutingStatus.getDefaultFelicaRoute() [RemovedMethod] Aborting: Found compatibility problems checking the public API (/home/nxa08017/android16_1.4.0/android_build/out/soong/.temp/sbox/d1717a17fe92a8b2da806db0f1cb87830019487b/packages/modules/Nfc/framework/java) against the API in /home/nxa08017/android16_1.4.0/android_build/out/soong/.temp/sbox/d1717a17fe92a8b2da806db0f1cb87830019487b/./out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest exit status 255 Workaround: Comment out the lines 52,64,77,78,79,120,160 in out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.system.latest/gen/framework-nfc.api.system.latest     Error: out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:77: error: Binary breaking change: Removed method android.nfc.NfcAdapter.isExitFramesSupported() [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:80: error: Binary breaking change: Removed method android.nfc.NfcAdapter.isPowerSavingModeEnabled() [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:81: error: Binary breaking change: Removed method android.nfc.NfcAdapter.isPowerSavingModeSupported() [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:91: error: Binary breaking change: Removed method android.nfc.NfcAdapter.setPowerSavingMode(boolean) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:196: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.getPollingLoopFiltersForService(android.content.ComponentName) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:197: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.getPollingLoopPatternFiltersForService(android.content.ComponentName) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:202: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.isDeviceScreenOnRequiredForService(android.content.ComponentName) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:203: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.isDeviceUnlockRequiredForService(android.content.ComponentName) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:214: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.setRequireDeviceScreenOnForService(android.content.ComponentName,boolean) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:215: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.setRequireDeviceUnlockForService(android.content.ComponentName,boolean) [RemovedMethod] out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest:248: error: Binary breaking change: Removed method android.nfc.cardemulation.CardEmulation.NfcEventCallback.onOffHostAidSelected(String,String) [RemovedMethod] Aborting: Found compatibility problems checking the public API (/home/nxa08017/android16_1.4.0/android_build/out/soong/.temp/sbox/6245059c063e0ae76fa4356a9b840b923ddb8764/packages/modules/Nfc/framework/java) against the API in /home/nxa08017/android16_1.4.0/android_build/out/soong/.temp/sbox/6245059c063e0ae76fa4356a9b840b923ddb8764/./out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest exit status 255 Workaround: Same as the previous workaround. Comment out the lines (error) in out/soong/.intermediates/prebuilts/sdk/framework-nfc.api.public.latest/gen/framework-nfc.api.public.latest.     Error: vendor/nxp/nfc/sepolicy/nfc/nfc.te:7:ERROR 'unknown type hal_emvco_service' at token ';' on line 24388: allow nfc hal_emvco_service:service_manager find; allow nfc nfc_vendor_data_file:file { create rename setattr unlink { { getattr open read ioctl lock map watch watch_reads } { open append write lock map } } }; checkpolicy:  error(s) encountered while parsing configuration Workaround: nano vendor/nxp/nfc/sepolicy/nfc/nfc.te # allow NFC process to call into the NFC HAL +type hal_emvco_service, hal_service_type, service_manager_type; +type hal_emvco_default, domain; allow nfc nfc_data_file:dir create_dir_perms; allow nfc nxpnfc_hwservice:hwservice_manager find; allow nfc nfc_vendor_data_file:dir { create_dir_perms add_name search read write create remove_name }; allow nfc nfc_vendor_data_file:file create_file_perms; allow nfc hal_emvco_service:service_manager find; allow nfc hal_emvco_default:binder call; allow nfc hal_emvco_default:binder transfer; allow nfc vendor_hal_nxpnfc_service:service_manager find;     Error: FAILED: out/soong/.intermediates/hardware/nxp/nfc/intf/nxpnfc/aidl/vendor.nxp.nxpnfc_aidl_interface/checkhash_2.timestamp if [ $(cd 'hardware/nxp/nfc/intf/nxpnfc/aidl/aidl_api/vendor.nxp.nxpnfc_aidl/2' && { find ./ -name "*.aidl" -print0 | LC_ALL=C sort -z | xargs -0 sha1sum && echo 1; } | sha1sum | cut -d " " -f 1) = $(tail -1 'hardware/nxp/nfc/intf/nxpnfc/aidl/aidl_api/vendor.nxp.nxpnfc_aidl/2/.hash') ]; then touch out/soong/.intermediates/hardware/nxp/nfc/intf/nxpnfc/aidl/vendor.nxp.nxpnfc_aidl_interface/checkhash_2.timestamp; else cat 'system/tools/aidl/build/message_check_integrity.txt' && exit 1; fi ############################################################################### # ERROR: Modification detected of stable AIDL API file                        # ############################################################################### Above AIDL file(s) has changed, resulting in a different hash. Hash values may be checked at runtime to verify interface stability. If a device is shipped with this change by ignoring this message, it has a high risk of breaking later when a module using the interface is updated, e.g., Mainline modules. Workaround: echo $(cd 'hardware/nxp/nfc/intf/nxpnfc/aidl/aidl_api/vendor.nxp.nxpnfc_aidl/2' && { find ./ -name "*.aidl" -print0 | LC_ALL=C sort -z | xargs -0 sha1sum && echo 1; } | sha1sum | cut -d " " -f 1) d9e99a62ff5ebed44083a79577ec7ed32d264775 Then,  nano hardware/nxp/nfc/intf/nxpnfc/aidl/aidl_api/vendor.nxp.nxpnfc_aidl/2/.hash replace the value to d9e99a62ff5ebed44083a79577ec7ed32d264775   A runtime error: Problem: You will find the following failed about the permission in the log. java.lang.IllegalStateException: Signature|privileged permissions not in privileged permission allowlist: {com.android.nfc (/apex/com.android.nfcservices/priv-app/[email protected]😞 android.permission.OBSERVE_ROLE_HOLDERS}   Workaround: Add :     <privapp-permissions package="com.android.nfc">         <permission name="android.permission.OBSERVE_ROLE_HOLDERS"/>     </privapp-permissions> To the file : out/target/product/evk_95/system/etc/permissions/privapp-permissions-platform.xml     10. Download the image to the target board: - We use the tool UUU to download the image to the i.MX boards. Download the UUU from here : Releases · nxp-imx/mfgtools - Download the Android 16 BSP i.MX95 EVK demo image from the Android i.MX BSP web page first. There are UUU script and necessary image files already in the demo image package.  - Put the UUU executable file into the demo image folder. uuu_imx_android_flash.bat is the script also in the same folder. - After your Android BSP building is completed and succeed, copy the images to the demo image folder. The image files are located in android_build/out/target/product/evk_95/. - Switch the boot mode to "Download" mode on the i.MX95 FRDM board. - Run the UUU script to download the images to the FRDM board. uuu_imx_android_flash.bat -f imx95 -a -e -u 15x15-frdm -d 15x15-frdm     Run the "TagInfo" on the board: - Download the TagInfo apk file from the NXP TagInfo App web page . - Use the "adb install" command to install the TagInfo to the FRDM board. C:\>adb install com.nxp.taginfo-6.2.0-play-release-protected.apk * daemon not running; starting now at tcp:5037 * daemon started successfully Performing Streamed Install Success   After TagInfo installed, the TagInfo icon will be available on the GUI.   Run the TagInfo, and then put a card on the board. The information of the card will be show on the TagInfo App.     Reference: PN7160/PN7220 – Android 16 porting guide PN7220 NFC Frontend IC with Integrated Power Management | NXP Semiconductors Android OS for i.MX Applications Processors | NXP Semiconductors nxp-nfc-infra · GitHub        
View full article
The PN7642/PN5190/PN7220 requires a calibration before the RF field is switched on for the first time with unloaded condition. "Unloaded" means: Without any additional metal in proximity of the antenna, except for the NFC reader components itself. During development of new readers, this calibration shall be done each time the antenna design, antenna matching, or EMC filter is modified. See a workflow of the Initial calibration for PN7642 done in NFC Cockpit.  During this procedure, the RF Field is switched on for approx. 11 ms, and the calibration data is saved in the memory. Note: Please note that the registers and EEPROM addresses might differ for a different products. Always check the Datasheet for the used product. 
View full article
Introduction We have an official PN7160/PN7220 Android 15 porting guide (PN7160/PN7220 – Android 15 porting guide). But the patches only for Android 15 AOSP r1 (android-15.0.0_r1). If customer want to porting to the newer release of AOSP, there will have many errors during the source code compiling. This document is for customer reference to solve the error one by one.    NOTE :  All the modifications are just for reference. They are NOT a NXP official patches for the newer release of AOSP porting. So the modifications may not be the best solution. Customer please base on their needs to modify the AOSP source code. This is not for production. Customer still need to perform full testing after the porting.    Hardware boards: i.MX8MN EVK (i.MX 8M Nano Evaluation Kit | NXP Semiconductors)   PN7160 EVK (OM27160| Development Kits for PN7160 Plug'n Play NFC Controller | NXP Semiconductors)     The connection between i.MX8MN EVK and PN7160 OM29110ARD-B i.MX8M Nano EVK pin PN7160 pin 3.3V J1003-1 VDD(3.3v) J1-4 5V J1003-2 VBAT (5v) J1-5  I2C3 SDA J1003-3 SDA J2-2 I2C3 SCL J1003-5 SCL J2-1 GPIO3_22 J1003-37 IRQ J2-10 GPIO3_21 J1003-38 REQ J4-2 GND J1003-39 GND J1-6 GPIO3_20 J1003-40 VEN J4-1     Build the Android for i.MX8MN EVK The i.MX Android BSP that I used is Android 15.0.0_2.0.0 (L6.12.20_2.0.0 BSP). It could be downloaded from here: Android OS for i.MX Applications Processors | NXP Semiconductors 1. Download the "Documentation" and the "Install Source Package".  2. Follow the steps in Android User's Guide to build the Android BSP for i.MX8MN EVK first.    According to the android_build/.repo/manifests/aosp-android-15.0.0_2.0.0.xml, you will see the AOSP version is android-15.0.0_r32.   Reference documents for porting: PN7160/PN7220 – Android 15 porting guide  Porting PN7160 to Android 14 on i.MX8M Nano board   Now, we start the porting:  1. Kernel Driver To establish connection with the PN7220 or PN7160, the Android stack uses the nxpnfc kernel driver.  You could download the driver from github below: nfcandroid_platform_drivers/drivers at br_ar_16_comm_infra_dev · nxp-nfc-infra/nfcandroid_platform_d...   The command is : git clone "https://github.com/nxp-nfc-infra/nfcandroid_platform_drivers.git" -b br_ar_16_comm_infra_dev   There is driver for Kernel 6.6 and 6.12. So, please download the correct one for your porting. For example, the kernel in i.MX Android BSP Android 15.0.0_2.0.0 is 6.12. So I will use the 6.12 driver for my porting.   In your porting, make sure the PATH in Makefile and Kconfig files are setting properly.  For example in my porting: . ├── Kconfig ├── Makefile └── pn7160 ├── common.c ├── common.h ├── i2c_drv.c ├── i2c_drv.h ├── Kbuild ├── Kconfig ├── Makefile ├── spi_drv.c └── spi_drv.h   For simplifying everything, we will only add a support for I2C and not SPI. Replace drivers/nfc/pn7160/Makefile default code with following code (for easier understanding) nxpnfc-i2c-objs = i2c_drv.o common.o obj-$(CONFIG_NXP_NFC_I2C) += nxpnfc_i2c.o   The contents of drivers/nfc/Kconfig. Add the PN7160 like below: source "drivers/nfc/pn7160/Kconfig" source "drivers/nfc/fdp/Kconfig" source "drivers/nfc/pn544/Kconfig" source "drivers/nfc/pn533/Kconfig" source "drivers/nfc/microread/Kconfig" source "drivers/nfc/nfcmrvl/Kconfig" source "drivers/nfc/st21nfca/Kconfig" source "drivers/nfc/st-nci/Kconfig" source "drivers/nfc/nxp-nci/Kconfig" source "drivers/nfc/s3fwrn5/Kconfig" source "drivers/nfc/st95hf/Kconfig" endmenu   The contents of drivers/nfc/Makefile. Add the PN7160 like below: # SPDX-License-Identifier: GPL-2.0 # # Makefile for nfc devices # obj-$(CONFIG_NXP_NFC_I2C) += pn7160/ obj-$(CONFIG_NFC_FDP) += fdp/ obj-$(CONFIG_NFC_PN544) += pn544/ obj-$(CONFIG_NFC_MICROREAD) += microread/ obj-$(CONFIG_NFC_PN533) += pn533/ obj-$(CONFIG_NFC_MEI_PHY) += mei_phy.o obj-$(CONFIG_NFC_SIM) += nfcsim.o obj-$(CONFIG_NFC_PORT100) += port100.o obj-$(CONFIG_NFC_MRVL) += nfcmrvl/ obj-$(CONFIG_NFC_TRF7970A) += trf7970a.o obj-$(CONFIG_NFC_ST21NFCA) += st21nfca/ obj-$(CONFIG_NFC_ST_NCI) += st-nci/ obj-$(CONFIG_NFC_NXP_NCI) += nxp-nci/ obj-$(CONFIG_NFC_S3FWRN5) += s3fwrn5/ obj-$(CONFIG_NFC_ST95HF) += st95hf/ obj-$(CONFIG_NFC_VIRTUAL_NCI) += virtual_ncidev.o   2. Adding the "nxpnfc" to the i.MX8MN EVK device tree file &i2c3 { clock-frequency = <100000>; pinctrl-names = "default", "gpio"; pinctrl-0 = <&pinctrl_i2c3>; pinctrl-1 = <&pinctrl_i2c3_gpio>; scl-gpios = <&gpio5 18 GPIO_ACTIVE_HIGH>; sda-gpios = <&gpio5 19 GPIO_ACTIVE_HIGH>; status = "okay"; nxpnfc@28{ compatible = "nxp,nxpnfc"; reg = <0x28>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_nfc>; nxp,nxpnfc-irq = <&gpio3 22 0>; nxp,nxpnfc-ven = <&gpio3 20 0>; nxp,nxpnfc-fw-dwnld = <&gpio3 21 0>; }; The GPIO settings in the IOMUXC: &iomuxc { pinctrl_nfc: nfcgrp { fsl,pins = < MX8MN_IOMUXC_SAI5_RXC_GPIO3_IO20 0X19 // VEN MX8MN_IOMUXC_SAI5_RXD0_GPIO3_IO21 0X19 // FW-DWNLD MX8MN_IOMUXC_SAI5_RXD1_GPIO3_IO22 0X19 // IRQ >; };   3. Modify the imx8mn_gki.fragment File:  android_build/vendor/nxp-opensource/kernel_imx/arch/arm64/configs/imx8mn_gki.fragment Add the "CONFIG_NXP_NFC_I2C=m" into the imx8mn_gki.fragment   4. Add the settings in your corresponding board configuration files in Android - Go to the android_build/device/nxp/imx8m/evk_8mn/  - Modify the BoardConfig.mk. # selinux permissive + BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive BOARD_SEPOLICY_DIRS := \ $(CONFIG_REPO_PATH)/imx8m/sepolicy \ $(IMX_DEVICE_PATH)/sepolicy \ + vendor/nxp/nfc/sepolicy \ + vendor/nxp/nfc/sepolicy/nfc + include vendor/nxp/nfc/BoardConfigNfc.mk   - Add the "nxpnfc_i2c.ko" to the ShareBoardConfig.mk. Make sure the path and the filename are correct. $(KERNEL_OUT)/drivers/net/phy/realtek.ko \ $(KERNEL_OUT)/drivers/pps/pps_core.ko \ $(KERNEL_OUT)/drivers/ptp/ptp.ko \ $(KERNEL_OUT)/drivers/net/ethernet/freescale/fec.ko + $(KERNEL_OUT)/drivers/nfc/pn7160/nxpnfc_i2c.ko endif $(KERNEL_OUT)/drivers/trusty/trusty-core.ko \ $(KERNEL_OUT)/drivers/trusty/trusty-log.ko \ $(KERNEL_OUT)/drivers/trusty/trusty-ipc.ko \ $(KERNEL_OUT)/drivers/trusty/trusty-virtio.ko \ + $(KERNEL_OUT)/drivers/nfc/pn7160/nxpnfc_i2c.ko else BOARD_VENDOR_RAMDISK_KERNEL_MODULES += \ $(KERNEL_OUT)/drivers/input/touchscreen/goodix_ts.ko \ $(KERNEL_OUT)/drivers/input/touchscreen/synaptics_dsx/synaptics_dsx_i2c.ko Endif   - Add the following to the Compatibility_matrix.xml <compatibility-matrix version="1.0" type="device"> <hal format="native" optional="false"> <name>netutils-wrapper</name> <version>1.0</version> </hal> <hal format="aidl" optional="true"> <name>android.hardware.emvco</name> <version>1</version> <interface> <name>IEmvco</name> <instance>default</instance> </interface> </hal> </compatibility-matrix>   - Add the following to the device_framework_matrix.xml <compatibility-matrix version="1.0" type="framework"> <hal format="aidl" optional="true"> <name>nxp.hardware.secureime</name> <version>1</version> <interface> <name>ISecureIME</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>nxp.hardware.imx_dek_extractor</name> <version>1</version> <interface> <name>IDek_Extractor</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>vendor.nxp.nxpnfc</name> <version>2</version> <interface> <name>INxpNfc</name> <instance>default</instance> </interface> </hal> <hal format="aidl" optional="true"> <name>android.hardware.emvco</name> <version>1</version> <interface> <name>IEmvco</name> <instance>default</instance> </interface> </hal> </compatibility-matrix>   - Add the following to the evk_8mn.mk # ------nfc------- $(call inherit-product, vendor/nxp/nfc/device-nfc.mk) $(call inherit-product, vendor/nxp/emvco/device-emvco.mk) PRODUCT_PACKAGES += \ android.hardware.nfc-service.nxp PRODUCT_PACKAGES += \ com.nxp.emvco \ com.nxp.nfc \ nfc_nci_nxp_pn72xx   - Add the nxpnfc_i2c in init.rc # Grant permission for fetching available_pages info of statsd chown system system /proc/pagetypeinfo chmod 0440 /proc/pagetypeinfo exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d \ /vendor/lib/modules nxpnfc_i2c write /sys/power/wake_lock nosleep on post-fs-data && property:vendor.skip.charger_not_need=0 setprop vold.post_fs_data_done 1   - Add nxpnfc to ueventd.nxp.rc /sys/devices/virtual/thermal/thermal_zone* trip_point_0_hyst 0660 system system /sys/devices/virtual/thermal/thermal_zone* trip_point_1_hyst 0660 system system /dev/dmabuf_imx 0664 system system /sys/class/backlight/* brightness 0660 system system /dev/ttymxc1 0666 nfc nfc /dev/ttymxc2 0666 nfc nfc /dev/nxpnfc 0666 nfc nfc # for libcamera /dev/media* 0660 system camera /dev/v4l-subdev* 0660 system camera   5. Apply the NXP AOSP patches As the official NXP NFC patches is only for AOSP android-15.0.0_r1, and there are big different between android-15.0.0_r1 and android-15.0.0_r32. So, before apply the patches, I copy the nfc folders from android-15.0.0_r1 to replace the nfc folders in android-15.0.0_r32.   First, download the AOSP android-15.0.0_r1 from github. $ mkdir android-15.0.0_r1 $ cd android-15.0.0_r1 $ repo init -u https://android.googlesource.com/platform/manifest -b android-15.0.0_r1 $ repo sync   Then, remove the following folders from android-15.0.0_r32. And then copy the following nfc folders from android-15.0.0_r1 to replace the same folders in android-15.0.0_r32. packages/apps/Nfc frameworks/base/nfc frameworks/base/nfc-extras system/nfc   for example: $ rm -rf android_build/packages/apps/Nfc $ cp -ra android-15.0.0_r1/packages/apps/Nfc android_build/packages/apps/   I write a script to download the patches from the github. Customer could put the following scripts on the same directory with android_build. AOSP_adaptation.sh # nxp_nci_hal_nfc git clone "https://github.com/nxp-nfc-infra/nxp_nci_hal_nfc.git" cd nxp_nci_hal_nfc git checkout br_ar_15_comm_infra_dev cp -rf * ../android_build/packages/apps/Nfc/ cd .. # nxp_nci_hal_libnfc-nci git clone "https://github.com/nxp-nfc-infra/nxp_nci_hal_libnfc-nci.git" cd nxp_nci_hal_libnfc-nci git checkout br_ar_15_comm_infra_dev cp -rf * ../android_build/system/nfc/ cd .. # nfcandroid_nfc_hidlimpl git clone "https://github.com/nxp-nfc-infra/nfcandroid_nfc_hidlimpl.git" cd nfcandroid_nfc_hidlimpl git checkout br_ar_15_comm_infra_dev cp -rf * ../android_build/hardware/nxp/nfc cd .. # nfcandroid_frameworks git clone "https://github.com/nxp-nfc-infra/nfcandroid_frameworks.git" cd nfcandroid_frameworks git checkout br_ar_15_comm_infra_dev mkdir ../android_build/vendor/nxp/frameworks cp -rf * ../android_build/vendor/nxp/frameworks cd .. # nfcandroid_emvco_aidlimpl git clone "https://github.com/nxp-nfc-infra/nfcandroid_emvco_aidlimpl.git" cd nfcandroid_emvco_aidlimpl git checkout br_ar_15_comm_infra_dev mkdir ../android_build/hardware/nxp/emvco cp -rf * ../android_build/hardware/nxp/emvco cd .. # nfcandroid_platform_reference git clone "https://github.com/nxp-nfc-infra/nfcandroid_platform_reference.git" cd nfcandroid_platform_reference git checkout br_ar_15_comm_infra_dev cp -rf vendor/nxp/* ../android_build/vendor/nxp/ cd .. # nfcandroid_infra_test_apps git clone https://github.com/nxp-nfc-infra/nfcandroid_infra_test_apps.git cd nfcandroid_infra_test_apps/ git checkout br_ar_15_comm_infra_dev cd test_apps/ cp -rf SMCU_Switch/ ../../android_build/packages/apps/ cp -rf EMVCoModeSwitchApp/ ../../android_build/packages/apps/Nfc/ cp -rf load_unload/ ../../android_build/hardware/nxp/nfc/ cp -rf SelfTestAidl/ ../../android_build/hardware/nxp/nfc/ cd ../.. # nfcandroid_infra_comm_libs git clone "https://github.com/nxp-nfc-infra/nfcandroid_infra_comm_libs.git" cd nfcandroid_infra_comm_libs git checkout br_ar_15_comm_infra_dev cp -rf nfc_tda/ ../android_build/system/ cp -rf emvco_tda/ emvco_tda_test/ ../android_build/hardware/nxp/emvco/ cp -rf NfcTdaTestApp/ ../android_build/packages/apps/Nfc/ cd ..   Apply_patches.sh cd android_build/build/bazel/ patch -p1 < ../../../nfcandroid_platform_reference/build_cfg/build_pf_patches/AROOT_build_bazel.patch cd ../release patch -p1 < ../../../nfcandroid_platform_reference/build_cfg/build_pf_patches/AROOT_build_release.patch cd ../../external/libchrome patch -p1 < ../../../nfcandroid_platform_reference/build_cfg/build_pf_patches/AROOT_external_libchrome.patch cd ../../frameworks/base patch -p1 < ../../../nfcandroid_platform_reference/build_cfg/build_pf_patches/AROOT_frameworks_base.patch cd ../../system/logging patch -p1 < ../../../nfcandroid_platform_reference/build_cfg/build_pf_patches/AROOT_system_logging.patch   So, run the AOSP_adaptation.sh first, then run the Apply_patches.sh.   6. Put changes into hardwatre/interfaces/compatibility_matrices Different compatibility matrix for different Android versions. File: android_build/hardware/interfaces/compatibility_matrices/compatibility_matrix.202404.xml <hal format="aidl"> <name>android.hardware.audio.effect</name> <version>1-2</version> <interface> <name>IFactory</name> <instance>default</instance> </interface> </hal> + <hal format="aidl" optional="true"> + <name>nxp.hardware.imx_dek_extractor</name> + <version>1</version> + <interface> + <name>IDek_Extractor</name> + <instance>default</instance> + </interface> + </hal> + <hal format="aidl" optional="true"> + <name>vendor.nxp.nxpnfc</name> + <version>2</version> + <interface> + <name>INxpNfc</name> + <instance>default</instance> + </interface> + </hal> + <hal format="aidl" optional="true"> + <name>vendor.nxp.emvco</name> + <version>1</version> + <interface> + <name>INxpEmvco</name> + <instance>default</instance> + </interface> + </hal> <hal format="aidl"> <name>android.hardware.audio.sounddose</name> <version>1-3</version>   7. Change the device specific .mk For pn7160, NXP_NFC_HW should equal to pn7160. For pn7220, NXP_NFC_HW should equal to pn7220_i2cs.   File : android_build/vendor/nxp/nfc/device-nfc.mk ##### ##### NXP NFC Device Configuration makefile ###### NXP_NFC_HOST := $(TARGET_PRODUCT) ifndef TARGET_NXP_NFC_HW NXP_NFC_HW := pn7160 else NXP_NFC_HW := $(TARGET_NXP_NFC_HW) endif NXP_NFC_PLATFORM := pn54x NXP_VENDOR_DIR := nxp NXP_I2CM_S := $(TARGET_NXP_I2C_M_S)   File: android_build/vendor/nxp/emvco/device-emvco.mk NXP_VENDOR_DIR := nxp NXP_NFC_HW := $(TARGET_NXP_NFC_HW) ifeq ($(strip $(TARGET_NXP_NFC_HW)),) NXP_NFC_HW := pn7160 endif # Nfc service has dependency with EMVCo JAR PRODUCT_PACKAGES += \ com.nxp.emvco   8. Now, you can start to build the Android BSP For i.MX8MN EVK,  $ source build/envsetup.sh $ lunch evk_8mn-nxp_stable-userdebug $ export TARGET_RELEASE=nxp_stable $ build_build_var_cache $ ./imx-make.sh -j4 2>&1 | tee build-log.txt   When building the BSP, there will have many errors during the build. I list some errors and the reference solution below for customer reference.  Error :  Complain about the nfc_aconifg_flags.   Workaround : packages/apps/Nfc/flags/Android.bp aconfig_declarations { // name: "nfc_aconfig_flags", name: "com.android.nfc.flags-aconfig", package: "com.android.nfc.flags", container: "system", srcs: ["nfc_flags.aconfig"], } java_aconfig_library { // name: "nfc_aconfig_flags_lib", // aconfig_declarations: "nfc_aconfig_flags", name: "com.android.nfc.flags-aconfig-java", aconfig_declarations: "com.android.nfc.flags-aconfig", min_sdk_version: "33", apex_available: [ "//apex_available:platform", "com.android.nfcservices", ], } java_library { name: "nfc_flags_lib", sdk_version: "system_current", min_sdk_version: "33", srcs: [ "lib/**/*.java", ], static_libs: [ "com.android.nfc.flags-aconfig-java", ],   Error: platform_testing/build/tasks/tests/native_test_list.mk: error: continuous_native_tests: Unknown installed file for module 'libnfc-nci-jni-tests'   Workaround: remove 'libnfc-nci-jni-tests' in  native_test_list.mk   Error: error: packages/apps/Nfc/tests/instrumentation/Android.bp:6:1: module "NfcNciInstrumentationTests" variant "android_common": cannot depend directly on java_sdk_library "android.test.runner"; try depending on "android.test.runner.stubs", "android.test.runner.stubs.system", "android.test.runner.stubs.test", or "android.test.runner.impl" instead   Workaround:  The hints are gave in the error message.. Change the "android.test.runner" to "android.test.runner.stubs", "android.test.runner.stubs.system", "android.test.runner.stubs.test", or "android.test.runner.impl".   Error: error: vendor/nxp/frameworks/nfc/Android.bp:12:1: module "com.nxp.nfc" variant "android_common": depends on //frameworks/base/nfc:framework-nfc.impl which is not visible to this module You may need to add "//vendor/nxp/frameworks/nfc" to its visibility   Workaround: File : frameworks/base/nfc/Android.bp permitted_packages: [ "android.nfc", "com.android.nfc", ], impl_library_visibility: [ "//frameworks/base:__subpackages__", "//cts/hostsidetests/multidevices/nfc:__subpackages__", "//cts/tests/tests/nfc", "//vendor:__subpackages__", "//packages/apps/Nfc:__subpackages__", ],     Error: packages/apps/Nfc/nci/src/com/android/nfc/dhimpl/NativeT4tNfceeManager.java:20: error: duplicate class: com.android.nfc.dhimpl.NativeT4tNfceeManager   Workaround: Edit the file packages/apps/Nfc/nci/src/com/android/nfc/dhimpl/NativeT4tNfceeManager.java then comment out the duplicated class.   Error: android/R.java:12483: error: could not resolve field FLAG_NFC_ASSOCIATED_ROLE_SERVICES     .annotation.FlaggedApi(android.nfc.Flags.FLAG_NFC_ASSOCIATED_ROLE_SERVICES)   Workaround: Edit the file frameworks/base/nfc/java/android/nfc/flags.aconfig Add the below flag. flag { name: "nfc_associated_role_services" is_exported: true namespace: "nfc" description: "Share wallet role routing priority with associated services" bug: "366243361" }   Error: FAILED: platform_testing/build/tasks/tests/native_test_list.mk: error: continuous_native_tests: Unknown installed file for module 'libnfc-nci-tests'   Workaround: Remove the libnfc-nci-tests in native_test_list.mk.   Error: prebuilts/clang/host/linux-x86/clang-r536225/include/c++/v1/string:780:43: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'   780 |   static_assert((is_same<_CharT, typename traits_type::char_type>::value),       |                                           ^ packages/apps/Nfc/nci/jni/NativeNfcTda.cpp:32:35: note: in instantiation of template class 'std::basic_string<unsigned char>' requested here    32 | static std::basic_string<uint8_t> sRxTdaDataBuff;       |                                   ^   Workaround: Edit the packages/apps/Nfc/nci/jni/NativeNfcTda.cpp using android::base::StringPrintf; extern bool nfc_debug_enabled; SyncEvent sCtLibSyncEvt; //static std::basic_string<uint8_t> sRxTdaDataBuff; static std::basic_string<char> sRxTdaDataBuff;   Error: packages/apps/Nfc/nci/jni/NativeT4tNfcee.cpp:493:21: error: no matching member function for call to 'append'   493 |       sRxDataBuffer.append(data.p_data, data.len);       |       ~~~~~~~~~~~~~~^~~~~~   Workaround:  Edit the packages/apps/Nfc/nci/jni/NativeT4tNfcee.cpp void NativeT4tNfcee::t4tReadComplete(tNFA_STATUS status, tNFA_RX_DATA data) { mT4tOpStatus = status; if (status == NFA_STATUS_OK) { if (data.len > 0) { sRxDataBuffer.insert(sRxDataBuffer.end(), data.p_data, data.p_data + data.len); LOG(DEBUG) << StringPrintf("%s: Read Data len new: %d ", __func__, data.len); } } SyncEventGuard g(mT4tNfcEeRWCEvent); mT4tNfcEeRWCEvent.notifyOne(); }   Error: frameworks/base/core/java/android/provider/Settings.java:2351: error: could not resolve field FLAG_NFC_ACTION_MANAGE_SERVICES_SETTINGS     @FlaggedApi(android.nfc.Flags.FLAG_NFC_ACTION_MANAGE_SERVICES_SETTINGS)   Workaround:  File: frameworks/base/nfc/java/android/nfc/flags.aconfig Add the following to the flags.aconfig flag { name: "nfc_action_manage_services_settings" is_exported: true namespace: "nfc" description: "Add Settings.ACTION_MANAGE_OTHER_NFC_SERVICES_SETTINGS" bug: "358129872" }   There are some errors are not listed in the table because there will have some hints to correct the error in the error message. Customer could follow the hints and base on the needs to modify the source code. Sometime, customer could compare the source code between r1 and r32. Here is the AOSP source code android-15.0.0_r32  and the android-15.0.0_r1.   9. Download the image to the i.MX8MN EVK board - Switch to download mode on the 8MN EVK board - Download the Android 15 BSP i.MX8MN EVK demo image from the Android BSP web page first. Because there are UUU script and necessary image files already in the demo image package.  - Download the UUU from here : Releases · nxp-imx/mfgtools - Put the UUU executable file into the demo image folder. uuu_imx_android_flash.bat is the script also in the same folder. - After your building is succeed, Copy the images to the demo image folder. The images are located in android_build/out/target/product/evk_8mn/ - Run the UUU script to download the images to the EVK board.     Reference: i.MX6ULL EVK running Yocto Linux + PN7160 Porting PN7160 to Android 14 on i.MX8M Nano board Android OS for i.MX Applications Processors | NXP Semiconductors PN7160/PN7220 – Android 15 porting guide Plug-n-Play NFC Frontend with Integrated Firmware | NXP Semiconductors  
View full article
Prerequities:  PN7642 design-in recommendations   1// Impedance tuning  PN76 family antenna design guide The target impedance is chosen based on the target application. If full power is required (e.g., POS terminals). The target impedance of 15-17 Ω is recommended. For lower power applications using ULPCD, the higher impedance is typically preferred, 30-50 Ω (symmetrical tuning).   2// Dynamic power control  PN7642 - Basic RF power limitation using DPC   3// H-Field check  There are given limits, especially for the maximum H-field radiated by the reader. Exceeding these limits might lead to destroying the NFC Card/NFC Tag.   The H-Field can be measured with the help of test equipment, as  ISO 10373-6 Test PICC EMVCo 3.0 Test PICC  For indication only, the customers can use "smart" Field Strength Probes as shown below :        Note: The most critical position occurs when the card is placed directly on the NFC antenna . In this case, if the H-field exceeds the maximum allowed level, the output power must be reduced using DPC settings. 4// HF Attenuator value  Turn on the RF Field with the DPC set and enabled from the previous step  Read the CLIF_RXCTRL_STATUS register and check the HF_ATT_VAL as shown below.    The value for the "unloaded" condition with full power shall be approximately 35-45dec.  If the value is out of this range, the customer is required to adjust the Rx resistors to reach this value.  5// Receiver settings  Check the "Power" range and Communication Range with the default settings provided by NXP.  Power Range -> The distance at which the NFC Tag can still generate its answer, but the NFC Reader does not see it  Communication Range -> The distance at which the NFC Tag can still communitate with the NFC Reader  Ideally, Power Range ≈ Communication Range Also, the NFC Reader should not generate any false communications as e.g., "HAL COLLISION ERROR".  The optimisation of the receiver can be done in the following way:  Enter DPC Calibration  Go to the "ARC" menu and "disable" the ARC algorithm     This will force the IC to use the RX settings from the following Register/EEPROM SIGPRO_RM_TECH_REG DGRM_RSSI_REG   5.1// SIGPRO_RM_TECH_REG (RM_MF_GAIN parameter) This parameter basically defines the gain of the input amplifier.  Select SIGPRO_RM_TECH_REG  Switch "operation" to EEPROM and choose the required technology  Increase the RM_MF_GAIN to 0x02 (it depends on the setup).     5.2// DGRM_RSSI_REG (DGRM_SIGNAL_DETECT_TH_OVR_VAL parameter) This parameter defines a threshold from which the internal logic starts to decode the incoming signal.  If the threshold is too low or very close to the noise floor, the system can detect the noise as an NFC Communication.  It is therefore,  Threshold + margin > noise floor The best routine is to perform "Signal Detection Threshold" analysis. This can be done with the help of the NFC Cockpit (described in PN7642 design-in recommendations) As a result, the user can obtain the mean value of the "Noise," and suggested "DGRM_SIGNAL_DETECT_TH_OVR_VAL" threshold based on the inserted "Margin."  Maring (m) + Noise mean value (μ) = Threshold  6+16=23 Then this value shall be written in "DGRM_RSSI_REG" EEPROM as shown below.      6// ULPCD Settings  We recommend the following ULPCD Settings as a starting point.  ULPCD VDDPA should be chosen in such a way that the HF Attenuator value is not 0x00! The typical value for HF Attenuator in ULPCD is around 0x05-0x0B.   6.1// RSSI Threshold evaluation  For a proper RSSI Threshold selection, it is recommended to perform the ULPCD Calibration, e.g., 20 times, and check the "jitter" of the RSSI signal for your device.    If you see that the RSSI value is jittering, e.g., 1 unit as shown above. The absolute minimum threshold for this case is 2. However, it is always recommended to include adequate margin (To prevent false wake-ups).   Generally, the margin of 2 units is sufficient. So in this case, the optimum threshold will be 4. 
View full article