This document describes step-by-step how to run NFC on Raspberry Pi platform.
Hardware setup:
You need:
- Raspberry Pi (any model) : https://www.raspberrypi.org/products/:
- OM5578(PN7150 demokit) in RPi configuration (or OM5577(PN7120 demokit)😞
Then simply assemble boards together, stacking OM5578RPI (or OM5577RPI) to Raspberry Pi expansion connector:
Software setup:
Use Raspbian (https://www.raspberrypi.org/software/operating-systems/) or any other Linux distribution (guidelines to set up Linux environment on raspberry pi: https://www.raspberrypi.org/documentation/installation/installing-images/).
Step by step procedure:
Enable i2c support:
On Raspbian:
Run "sudo raspi-config"
Use the down arrow to select "5 Interfacing Options"
Arrow down to "P5 I2C"
Select "yes" when it asks you to enable I2C
Also select "yes" if it asks about automatically loading the kernel module
Use the right arrow to select the <Finish> button
Select "yes" when it asks to reboot
The system will reboot. when it comes back up, log in and enter the following command "ls /dev/*i2c*".
The Pi should respond with "/dev/i2c-1" which represents the user-mode I2C interface.
Install necessary tools:
On Raspbian execute the command:
sudo apt-get install autoconf automake libtool git
Clone Linux libnfc-nci library repository:
Execute the command:
git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git
Configure the library:
Execute the commands:
cd linux_libnfc-nci
./bootstrap
./configure --enable-alt
Build and install the library:
Execute the commands:
make
sudo make install
export LD_LIBRARY_PATH=/usr/local/lib
Run demo application (built and installed together with the library during previous step):
To simply display all data collected from remote NFC device (Peer, reader/writer or card), run the demo application in poll mode executing the command:
nfcDemoApp poll
For more details about the demo application modes execute command:
nfcDemoApp --help
One step further:
Set environment variable to reference library installation:
Execute command:
export LD_LIBRARY_PATH=/usr/local/lib
You may wan't to make this setting permanent by adding it to your .bashrc file for instance :
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> .bashrc
Write your own application:
Several simple examples demonstrating use of the linux_libnfc-nci library for different use cases (Reader, Peer to peer, Host Card Emulation) are given as reference: https://github.com/NXPNFCLinux/linux_libnfc-nci_examples
- Simply clone the repository
git clone https://github.com/NXPNFCLinux/linux_libnfc-nci_examples.git
- Browse to the targeted example:
cd linux_libnfc-nci_examples/xxx_example
- Build the example:
make
- Run the example
./xxx_example
Additional information:
Another Platform ?
Using UDOO NEO (with OM5577 or OM5578 in Arduino configuration) ?
-> Follow step-by-step procedure, just updating src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h file to set CONFIGURATION flag to value 2, before building the library
Using BeagleBone Black (with OM5577 or OM5578 in BBB configuration) ?
-> Follow step-by-step procedure, just updating src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h file to set CONFIGURATION flag to value 2, before building the library
Using other Linux platform or others OM5578/OM5577 demokits configuration ?
-> Follow step-by-step procedure, just updating src/halimpl/pn54x/tml/i2c/phTmlNfc_alt.h file to set CONFIGURATION flag to value 0 and defining I2C_BUS, PIN_INT and PIN_ENABLE flags according to the HW connection, before building the library
Running Android ?
-> Follow guidelines provided in the related documentation: https://www.nxp.com/docs/en/application-note/AN11690.pdf
查看全文