NFC PN7150 Android Oreo porting

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

NFC PN7150 Android Oreo porting

5,467 Views
nikolaos_pasalo
Contributor II

Hi,

I'm trying to add support for NFC to our Android device. We are using the PN7150 module. I have followed the documentation to add the NXP libraries into our AOSP. So, following the documentation here:

https://www.nxp.com/docs/en/application-note/AN11690.pdf 

I added these lines in our manifest file:

<remote name="CodeAuroraExt" fetch="https://source.codeaurora.org/external"/>

<project name="nfcandroid/NfcAndroid_LibnfcNci" remote="CodeAuroraExt" path="NxpNfcAndroid/NfcAndroid_libnfcNci" revision="refs/tags/NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc"/>
<project name="nfcandroid/NfcAndroid_Nfc" remote="CodeAuroraExt" path="NxpNfcAndroid/NfcAndroid_Nfc" revision="refs/tags/NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc"/>
<project name="nfcandroid/NfcAndroid_Vendor" remote="CodeAuroraExt" path="NxpNfcAndroid/NfcAndroid_Vendor" revision="refs/tags/NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc"/>
<project name="nfcandroid/NfcAndroid_Base" remote="CodeAuroraExt" path="NxpNfcAndroid/NfcAndroid_Base" revision="refs/tags/NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc"/>
<project name="nfcncisw/nxpnfc_android_oreo" remote="CodeAuroraExt" path="NxpNfcAndroid" revision="master"/>

I was able to add the device in the kernel and I can see that a /dev/pn544 device exists. I can see the NFC device in the Android Settings menu into "Connected Devices", but it looks like I cannot enable the device.

At first I was getting some build errors because we have the TREBLE enabled and one of the patched had the following line added:

+ /system/bin/hw/vendor\.nxp\.nxpnfc@1\.0-service               u:object_r:hal_nfc_default_exec:s0

After replacing the /system with /(vendor|system/vendor) solved my build problem.

Secondly, I was getting some errors that the INfc library couldn't be found neither in the framework nor in the manifest. So I had to add the <interface> section in my manifest file.

<!-- NFC service -->
<hal format="hidl">
<name>android.hardware.nfc</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>INfc</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>vendor.nxp.nxpnfc</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>INqNfc</name>
<instance>default</instance>
</interface>
</hal>

Now it looks like I am getting a timeout error on the following line:

mHal = INfc::getService();

located in under the /system/nfc/src/adaption/NfcAdaption.cpp:416

Any help will be much appreciated.

0 Kudos
6 Replies

2,467 Views
nikolaos_pasalo
Contributor II

It looks like the problem with the never returning function: mHal = INfc::getService(); was that the service vendor.nxp.nxpnfc wasn't actually running. After fixing that issue the NFC looks like it is starting up properly.

Unfortunately now I have another issue. When I am trying to put an NFC TAG on the back of my device to read it, I am getting the following logcat output:

