2

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.

4
  • Make sure you don't have 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!
    – JayEye
    Commented Apr 22, 2016 at 16:01
  • Did you follow this exactly?
    – not2qubit
    Commented Apr 22, 2016 at 16:08
  • If I knew why I can only get the board to work with DT disabled, I would probably be able to figure out how to make it work with DT enabled as well. Commented Apr 25, 2016 at 5:47
  • @user1147688 yes I did and there are several reasons why this can't be followed to the letter for a Pi 3 and/or Raspbian Jessie. First of all, there's no more /etc/modprobe.d/raspi-blacklist.conf and the spi-bcm2708 has been replaced with another version. Second, the old Pi 1 didn't have a device tree. Commented Apr 25, 2016 at 5:52

2 Answers 2

7

I have found a solution although I take no credit for it:

"Turns out the Raspberry Pi 3 uses the first serial port for its integrated Bluetooth! There are several ways to get around the problem, knowing this. For now and for my purposes, simply disabling bluetooth did the trick: add

dtoverlay=pi3-disable-bt
to /boot/config.txt and then sudo systemctl disable hciuart to disable to the bluetooth service.
Reboot and NFC through /dev/ttyAMA0 works again!
"

Original link here.

This works flawlessly.

2
  • Another update to this: I was unable to get this working at all using serial or i2c, but was able to get it working with SPI but had to turn down the frequency. 500khz doesn't work, but 280khz does (so device.connstring = "pn532_uart:/dev/spidev0.0:280000")
    – Karl
    Commented Jun 18, 2017 at 6:12
  • I have the same problem as this question but dtoverlay is already set to mentiioned value. I tried UART, SPI , I2C but none of them worked... Have you any idea? thanks
    – Saleh
    Commented Feb 7, 2020 at 22:04
1

I noticed that I have a similar question to yours and I solved mine by looking at this information here: Serial port in RPI 3

It is now referenced as ttyS0. I can test my program to run fine when I change my device reference from ttyAMA0 to ttyS0. Hope this helps

2
  • Thanks for the tip, I hadn't come across this yet so I'll be sure to try it tonight! Commented Apr 11, 2016 at 4:34
  • No joy. Tried this, tried the overlay to disable bt, no response over UART, it doesn't even see an NFC device. I am using the ITEAD PN521 though, not the AdaFruit board. Thanks anyway. The quest continues... Commented Apr 12, 2016 at 5:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.