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:
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
netutils-wrapper
1.0
android.hardware.emvco
1
IEmvco
default
- Add the INxpNfc and IEmvco to the device_framework_matrix.xml
nxp.hardware.secureime
1
ISecureIME
default
nxp.hardware.ele
1
ISecureEnclave
default
nxp.hardware.imx_dek_extractor
1
IDek_Extractor
default
vendor.nxp.nxpnfc_aidl
2
INxpNfc
default
android.hardware.emvco
1
IEmvco
default
- 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
android.hardware.audio.effect
1-3
IFactory
default
nxp.hardware.imx_dek_extractor
1
IDek_Extractor
default
nxp.hardware.ele
1
ISecureEnclave
default
vendor.nxp.nxpnfc_aidl
2
INxpNfc
default
vendor.nxp.emvco
1
INxpEmvco
default
android.hardware.authsecret
1
IAuthSecret
default
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]
Workaround:
Add :
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