[Huawei P20 Pro ROMs, Kernels, Recoveries, & Other ] _unknown:
NFC not working: analysis

I've been looking at the NFC issues a bit more, and have some extra information. No solution yet, it does not look like there is a simple fix for this issue, but maybe someone who knows how Huawei works with vendor-specific code and/or it's NFC implementation will be able to chime in based on these details.

With some help from Luk1337 I managed to compile my own LineageOS build. I've summarized the setup as follows (for an Ubuntu 16.04):

mkdir -p ~/bin
wget 'https://storage.googleapis.com/git-repo-downloads/repo' -P ~/bin
chmod +x ~/bin/repo
apt-get update
apt-get install openjdk-8-jdk android-tools-adb bc bison build-essential curl flex g++-multilib gcc-multilib gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libssl-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc yasm zip zlib1g-dev ccache

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.profile
echo 'export USE_CCACHE=1' >> ~/.profile
echo 'export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx6G"' >> ~/.profile
source ~/.profile

mkdir -p ~/android/lineage
cd ~/android/lineage
repo init -u https://github.com/LineageOS/android.git -b lineage-15.1

cat <<EOF > .repo/local_manifests/roomservice22.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="berkeley-dev/android_patcher" path="patcher" remote="github" />
<project name="berkeley-dev/android_device_huawei_kirin970-common" path="device/huawei/kirin970-common" remote="github" />
<project name="berkeley-dev/android_device_huawei_berkeley" path="device/huawei/berkeley" remote="github" />
<project name="berkeley-dev/android_device_huawei_charlotte" path="device/huawei/charlotte" remote="github" />
<project name="berkeley-dev/proprietary_vendor_huawei_kirin970-common" path="vendor/huawei/kirin970-common" remote="github" />
</manifest>
EOF

repo sync
. build/envsetup.sh
repopick 207583 214316
repopick -t long-screen-per-app

./patcher/patch.sh

brunch charlotte

Note that this build takes a long time and requires significant resources. In the end, you get a lineage zip-file in android/lineage/out/target/product/charlotte that you can flash.

This build should be mostly identical to the builds available here, so there are no modifications yet. This is just the baseline setup.

In order to try and fix the NFC issues, I included the following files in vendor/huawei/kirin970-common/kirin970-common-vendor.mk:

vendor/huawei/kirin970-common/nfc/lib64/vendor.huawei.hardware.nfc@1.0.so:system/lib64/vendor.huawei.hardware.nfc@1.0.so \
vendor/huawei/kirin970-common/nfc/lib64/hw/nfc_nci.pn54x.default.so:system/lib64/hw/nfc_nci.pn54x.default.so \
vendor/huawei/kirin970-common/nfc/lib64/hw/nfc_nci.cxd22xx.default.so:system/lib64/hw/nfc_nci.cxd22xx.default.so \
vendor/huawei/kirin970-common/nfc/lib64/hw/vendor.huawei.hardware.nfc@1.0-impl.so:system/lib64/hw/vendor.huawei.hardware.nfc@1.0-impl.so \
vendor/huawei/kirin970-common/nfc/lib64/hw/nfc_nci.pn54x_45_553.default.so:system/lib64/hw/nfc_nci.pn54x_45_553.default.so \
vendor/huawei/kirin970-common/nfc/lib64/hw/nfc_nci.pn54x_45_551.default.so:system/lib64/hw/nfc_nci.pn54x_45_551.default.so \
vendor/huawei/kirin970-common/nfc/lib/vendor.huawei.hardware.nfc@1.0.so:system/lib/vendor.huawei.hardware.nfc@1.0.so \
vendor/huawei/kirin970-common/nfc/lib/hw/nfc_nci.pn54x.default.so:system/lib/hw/nfc_nci.pn54x.default.so \
vendor/huawei/kirin970-common/nfc/lib/hw/nfc_nci.cxd22xx.default.so:system/lib/hw/nfc_nci.cxd22xx.default.so \
vendor/huawei/kirin970-common/nfc/bin/hw/vendor.huawei.hardware.nfc@1.0-service:system/bin/hw/vendor.huawei.hardware.nfc@1.0-service \
vendor/huawei/kirin970-common/nfc/bin/nfcgetcplc:system/bin/nfcgetcplc \
vendor/huawei/kirin970-common/nfc/etc/init/vendor.huawei.hardware.nfc@1.0-service.rc:system/etc/init/vendor.huawei.hardware.nfc@1.0-service.rc

Actual files in attachment nfc-huawei.tar.gz

Rebuilding LineageOS with these included, NFC still does not work, but from an adb shell the following commands may be interesting:

