Fix NFC for htc m7 under Cyanogenmod 13

Init

After upgrading my HTC m7 to Cyanogenmod 13 I discovered that NFC was not working. The NFC icon was touchable but nothing happened! I started to debug a little bit around. Here are my findings.

NFC initiation under Cyanogenmod 12.1

Under Cyanogenmod 12.1 NFC initiation looks like this. The NFC process is searching for some firmware but can’t find them and continues with old NFC firmware.

tuxinaut@sm191:~$ adb logcat | grep -Ei "NFCJNI|firmware"
D/NFCJNI  ( 2647): Start Initialization
E/NFC-HCI ( 2647): Could not open /vendor/firmware/libpn544_fw.so or /system/lib/libpn544_fw.so
W/NFC     ( 2647): Firmware image not available: this device might be running old NFC firmware!
D/NFCJNI  ( 2647): NFC capabilities: HAL = 8150100, FW = b10122, HW = 620003, Model = 11, HCI = 1, Full_FW = 1, Rev = 34, FW Update Info = 0
...
...
I/NFCJNI  ( 2647): NFC Initialized

NFC initiation under Cyanogenmod 13

Under Cyanogenmod 13 NFC initiation looks like this. No missing firmware but some errors which cause NFC to not working.

tuxinaut@sm191:~$ adb logcat | grep -Ei "NFCJNI|firmware"
01-01 12:36:55.497  2721  2721 I NFCJNI  : NFC Service: loading nxp JNI
01-01 12:36:55.911  2721  2945 D NfcService: checking on firmware download
01-01 12:36:55.938  2721  2945 D NFCJNI  : Start Initialization
01-01 12:36:56.194  2721  2945 D NFCJNI  : NFC capabilities: HAL = 8150100, FW = b10122, HW = 620003, Model = 11, HCI = 1, Full_FW = 1, Rev = 34, FW Update Info = 249
01-01 12:36:56.392  2721  2945 D NFCJNI  : Download new Firmware
01-01 12:36:57.441  2721  2945 W NFCJNI  : Firmware update FAILED
01-01 12:36:57.631  2721  2945 D NFCJNI  : Download new Firmware
01-01 12:36:58.681  2721  2945 W NFCJNI  : Firmware update FAILED
01-01 12:36:58.871  2721  2945 D NFCJNI  : Download new Firmware
01-01 12:36:59.921  2721  2945 W NFCJNI  : Firmware update FAILED
01-01 12:36:59.921  2721  2945 E NFCJNI  : Unable to update firmware, giving up
01-01 12:36:59.971  2721  2945 D NFCJNI  : Terminating client thread...

Solution

After comparing the logcat outputs I searched for mentioned firmware file (libpn544_fw.so) and found the file under Cyanogenmod 13. So I removed this file and bingo NFC works.

On the mobile phone

  • Enable Developer settings. Touch multiple times on the Build number (under Settings)
  • Under Developer options
    • Enable root access for Apps and ADB
    • Enable Android debugging

On the computer

Install adb (under Ubuntu the package name android-tools-adb)

sudo apt-get install android-tools-adb

Open an adb shell

adb shell

Execute following commands in the adb shell

# Become root
su

# Make system filesystem writeable
mount -o rw,remount /system

# Remove the firmware file
rm -f /system/vendor/lib/libpn544_fw.so
rm -f /system/vendor/firmware/libpn544_fw.so

After this restart the device. After the restart NFC works as expected.

Update 2016-12-22

After updating to the last nightly I found out that you also must remove /system/vendor/firmware/libpn544_fw.so (Or they moved the file I was to fast with removing)

Categories: cyanogenmod fix
Tags: cyanogenmod htc nfc