Skip to content

Latest commit

 

History

History
188 lines (130 loc) · 3.9 KB

File metadata and controls

188 lines (130 loc) · 3.9 KB

libnfc-openwrt

OpenWrt package for libnfc library, enabling NFC (Near Field Communication) functionality on OpenWrt systems.

Overview

This project provides build configuration for the libnfc library and related tools for OpenWrt. libnfc is an open source, cross-platform, low-level NFC SDK and programming API that supports various NFC devices and tag operations.

Features

  • libnfc 1.8.0 - Core NFC library
  • Multiple driver support:
    • PN532 UART
    • PN532 SPI
    • PN532 I2C
  • Supported tag types:
    • MIFARE Classic
    • MIFARE Ultralight
    • Jewel Topaz
    • NFC Forum Tag Type 3/4
  • Comprehensive utility toolset

Packages

1. libnfc

Core library package providing basic NFC operations.

Features:

  • Manipulate Jewel Topaz tags
  • Manipulate MIFARE Classic and Ultralight tags
  • Low-level NFC communication interface

2. nfc-utils

Collection of NFC utility tools.

Included tools:

  • nfc-emulate-forum-tag4 - Emulates NFC Forum Tag Type 4 v2.0 (or v1.0)
  • nfc-jewel - Jewel tag dump/restore tool
  • nfc-list - Lists the first target present of each founded device
  • nfc-mfclassic - MIFARE Classic manipulation example
  • nfc-mfultralight - MIFARE Ultralight dump/restore tool
  • nfc-read-forum-tag3 - Extract NDEF Message from NFC Forum Tag Type 3
  • nfc-relay-picc - Relay example using two PN532 devices
  • nfc-scan-device - Lists each available NFC device

3. nfc-exp

Onion NFC/RFID Expansion Applications.

Building

Place this project in the package directory of your OpenWrt SDK:

cd /path/to/openwrt-sdk/package
git clone <repository-url> libnfc-openwrt

Configure build options:

make menuconfig

Navigate to:

  • Libraries -> libnfc
  • Utilities -> nfc-utils
  • Onion -> Utilities -> nfc-exp (optional)

Build the package:

make package/libnfc-openwrt/compile V=s

Configuration

After installation, the configuration file is located at /etc/nfc/libnfc.conf.

Default Configuration Example

allow_autoscan = true
allow_intrusive_scan = false
log_level = 1
device.name = "PN532 via CH341"
device.connstring = "pn532_uart:/dev/ttyUSB7"

Configuration Options

  • allow_autoscan - Enable automatic device scanning
  • allow_intrusive_scan - Enable intrusive scanning
  • log_level - Log level (0-3)
  • device.name - Device name
  • device.connstring - Device connection string

Common Connection String Formats

  • UART: pn532_uart:/dev/ttyUSB0
  • SPI: pn532_spi:/dev/spidev0.0
  • I2C: pn532_i2c:/dev/i2c-1

Usage Examples

Scan for NFC Devices

nfc-scan-device

List Tags

nfc-list

Read MIFARE Classic Card

nfc-mfclassic r a dump.mfd

Write MIFARE Classic Card

nfc-mfclassic w a dump.mfd

Read MIFARE Ultralight Card

nfc-mfultralight r dump.mfd

Hardware Support

This package supports NFC modules based on the PN532 chip, connected via:

  • UART (Serial)
  • SPI
  • I2C

Compatible hardware includes:

  • PN532 NFC modules
  • PN532 modules connected via CH341 USB-to-serial adapter

License

  • libnfc: LGPL-2.1
  • OpenWrt Package: GPL-2.0

Maintainer

Sebastian Wendel packages@sourceindex.de

Related Links

Troubleshooting

Device Not Found

  1. Verify the device is properly connected
  2. Confirm the device node exists (e.g., /dev/ttyUSB0)
  3. Check if the connection string in libnfc.conf is correct
  4. Try running nfc-scan-device -v for verbose output

Permission Issues

Ensure the user running NFC tools has permission to access the device node:

chmod 666 /dev/ttyUSB0

Debug Logging

Modify log_level to 3 in the configuration file for detailed logs:

log_level = 3

Contributing

Issues and Pull Requests are welcome!