08-06 12:24:59.330 416 3448 D NxpTml : PN54X - Read requested.....
08-06 12:24:59.330 416 3448 D NxpTml : PN54X - Invoking I2C Read.....
08-06 12:24:59.330 3273 3434 I BrcmNfcNfa: nfa_dm_disc_sm_execute (): new state: DISCOVERY (1), disc_flags: 0x1
08-06 12:25:07.943 416 3448 D NxpTml : PN54X - I2C Read successful.....len = 4
08-06 12:25:07.943 416 3448 D NxpTml : PN54X - Posting read message.....
08-06 12:25:07.943 416 3448 D NxpNciR : len = 4 <= 600701A1
08-06 12:25:07.943 416 3451 D NxpHal : read successful status = 0x0
08-06 12:25:07.944 3273 3434 I BrcmNfcNfa: NFC received ntf gid:0
08-06 12:25:07.944 3273 3434 I BrcmNfcNfa: nci_proc_core_ntf opcode:0x7
08-06 12:25:07.944 3273 3434 I BrcmNfcNfa: nfa_dm_nfc_response_cback () NFC_GEN_ERROR_REVT(0x500d)
08-06 12:25:07.944 3273 3434 I BrcmNfcNfa: nfa_dm_disc_data_cback ()
08-06 12:25:07.944 3273 3434 I BrcmNfcNfa: nfa_dm_disc_sm_execute (): state: DISCOVERY (1), event: INTF_ERROR_NTF(10) disc_flags: 0x1
08-06 12:25:07.944 3273 3434 I BrcmNfcNfa: nfa_dm_disc_sm_execute (): new state: DISCOVERY (1), disc_flags: 0x1
08-06 12:25:07.948 416 3448 D NxpTml : PN54X - Read requested.....
08-06 12:25:07.948 416 3448 D NxpTml : PN54X - Invoking I2C Read.....
08-06 12:25:12.563 416 3448 D NxpTml : PN54X - I2C Read successful.....len = 4
08-06 12:25:12.564 416 3448 D NxpTml : PN54X - Posting read message.....
08-06 12:25:12.564 416 3448 D NxpNciR : len = 4 <= 600701A1
08-06 12:25:12.564 416 3451 D NxpHal : read successful status = 0x0
08-06 12:25:12.565 3273 3434 I BrcmNfcNfa: NFC received ntf gid:0
08-06 12:25:12.565 3273 3434 I BrcmNfcNfa: nci_proc_core_ntf opcode:0x7
08-06 12:25:12.565 3273 3434 I BrcmNfcNfa: nfa_dm_nfc_response_cback () NFC_GEN_ERROR_REVT(0x500d)
08-06 12:25:12.565 3273 3434 I BrcmNfcNfa: nfa_dm_disc_data_cback ()
08-06 12:25:12.565 3273 3434 I BrcmNfcNfa: nfa_dm_disc_sm_execute (): state: DISCOVERY (1), event: INTF_ERROR_NTF(10) disc_flags: 0x1
08-06 12:25:12.565 3273 3434 I BrcmNfcNfa: nfa_dm_disc_sm_execute (): new state: DISCOVERY (1), disc_flags: 0x1

Any idea why? The "NFC reader" that I'm using to read the NFC TAG never actually reads anything.

Also, when I'm trying to transfer a photo through NFC (Android beam), the android NFC service is crashing.

0 Kudos

2,467 Views
jeremygeslin
NXP Employee
NXP Employee

Hi,

It looks like the problem with the never returning function: mHal = INfc::getService(); was that the service vendor.nxp.nxpnfc wasn't actually running. After fixing that issue the NFC looks like it is starting up properly.

How did you fix it to have vendor.nxp.nxpnfc service running ?

0 Kudos

2,467 Views
nikolaos_pasalo
Contributor II

It turns out that the Android NFC Beam was crashing because when you are trying to send an image through NFC it attempts to send the image using a different protocol, like Bluetooth. In my case the Bluetooth was disabled, so when the NFC service was trying to get a reference of the Bluetooth device, the reference was NULL, resulting in a crash.

Everything is fine now.

0 Kudos

2,467 Views
tanuja_gudaje
Contributor I

Hi Nikolaos Pasaloukos,

How did you resolved the never returning mHal=INfc::getService() isuue.

I am also facing same issue.

can you share what is the solution to get it work.

Kind Regards,

Tanuja Gudaje

0 Kudos

2,467 Views
jimmychan
NXP TechSupport
NXP TechSupport

You can download the patch for Android Oreo from here:

NXPNFCLinux · GitHub 

0 Kudos

2,467 Views
nikolaos_pasalo
Contributor II

I've done this already with no success. I think I have solved the problem by commenting the following line under /device/qcom/common/base.mk

#PRODUCT_PROPERTY_OVERRIDES += ro.hardware.nfc_nci=nqx.default

According to the documentation (section 3.1.4) this should have been:

PRODUCT_PROPERTY_OVERRIDES += \ ro.hardware.nfc_nci=pn54x

I will provide more details as soon as I have isolate/finalise only the necessary changes to make it work.

0 Kudos