NFC
Near-field communication (NFC) can be used for contactless exchange of data over short distances. Different approaches exist on Linux to support it:
- libnfc: userspace implementation, but mostly for desktop (e.g. USB) readers
- Android NFC HAL: doesn't really work outside Android, probably mostly proprietary implementations
- Linux NFC subsystem: NFC abstraction in the (mainline) Linux kernel with support for many different (also embedded) NFC chips
For smartphones/embedded devices the Linux NFC subsystem is the most suitable one, because it can be set up normally in the device tree like other hardware. Unfortunately, the NFC subsystem has been somewhat unmaintained for quite some time, and especially the userspace portion of it: Neard.
Note that there is support for NFC/Neard in Qt if you want to build an application that makes use of NFC yourself.
Devices with NFC support
If your device runs the mainline kernel, and has a NFC chip that is supported in mainline's Linux NFC subsystem it should be fairly easy to add it to the device tree. Check the available NFC device tree bindings for details. Otherwise, these devices in postmarketOS already support NFC to some extent:
Device | Codename | Category | Status |
---|---|---|---|
Xiaomi Redmi Note 10 Pro | xiaomi-sweet | Y | |
Google Pixel 3a | google-sargo | community | P |
Google (ASUS) Nexus 7 (2012) | asus-grouper | community | Y |
Google (ASUS) Nexus 7 (2012) GSM | asus-tilapia | community | Y |
LG Optimus Vu | lg-p895 | community | Y |
OnePlus 6 | oneplus-enchilada | community | P |
OnePlus 6T | oneplus-fajita | community | P |
Qualcomm Snapdragon 625 | qcom-msm8953 | community | P |
Samsung Galaxy A3 (2015) | samsung-a3 | community | Y |
Samsung Galaxy A5 | samsung-a5 | community | Y |
Samsung Galaxy E7 | samsung-e7 | community | Y |
Xiaomi Mi Note 2 | xiaomi-scorpio | community | Y |
BQ Aquaris X / Aquaris X Pro | bq-bardock / bq-bardockpro | testing | Y |
Fairphone 3 | fairphone-fp3 | testing | Y |
Google Pixel 3a XL | google-bonito | testing | P |
Huawei Ascend G7 | huawei-g7 | testing | Y |
Microsoft Lumia 640 | microsoft-dempsey | testing | Y |
Nokia Lumia 630 | nokia-moneypenny | testing | Y |
Nokia Lumia 730 | nokia-superman | testing | Y |
Nokia Lumia 830 | nokia-tesla | testing | Y |
Nothing Phone 1 | nothing-spacewar | testing | Y |
OLIMEX Teres-I | teres_i | testing | Y |
OnePlus 3T | oneplus-oneplus3t | testing | Y |
OnePlus 5 | oneplus-cheeseburger | testing | Y |
OnePlus 5T | oneplus-dumpling | testing | Y |
OnePlus 8 Pro | oneplus-instantnoodlep | testing | Y |
Qualcomm Snapdragon 410 | qcom-msm8916 | testing | P |
Samsung Galaxy A7 (2015) | samsung-a7 | testing | Y |
Samsung Galaxy Ace 2 GT-I8160 | samsung-codina | testing | Y |
Samsung Galaxy Ace 4 | samsung-heatqlte | testing | Y |
Samsung Galaxy Core Prime LTE | samsung-rossa | testing | Y |
Samsung Galaxy Grand Prime (SM-G530W) | samsung-fortuna, samsung-gprimeltecan | testing | Y |
Samsung Galaxy Grand Prime (SM-G530Y) | samsung-fortunaltezt | testing | Y |
Samsung Galaxy S Advance | samsung-janice | testing | Y |
Volla Phone 22 | volla-mimameid | testing | P |
Xiaomi Mi 11 Lite 4G | xiaomi-courbet | testing | Y |
Xiaomi Mi 5 | xiaomi-gemini | testing | Y |
Xiaomi Mi 5s Plus | xiaomi-natrium | testing | Y |
Xiaomi Mi 6 | xiaomi-sagit | testing | Y |
Xiaomi Mi 9T / Redmi K20 | xiaomi-davinci | testing | P |
Xiaomi Mi Note 10 / Mi CC9 Pro | xiaomi-tucana | testing | Y |
Xiaomi Mi Note 10 Lite | xiaomi-toco | testing | Y |
Xiaomi POCO X3 NFC | xiaomi-surya | testing | Y |
Xiaomi Redmi Note 12 Pro (4G) | xiaomi-sweet_k6a | testing | Y |
Applications that require NFC to work properly
Application name | Toolkit | License | Short Description | Note |
---|---|---|---|---|
AusweisApp | Qt | EUPL-1.2 | Official eID client in Germany for EU eIDAS | 🚩 This app needs to be installed from a third-party Flatpak repository. de.bund.ausweisapp.ausweisapp2 |
eSzemélyi Kliens | Qt | Proprietary | Official eID client in Hungary | 🚩 This app is x86 & x86_64 only and needs to be installed from a third-party site and currently is only in .deb and .rpm packages. |
Thales (formerly Gemalto) SConnect | - | Proprietary | Browser Plug-In for official Swedish and Belgian eID web applications | 🚩 This app is x86 & x86_64 only and needs to be installed from a third-party site and currently is only in tar.gz package. |
Digital identity and trust infrastructure (Switzerland) | - | MIT | Official Swiss eID pilot program | 🚩 This is still a pilot program, and at the moment this requires Waydroid, but the law mandates open source and so far more or less everything is on GitHub, so there is hope for improvements. |
Applications that can use NFC, but NFC is not strictly required
Application name | Toolkit | License | Short Description | Note |
---|---|---|---|---|
Yubico Authenticator | Flutter | Apache-2.0 | Open source authenticator app for Yubico's own hardware security products. | 🚩 NFC support for Linux is in Yubico/libfido2 and is still considered experimental. This app needs to be installed from a third-party Flatpak repository. com.yubico.yubioath |
Testing
As a basic test, you can use nfctool
(from apk add neard
) to poll for devices:
$ nfctool -d nfc0 -1 -p
nfc0:
Tags: [ ]
Devices: [ ]
Protocols: [ Felica MIFARE Jewel ISO-DEP ISO-15693 ]
Powered: Yes
RF Mode: None
lto: 0
rw: 0
miux: 0
Start polling on nfc0 as initiator
Targets found for nfc0
Tags: [ tag0 ]
Devices: [ ]
If you hold some other NFC-capable device close to the NFC antenna, it should find a NFC tag and show it. Many chip cards nowadays have NFC, or maybe you can use another smartphone.
Note: You may need to search for a while to find a working spot on the phone close to the NFC antenna. It could be anywhere on the back or anywhere on the front so just search for a bit before you give up. |
Reading NFC tags
For advanced usage you should start the Neard daemon (rc-service neard start
). Neard then provides a DBUS API similar to BlueZ for Bluetooth that allows reading/writing NFC tags for example.
The easiest way to test it is using the Neard test scripts, for example with test-adapter
and test-tag
.
Upstream is looking for potential maintainers and testers of the Linux NFC subsystem, so if you would like to help, consider posting on the linux-nfc mailing list.