HWCLT:/ # /system/bin/hw/vendor.huawei.hardware.nfc@1.0-service
HWCLT:/ # ps -ef | grep nfc
nfc 7413 528 0 23:41:09 ? 00:00:00 com.android.nfc
nfc 7494 1 0 23:41:11 ? 00:00:00 vendor.huawei.hardware.nfc@1.0-service
root 7960 7769 0 23:43:05 pts/1 00:00:00 grep nfc
HWCLT:/system/bin # ./nfcgetcplc
DH--->NFCC#20000100
NFCC--->DH#400003001100
DH--->NFCC#200100
NFCC--->DH#40011900031E030008000102038081828302D002FF0200049810050A
DH--->NFCC#2F0200
NFCC--->DH#4F0205000000D8E3
DH--->NFCC#2F000100
NFCC--->DH#4F000100
DH--->NFCC#20020D03A0EC0100A0ED0101A0120102
NFCC--->DH#4002020000
DH--->NFCC#22000101
NFCC--->DH#4200020001
NFCC--->DH#6200050100010100
DH--->NFCC#200406030101020101
NFCC--->DH#40040400FF0103
DH--->NFCC#2201020101
NFCC--->DH#42010100
DH--->NFCC#0300028103
NFCC--->DH#600603010301
NFCC--->DH#0300028180
DH--->NFCC#030003810204
NFCC--->DH#600603010301
NFCC--->DH#030003818000
DH--->NFCC#030004810103C0
NFCC--->DH#600603010301
NFCC--->DH#0300028180
DH--->NFCC#030003990201
NFCC--->DH#600603010301
DH--->NFCC#03000F995000A4040008A000000151000000
NFCC--->DH#600603010301
DH--->NFCC#030007995080CA9F7F00
NFCC--->DH#600603010301
DH--->NFCC#0300029961
DH--->NFCC#20030301A0F0
NFCC--->DH#600603010301
NFCC--->DH#40034A0001A0F04502020408B440ED0000000000002001000000000000000000000000000000000070010100000100FF000000000000000000E400000000000000000000000000000000030300
DH--->NFCC#2201020100
NFCC--->DH#42010100
NFCC--->DH#6200050101010100
DH--->NFCC#220102C000
NFCC--->DH#42010100
DH--->NFCC#2F000101
NFCC--->DH#4F000100
DH--->NFCC#20020501A0EC0101
NFCC--->DH#4002020000
mv: bad '/data/nfc/nfccplc_tmp': No such file or directory
HWCLT:/system/bin #
HWCLT:/system/bin # mkdir /data/nfc/nfccplc_tmp
HWCLT:/system/bin # ./nfcgetcplc
DH--->NFCC#20000100
NFCC--->DH#400003001100
DH--->NFCC#200100
NFCC--->DH#40011900031E030008000102038081828302D002FF0200049810050A
DH--->NFCC#2F0200
NFCC--->DH#4F0205000000D8E3
DH--->NFCC#2F000100
NFCC--->DH#4F000100
DH--->NFCC#20020D03A0EC0100A0ED0101A0120102
NFCC--->DH#4002020000
DH--->NFCC#22000101
NFCC--->DH#4200020001
NFCC--->DH#6200050101010100
DH--->NFCC#200406030101020101
NFCC--->DH#40040400FF0103
DH--->NFCC#2201020101
NFCC--->DH#42010100
NFCC--->DH#620005C002018000
DH--->NFCC#0300028103
NFCC--->DH#600603010301
NFCC--->DH#0300028180
DH--->NFCC#030003810204
NFCC--->DH#600603010301
NFCC--->DH#030003818000
DH--->NFCC#030004810103C0
NFCC--->DH#600603010301
NFCC--->DH#0300028180
DH--->NFCC#030003990201
DH--->NFCC#03000F995000A4040008A000000151000000
NFCC--->DH#600603010301
NFCC--->DH#600603010301
DH--->NFCC#030007995080CA9F7F00
NFCC--->DH#600603010301
DH--->NFCC#0300029961
DH--->NFCC#20030301A0F0
NFCC--->DH#600603010301
NFCC--->DH#40034A0001A0F04502020408B440ED0000000000002001000000000000000000000000000000000070010100000100FF000000000000000000E400000000000000000000000000000000030300
DH--->NFCC#2201020100
NFCC--->DH#42010100
NFCC--->DH#6200050101010100
DH--->NFCC#220102C000
NFCC--->DH#42010100
DH--->NFCC#2F000101
NFCC--->DH#4F000100
DH--->NFCC#20020501A0EC0101
NFCC--->DH#4002020000
HWCLT:/system/bin #

Meanwhile in logcat:

https://pastebin.com/avyvVcfv

Toggling NFC with this setup results in the following logcat:

https://pastebin.com/Emf0xAdW

Somewhat interesting tidbit in the nfcgetcplc logcat is:

06-08 10:11:50.901 23573 23573 D : nfcservice_unlock NFC write /sys/nfc/nfcservice_lock success!

No idea what this binary is for or how it is used in the original ROM. It seems to work somewhat at least, but no actual improvement in NFC functionality (no tags detected).