Open StarGate01 opened 3 weeks ago
For reference, here is a debug log of pcscd while pcsc_scan
is running and trying to scan a NXP P71D321 Javacard. The connection breaks and re-establishes in quick succession. This matches my obervations from linux_libnfc-nci
without the config parameters applied.
connection dropping
At the moment there appears to be a hard-coded timeout of 700 ms for most exchanges with tags. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/net/nfc/nci_core.h#n55 A generous increase leads to better stability. Probably unrelated, but worth a try.
In fact, it is the pcscd
that explicitly powers the card down if not in use. See here.
My handler then reports the tag as removed. The kernel wipes the list of targets when a connection is closed, a new poll is necessary prior to any further activation. I experimented with reporting the card as present even after IFD_POWER_DOWN, but ran into other problems. The current state of the library is not satisfactory, but it was a reasonable first shot.
Once a client actually connects to the tag, the connection stays alive. Try interacting with the tag instead of simply running pcsc_scan
.
I have recompiled the kernel with an NCI_DATA_TIMEOUT
of 5000, KeePassXC seems to have a better time now, but the connection is still unstable / cycling (due to the missing power config I guess).
Commercial NFC-enabled PC/SC readers (eg. the ACR1252U) report the NFC card as inserted all the time when the card is in the RF field, even when no PC/SC client session is active. Some applications, like e.g. KeePassXC and the Yubico Authenticator (OTP) depend on that behavior to properly list connected devices.
I am currently testing this driver together with ATR kernel patch (https://lore.kernel.org/netdev/20241103124525.8392-1-juraj@sarinay.com/) and the built-in NXP chip of my ThinkPad T16G2 (NXP NPC300).
While ATR detection now works, I was unable to get any PC/SC transaction to work with the PKCS#11 driver for my eID card, while using NXP out-of-three kernel modules coupled with @StarGate01 IFD library everything works. (What I tried was to list the stored certificate on Firefox PKCS#11 configuration).
Could the NCI_DATA_TIMEOUT be the issue? I will try soon but at the moment I am a bit hardware and time constrained to run another kernel recompilation
As detailed in https://github.com/nfc-tools/libnfc/issues/455#issuecomment-2221979571 , the NXP chip in my Lenovo Yoga X1 Gen3 needs some additional configuration commands to operate in a stable mode.
Without this configuration, the chip does somewhat work, and also detects tags - but any longer running data transmissions fail due to the connection dropping. I presume this is because of the misconfigured power and firmware parameters.
I tried reaching @krzk via email, to get some pointers on how custom NCI commands could be passed to the chip via the Netlink and nxp-nci systems.