Hardware:
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
$ 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"
BBLAYERS += " ${BSPDIR}/sources/meta-nxp-nfc"
$ 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
4. OM27160A1HN Hardware Design Files