[T-Mobile Galaxy Note 4 Android Development] fattire:
Some thoughts on NFC.

Since there are now a multitude of roms, none of which support nfc because we don't yet, here's why it's not working so far. I put this here for others to look at as well as for future reference for myself. I'll update this w/corrections because I'm sure it's not 100% right yet.

So the Note 4 uses a brand-new 45nm chip, the S3FWRN5, which so far hasn't appeared on any other devices. We don't have source code for the HAL (the hardware abstraction layer, used to connect the kernel support with the android side of things), though stock does provide a file called /system/lib/hw/nfc_nci.apk8084.so (the binary HAL)

When building w/NFC, you need to do a few things. First, in trlte.mk, you need to turn on a few NFC packages. Here are some I've tried.

PRODUCT_PACKAGES += \

com.android.nfc_extras \

libnfc-sec \

NfcNci \

Tag \

nfclib \

nfc_nci.apq8084 \

nfc_nci.bcm2079x.default \

bcm2079x.apq8084 \

libnfc-nci

(note that some of the above don't do anything or are not for our hardware. We won't ever need them all... I'm including them for reference. In other words, it's a more complete list of stuff to try if you are experimenting...)

Then there's the libnfc configuration files. Note that libnfc-brcm is duplicated from libnfc-sec.conf. This is because of hardcoding of that file name in the lollipop source (which was changed for the Note 4's chip by Samsung apprently to libnfc-sec)

PRODUCT_COPY_FILES += \

$(LOCAL_PATH)/configs/libnfc-sec.conf:system/etc/libnfc-sec.conf \

$(LOCAL_PATH)/configs/libnfc-sec.conf:system/etc/libnfc-brcm.conf \

$(LOCAL_PATH)/configs/libnfc-sec-hal.conf:system/etc/libnfc-sec-hal.conf \

$(LOCAL_PATH)/configs/nfcee_access.xml:system/etc/nfcee_access.xml

There's more. In configs/libnfc-sec.conf, you can instruct libnfc which hal to load by adding a line like:

NCI_HAL_MODULE="nfc_nci.apq8084"

or

NCI_HAL_MODULE="nfc_nci.bcm2079x.apq8084"

That's the wrong HAL, bu tI thought maybe at least it would think it loaded... but nothing I've tried got the HAL to load successfully. I always get a:

D/NfcAdaptation( 4765): const CNfcParam* CNfcConfig::find(const char*) const found NCI_HAL_MODULE=nfc_nci.pn54x.apq8084

E/NfcAdaptation( 4765): NfcAdaptation::InitializeHalDeviceContext: fail hw_get_module nfc_nci.pn54x.apq8

(replace that module name with the various ones I've tried...) Also you can specify the HAL suffix in BoardConfigCommon.mk with:

BOARD_NFC_HAL_SUFFIX := apq8084

Things that have been tried:

1. all stock binaries (HAL, nfclib, etc.)

2. all built binaries except for HAL... (and renaming stock hal to bcm2079x.apq8084 doesn't load either)

3. All built binaries

4. Various combos of the above.

The current theory is we need (A) some kind of wrapper to pass through to the stock HAL, or (B) wait for a new 5.0 stock HAL to show up from Samsung or (C) wait for some documentation/source to show up for the unique NFC chip as other devices start to use it.

I'd expect the code for our chip would probably go in external/libnfc-nci/halimpl

NFC doesn't work on any of the Notes in CM12 yet as far as I know... hopefully someone out there might have some insight.

Any other thoughts, anyone?