2251519_en-US

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

2251519_en-US

2251519_en-US

PN7160 PN7220 Android 15 Porting to i.MX8MN EVK

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. 


Hardware boards:

i.MX8MN EVK


PN7160 EVK


PN7220 EVK



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 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.


Now, follow the PN7160/PN7220 – Android 15 porting guide to porting the NFC to i.MX Android BSP. 


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...

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:

android_build/vendor/nxp-opensource/kernel_imx/drivers/nfc$ tree
.
├── Kconfig
├── Makefile
└── pn7160
        ├── common.c
        ├── common.h
        ├── i2c_drv.c
        ├── i2c_drv.h
        ├── Kbuild
        ├── Kconfig
        ├── Makefile
        ├── spi_drv.c
        └── spi_drv.h

1 directory, 11 files

android_build/vendor/nxp-opensource/kernel_imx/drivers/nfc$ cat Makefile
#
# Makefile for the kernel nfc device drivers.
#
obj-y += pn7160/

android_build/vendor/nxp-opensource/kernel_imx/drivers/nfc$ cat Kconfig
source "drivers/nfc/pn7160/Kconfig"


2. Adding the "nxpnfc" to the i.MX8MN EVK device tree file.

Show the connections table on the board.

Show the pictures


&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>;
};


&iomuxc {

        pinctrl_nfc: nfcgrp {

                fsl,pins = <

                        MX8MN_IOMUX_SAI5_RXC_GPIO3_IO20                 0X19  // VEN

                        MX8MN_IOMUX_SAI5_RXD0_GPIO3_IO21                0X19  // FW-DWNLD

                        MX8MN_IOMUX_SAI5_RXD1_GPIO3_IO22                0X19  // IRQ

                >;

        };

Show the schematic.


 3. Modify the imx8mn_gki.fragment

nano vendor/nxp-opensource/kernel_imx/arch/arm64/configs/imx8mn_gki.fragment

Add the CONFIG_NXP_NFC_I2C=m


4. Go to the 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


ShareBoardConfig.mk


    $(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/nfc/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/nfc/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


Compatibility_matrix.xml


   

        netutils-wrapper

        1.0

   

   

        android.hardware.emvco

        1

       

            IEmvco

            default

       

   



device_framework_matrix.xml

   

        nxp.hardware.secureime

        1

       

            ISecureIME

            default

       

   

   

        nxp.hardware.imx_dek_extractor

        1

       

            IDek_Extractor

            default

       

   

   

        vendor.nxp.nxpnfc

        2.0

       

            INxpNfc

            default

       

   

   

        android.hardware.emvco

        1

       

            IEmvco

            default

       

   




evk_8mn.mk


# -------@block_bluetooth-------

# Bluetooth HAL

PRODUCT_PACKAGES += \

    android.hardware.bluetooth \

    android.hardware.bluetooth-service.default.nxp


# NXP 8987 Bluetooth vendor config

PRODUCT_PACKAGES += \

    bt_vendor.conf


# ------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


# -------@block_usb-------



Init.rc


on post-fs && property:vendor.skip.charger_not_need=0

    # Swap in only 1 page at a time

    write /proc/sys/vm/page-cluster 0


    # 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



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. 

hardware/interfaces/compatibility_matrices/compatibility_matrix.202404.xml


   

        android.hardware.wifi.hostapd

        1

       

            IHostapd

            default

       

   

   

        android.hardware.wifi.supplicant

        2

       

            ISupplicant

            default

       

   

   

        nxp.hardware.imx_dek_extractor

        1

       

            IDek_Extractor

            default

       

   

   

        vendor.nxp.nxpnfc

        2.0

       

            INxpNfc

            default

       

   

   

        vendor.nxp.emvco

        1

       

            INxpEmvco

            default

       

   


6.  android_build/vendor/nxp/nfc/device-nfc.mk

android_build/vendor/nxp/emvco/device-emvco.mk


Two approach.

1. NXP NFC Patch to Android AOSP and then build. If the Android release is too new, It will be a lot of errors,

2. Copy the R1 files to R30 first, then run NXP NFC patch. Then build.


I use the second.

Download the AOSP R1 source code.

Copy the R1 replace the folders below.


Apply the patches.


build the code.

Here is the error list and the reference solution.





Tags (1)
No ratings
Version history
Last update:
‎11-30-2025 07:39 PM
Updated by: