For the past weeks I have been trying to get the ITEAD PN532 NFC board working on a Raspberry Pi 3 running Raspbian Jessie (2016-03-18) using libnfc
.
Here's some info on the board itself. It has two switches to set the mode between UART, SPI or IIC.
Before we start, here's my lsmod
for reference.
In short, Serial disabled, SPI and I2C enabled with kernel modules loaded.
brcmfmac 177635 0 joydev 9024 0 brcmutil 5501 1 brcmfmac cfg80211 407580 1 brcmfmac evdev 10278 4 rfkill 16036 2 cfg80211 i2c_bcm2708 4920 0 bcm2835_gpiomem 2860 0 bcm2835_rng 1763 0 snd_bcm2835 19802 3 spi_bcm2835 7074 0 snd_pcm 73474 1 snd_bcm2835 snd_timer 18848 1 snd_pcm snd 50779 9 snd_bcm2835,snd_timer,snd_pcm uio_pdrv_genirq 2944 0 uio 7753 1 uio_pdrv_genirq i2c_dev 5671 0 fuse 80694 3 ipv6 338660 32
This is what's uncommented in /boot/config.txt
disable_overscan=1 # Uncomment some or all of these to enable the optional hardware interfaces dtparam=i2c=on dtparam=i2c_arm=on dtparam=spi=on dtparam=audio=on dtoverlay=pi3-miniuart-bt
Here's what I've tried:
I2C (device tree disabled)
Considered a REALLY BAD IDEA but I did get the board working via I2C. Was advised against it and to pursue device tree enabled solution, so all following attempts have DT enabled again.UART
- SET0 L / SET1 L
/etc/nfc/libnfc.conf
allow_autoscan = true allow_intrusive_scan = false device.name = "ITEAD PN532" device.connstring = "pn532_uart:/dev/serial0"
but also
allow_autoscan = true allow_intrusive_scan = false device.name = "ITEAD PN532" device.connstring = "pn532_uart:/dev/ttyS0"
Result:
~$ nfc-list
nfc-list uses libnfc 1.7.1
error libnfc.driver.pn532_uart
pn53x_check_communication
error nfc-list: ERROR: Unable to open NFC device: pn532_uart:/dev/serial0
I also tried with and without the dtoverlay=pi3-miniuart-bt
, this seems to do nothing.
- I2C
- SET0 H / SET1 L
/etc/nfc/libnfc.conf
allow_autoscan = true allow_intrusive_scan = false device.name = "ITEAD PN532" device.connstring = "pn532_i2c:/dev/i2c-1"
Result:
~$ nfc-list
nfc-list uses libnfc 1.7.1
error libnfc.bus.i2c Error: wrote only -1 bytes (10 expected).
error libnfc.driver.pn532_i2c Unable to transmit data. (TX) pn53x_check_communication: Input / Output Error
error libnfc.bus.i2c Error: wrote only -1 bytes (10 expected).
error libnfc.driver.pn532_i2c Unable to transmit data. (TX) nfc-list: ERROR: Unable to open NFC device: pn532_i2c:/dev/i2c-1
i2cdetect -y 1
result is empty.
- SPI
- SET0 L / SET1 H
/etc/nfc/libnfc.conf
allow_autoscan = true allow_intrusive_scan = false device.name = "ITEAD PN532" device.connstring = "pn532_uart:/dev/spidev0.0:500000"
Result:
~ $ nfc-list
nfc-list uses libnfc 1.7.1
error libnfc.driver.pn532_spi Unable to wait for SPI data. (RX)
pn53x_check_communication: Timeout
error libnfc.driver.pn532_spi Unable to wait for SPI data. (RX)
nfc-list: ERROR: Unable to open NFC device: pn532_spi:/dev/spidev0.0:500000
I've followed whatever I found in terms of wiring schemes for UART, SPI and I2C in whatever limited, disparate and usually downright wrong information I could puzzle together online but it's possible that I've incorrectly wired the device at some point using the individual jumper wires. That's why I've tried all of the above with a downgrade GPIO flat cable as well but that didn't make a difference.
And with that, I'm at the end of my wits.
getty
running on/dev/ttyS0
. This would not explain, of course, why you can't get the board running under SPI. You haven't explained why you need to disable the device tree to use I2C. My I2C devices work just fine with DT enabled!