NFC Knowledge Base

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

NFC Knowledge Base

Discussions

Sort by:
This document provides a step by step guide of how to use the CLRC663 plus with i.MX RT1050. For this purpose, we need to port the NFC Reader Library to i.MX RT1050.  There are two zip files attached to this document: 1. "NFCReaderLibrary_IMXRT1050_Porting Guide +DAL_IMXRT1050_BLE-NFC-V2.zip" : This folder is pre-configured for those who want to use BLE-NFC-v2 board with i.MX RT1050. 2. "NFCReaderLibrary_IMXRT1050_Porting Guide +DAL_IMXRT1050_CLEV6630B.zip" : This folder is pre-configured for those who want to use CLEV6630B board with i.MX RT1050. A video describing how to use i.MX RT1050 with CLRC663 Plus Family is available by clicking this link (Using i.MX RT 1050 with CLRC663 plus family |NXP ) as well. 
View full article
Hardware: 1. i.MX6ULL EVK board   2. OM27160A1HN   Software: 1. Build the Yocto Linux BSP for i.MX6ULL EVK. Here are the steps: $ mkdir L6.6.36_2.1.0 $ cd L6.6.36_2.1.0 $ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-scarthgap -m imx-6.6.36-2.1.0.xml $ repo sync   $ DISTRO=fsl-imx-xwayland MACHINE=imx6ull14x14evk source imx-setup-release.sh -b build-for-6ullevk $ bitbake core-image-full-cmdline   2. Add the nxpnfc driver to kernel After the BSP build succeed, the kernel source code is located here: L6.6.36_2.1.0/build-for-6ullevk/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/6.6.36+git/git/   Clone the nxpnfc repository into the kernel directory, replacing existing implementation: $ cd L6.6.36_2.1.0/build-for-6ullevk/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/6.6.36+git/git/ $ rm -rf drivers/nfc $ git clone https://github.com/NXPNFCLinux/nxpnfc.git drivers/nfc  This will end-up with the folder drivers/nfc containing the following files: • README.md: repository information • Makefile: driver heading makefile • Kconfig: driver configuration file • LICENSE: driver licensing terms • i2c_devicetree.txt: example of I²C device tree definition • spi_devicetree.txt: example of SPI device tree definition • nfc sub folder containing: – Makefile: – common.c: generic driver implementation – common.h: generic driver interface definition – i2c.c: I2C specific driver implementation – i2c.h: I2C specific driver interface definition – spi.c: SPI-specific driver implementation – spi.h: SPI-specific driver interface definition   Through kernel menuconfig procedure include the targeted driver to the build, as built-in (<*>): $ bitbake linux-imx -c menuconfig <*> NFC I2C Slave driver for NXP-NFCC       3. Connection between i.MX6ULL EVK and the PN7160 There are some pins on the Arduino header on the i.MX6ULL EVK board can be used to connect the PN7160 board. Below is the schematic of the Arduino headers on the i.MX6ULL EVK board. The two I2C2 pins can be used for I2C connection. The UART2_RX, UART2_TX and UART2_RTS can be changed to GPIO for connecting IRQ, VEN and DWL_REQ of PN7160, respectively. Below is the J1704 and J1703 on the EVK board.   Below is the schematic of Arduino interface on OM27160A1HN. There is a connector board (OM29110ARD-B). The OM27160A1HN is connecting on top of it. Below is the connectors board schematic. So, on the i.MX6ULL EVK board, we need I2C2 SDA and I2C2 SCL for I2C connections. And 3 GPIO pins for PN7160's IRQ, VEN and DWL_REQ. Here is the connection between i.MX6ULL EVK and OM29110ARD-B. OM29110ARD-B pin i.MX6ULL EVK pin I2C_SCL J2-1 I2C2_SCL J1704-10 I2C_SDA J2-2 I2C2_SDA J1704-9 GPIO_0 J2-10 GPIO1_21 J1703-1 GPIO_1 J4_1 GPIO1_20 J1703-2 GPIO_2 J4_2 GPIO1_25 J1703-3 3.3V J1-4 3.3V J1705-4 5V J1-5 5V J1705-5 GND J1-6 GND J1705-6      4. Modify the device tree file of i.MX6ull evk. The device tree file for i.MX6ULL evk is imx6ul-14x14-evk.dtsi. The location of the device tree file is here: L6.6.36_2.1.0/build-for-6ullevk/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/6.6.36+git/git/arch/arm/boot/dts/nxp/imx/imx6ul-14x14-evk.dtsi   As we don't use the UART2, we disabled it. &uart2 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_uart2>; uart-has-rtscts; /* for DTE mode, add below change */ /* fsl,dte-mode; */ /* pinctrl-0 = <&pinctrl_uart2dte>; */ status = "disabled"; // <--- change the status to "disabled" bluetooth { compatible = "nxp,88w8987-bt"; }; };   Put the below nxpnfc under the &I2C2 node. nxpnfc: nxpnfc@28 { compatible = "nxp,nxpnfc"; reg = <0x28>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_nfcgpio>; nxp,nxpnfc-irq = <&gpio1 21 0>; nxp,nxpnfc-ven = <&gpio1 20 0>; nxp,nxpnfc-fw-dwnld = <&gpio1 25 0>; };   Like this: Add the gpios for nxpnfc. pinctrl_nfcgpio: nfcgpiogrp { fsl,pins = < MX6UL_PAD_UART2_RX_DATA__GPIO1_IO21 0xb0 //irq MX6UL_PAD_UART2_TX_DATA__GPIO1_IO20 0xb0 //ven MX6UL_PAD_UART3_RX_DATA__GPIO1_IO25 0xb0 //dwld req >; };     5. Re-compile the kernel and the whole image. $ bitbake linux-imx -c compile $ bitbake core-image-full-cmdline     6. Using UUU to program the image to the board. The built image is .wic.zst file. We need to program it to the board. It is located in the deploy folder below. L6.6.36_2.1.0/build-for-6ullevk/tmp/deploy/images/imx6ull14x14evk/core-image-full-cmdline-imx6ull14x14evk.rootfs-20241113103828.wic.zst   Download the UUU.exe from here: https://github.com/nxp-imx/mfgtools/releases   Download the Demo image for i.MX6ULL EVK from the Linux BSP web page.   Unzip the demo image file to a folder. And then copy the UUU.exe to the same demo image folder.   Connect the board to your PC using the USB cable. Switch the boot mode to "Serial Downloader mode"   On the PC side, run the below command to program the image to SD card on the i.MX6ULL EVK. uuu -b sd_all core-image-full-cmdline-imx6ull14x14evk.rootfs-20241112083235.wic.zst   Then switch the boot mode to "Internal Boot (Development)". Restart the board. Now, you can login as "root" and use the board. And you can see the nxpnfc driver is properly loaded.     7. Build the NFC Library and the nfcDemoApp in Yocto In the Yocto's sources directory, download the meta-nxp-nfc layer from https://github.com/NXPNFCLinux/meta-nxp-nfc     $ git clone https://github.com/NXPNFCLinux/meta-nxp-nfc.git  Then, the NFC library recipe is located in L6.6.36_2.1.0/sources/meta-nxp-nfc/recipes-nfc/nxp_nfc. Change the recipe nxp-nfc_git.bb as below: # Copyright (C) 2016 NXP Semiconductors DESCRIPTION = "Linux NFC stack for NCI based NXP NFC Controllers." LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=86d3f3a95c324c9479bd8986968f4327" SRC_URI = " \ git://github.com/NXPNFCLinux/linux_libnfc-nci.git;branch=NCI2.0_PN7160;protocol=https \ " SRCREV = "6bf9f42b94e267f6384043009bda84c11e7ebbaa" SRC_URI[sha256sum] = "47bdc27108fc8d66ce5d6c33f76b419cdef20c24b9e187ada8e689d1bd7f79c7" inherit autotools pkgconfig lib_package S = "${WORKDIR}/git"   Add the meta-nxp-nfc layer to the build definition. Updating file build_dir/conf/bblayers.conf with: BBLAYERS += " ${BSPDIR}/sources/meta-nxp-nfc"   Build meta-nxp-nfc layer:     $ bitbake nxp-nfc After build succeed, the library files and the nfcDemoApp are located in here : L6.6.36_2.1.0/build-for-6ullevk/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/nxp-nfc/git/   Use the "scp" command to copy the files to the EVK board via the Network. If the folder is not exist on the EVK, please use "mkdir" to make the folder on the EVK first. Then use the "scp" command.  Here is the example: (**The IP address below should change to your EVK's IP address.) scp build/.libs/* root@10.192.246.136:/.libs/ scp image/etc/libnfc* root@10.192.246.136:/etc/   scp image/usr/lib/* root@10.192.246.136:/usr/lib     On the EVK board: root@imx6ull14x14evk:/# mkdir /usr/local root@imx6ull14x14evk:/# mkdir /usr/local/etc root@imx6ull14x14evk:/# cp /etc/libnfc-nci.conf /usr/local/etc   Now, you can run the nfcDemoApp on the i.MX6ULL EVK. root@imx6ull14x14evk:/# cd .libs/ root@imx6ull14x14evk:/.libs# ./nfcDemoApp poll       References: 1. i.MX Yocto Project User's guide 2. PN7160 Linux Porting Guide 3. MCIMX6ULL-EVK_DESIGNFILES 4. OM27160A1HN Hardware Design Files 5. OM29110 NFC’s SBC Interface Board Design Files 6. PN7150 NFC Controller on i.MX8M mini evk running Yocto
View full article
Hello NFC Community! This document demonstrates that multiple records can be also read from a Tag with TagXplorer. Please follow the steps below. Let's begin... Please make sure that you have written more than on record with NXP TagWriter app. For a more detailed explanation on this, please refer to the following document: Writing multiple NDEF text records with TagWrite app  The app can be found and downloaded from the Play Store: NFC TagWriter by NXP - Apps on Google Play  -> Connect the reader in TagXplorer -> Place the card on the reader and press Connect Tag -> Check for NDEF (1) and then, read NDEF (2). The Text Records can be visualized in the NDEF Payload Info below: I hope this is of great help! Ivan R.
View full article
SPIM module is one of the master interfaces provided by PN7462 , which is a 32-bit ARM Cortex-M0-based NFC microcontroller, and users may use this interface to connect with up to two SPI slave devices. The NFC reader library provides SPIM driver code in phHal/phhalSPIM, and users may directly use the following APIs in their application to implement simple SPI transaction, just like what is done  in the demo of "PN7462AU_ex_phExHif". While this demo has limitation with some SPI nor flash devices, which need a write-read operation in one NSS session, for example, the SPI nor flash device on OM27462 as below: Please note to solder R202 and connect it to 3V3 to make sure nHold pin has pull-up out of POR. The following is one of the command sets this device supports: This command contains 1 write(9F) followed by 3 read operations in one NSS session, but if you implement it with phhalSPIM_Transmit() and phhalSPIM_Receive() as below: status = phhalSPIM_Transmit(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_INIT_CRC, PH_EXHIF_HW_SPIM_APPEND_CRC, PH_EXHIF_HW_SPIM_CRC_INIT, 2, cmd_buf, PH_EXHIF_HW_SPIM_CRC_OFFSET);    status = phhalSPIM_Receive(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_INIT_CRC, PH_EXHIF_HW_SPIM_CRC_INIT, data_length, dst, PH_EXHIF_HW_SPIM_CRC_OFFSET);" You will have the following result: expected: NSS   \__________________________/ MOSI     CMD A7-A0 MISO                            DATA       actual:                         NSS   \____________||______________/ MOSI     CMD A7-A0 MISO                           DATA so the pulse between the write and read is the problem, and here we have to handle the NSS line manually, with the help of NSS_VAL and NSS_CONTROL bits in SPIM_CONFIG_REG. so the code should be like this:   Assert NSS   status = phhalSPIM_Transmit(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_INIT_CRC, PH_EXHIF_HW_SPIM_APPEND_CRC, PH_EXHIF_HW_SPIM_CRC_INIT, 2, cmd_buf, PH_EXHIF_HW_SPIM_CRC_OFFSET);    status = phhalSPIM_Receive(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_INIT_CRC, PH_EXHIF_HW_SPIM_CRC_INIT, data_length, dst, PH_EXHIF_HW_SPIM_CRC_OFFSET);"   De-assert NSS The NSS line assert and de-assert function can be implemented with register bit level APIs, just like below:             PH_REG_SET_BIT(SPIM_CONFIG_REG, NSS_VAL);//de-assert NSS             PH_REG_SET_BIT(SPIM_CONFIG_REG, NSS_CTRL);             PH_REG_CLEAR_BIT(SPIM_CONFIG_REG, NSS_VAL);//assert NSS Please also include the following header files in your application code. #include "ph_Reg.h" #include "PN7462AU/PN7462AU_spim.h" Please notice that phhalSPIM_Transmit() and phhalSPIM_Receive() are Rom based function, which clear NSS_CTRL bit by default. We can not change ROM API's behave but fortunately we have phhalSPIM_TransmitContinue() and phhalSPIM_ReceiveContinue() instead. so the final solution will be like below: Assert NSS   status = phhalSPIM_TransmitContinue(1, cmd_buf);    status = phhalSPIM_ReceiveContinue(3, dst);   De-assert NSS This doesn't mean phhalSPIM_Transmit() and phhalSPIM_Receive() are useless, because they can also help up to configure the SPI master interface, if you don't want to use register bit level API to initial the SPIM module manually. Please note to use 1 byte for write/read length to make these two functions work properly. so the whole pseudo code is like below: phhalSPIM_Init(PH_HW_SPIM_TIMEOUT) ; phhalSPIM_Configure(PH_HW_SPIM_SLAVE, PH_HW_SPIM_MSB_FIRST,                 \                                     PH_HW_SPIM_MODE, PH_HW_SPIM_BAUDRATE,  \                                     PH_HW_SPIM_NSSPULSE, PH_HW_SPIM_NSSPOL) ; status = phhalSPIM_Transmit(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_INIT_CRC, PH_EXHIF_HW_SPIM_APPEND_CRC, PH_EXHIF_HW_SPIM_CRC_INIT, 1, cmd_buf, PH_EXHIF_HW_SPIM_CRC_OFFSET);    status = phhalSPIM_Receive(PH_EXHIF_HW_SPIM_SLAVE, PH_EXHIF_HW_SPIM_INIT_CRC, PH_EXHIF_HW_SPIM_CRC_INIT, 1, dst, PH_EXHIF_HW_SPIM_CRC_OFFSET);" Assert NSS   status = phhalSPIM_TransmitContinue(1, cmd_buf);    status = phhalSPIM_ReceiveContinue(3, dst);   De-assert NSS The following steps show how to create a new project based on NFC reader library, please refer to https://www.nxp.com/docs/en/user-guide/UM10883.pdf  on how to import the NFC reader library. 1. Create a new project after importing the NFC reader library. 2. if you installed PN7462 support package, you will see this: 3. add a link to NFC reader lib: 4. add path and enable NFC reader lib in the project: 5. delete cr_startup.c and create the main code as well as the header file: 6. Build result: 7.Debug result: To fetch the ready demo, please submit a private ticket via the guide of https://community.nxp.com/docs/DOC-329745 . Hope that helps, Best regards, Kan
View full article
Using an alternative clock source to set up PN7462's contact interface clock , so that we have more options of the clock frequency.
View full article