Topic: Open Source PN532 HW

I just sent off for a first batch of PN532 breakout boards that I'll publish under an open-source license -- PN532 + an integrated antenna and all the main pins broken out to 0.1" headers -- and while the range can be improved with a bit of tuning, they work well with libnfc and the pn532_uart drivers.

I'm also interested in making a stand-alone board with an ARM MCU, and was thinking about the LPC1343 (as Roel is aware, who has helped a lot with the SW) because I'm already very familiar with this chip, and it's both cheap and supports USB.  I was thinking about making two different firmware versions, one that is simply a PN532 UART to USB CDC bridge with no real intermediary logic ... basically no better than a breakout board, but USB-powered rather than having to use an FTDI adapter, etc.  The second firmware could actually drive the PN532 chip itself and communicate with a PC via USB HID, for example, and work independantly of a PC (a LIPO cell and charger can be added to the board for about 2-3€ extra).

I already have written all the non-NFC code required, including drivers to read/write to SD cards (FAT32), bitmap (128x64 pixel  monochrome) and TFT (240x320 pixel 65K color) LCDs, etc., but it would help to know what people might be interested in with a stand-alone board?  The LPC1343 has limited storage (32KB flash, 8kb SRAM), and compiling with USBHID, UART and core peripheral drivers takes 4.2KB leaving ~28KB for user code.  Compiling with USB CDC (for easy 'printf' debugging) takes ~9.0K leaving 23KB for user code.  It's not a problem to move to a larger chip like the LPC1754 (128KB flash), but the 1343 has a really easy to use rom-based USB bootloader that makes it painless to update the firmware and hard to brick, as well as being very cost effective ($2 for a 72MHz ARM Cortex M3 MCU).

Would 20KB be enough to implement most of the core functionality of libnfc on an embedded non-Linux device, keeping in mind that you'll need to work around any 3rd part library dependencies?  libusb is a non-issue since the PN532 is using UART (though if someone adds SPI or I2C in libnfc I can use that as well), but I recall libnfc having some other dependencies.

If some of you can provide a list of some features that you'd consider mandatory, it would help to keep them in mind as I start working on the combined PN532 + ARM board.  Mostly, though, I'm curious if it's realistic to build a version of libnfc for an embedded device in <20KB, and what level of interest there is in the HW.

The breakout boards in any case should be here in two weeks time, and if everything is OK I'll publish the files and probably make a small batch of them available just to recover some of the costs involved developping them.  If the LP1343 is acceptable, I can make a board in a few weeks since I already have a number of proven designs for the 1343 and cheaper (non-USB) LPC1114 ... but it would help to know if 20-25KB is enough for an embedded/ARM version of libnfc (as an estimate).

Last edited by ktownsend (2010-12-21 15:41:23)

Re: Open Source PN532 HW

Hello,

ktownsend wrote:

I just sent off for a first batch of PN532 breakout boards that I'll publish under an open-source license -- PN532 + an integrated antenna and all the main pins broken out to 0.1" headers -- and while the range can be improved with a bit of tuning, they work well with libnfc and the pn532_uart drivers.

I'm really happy to ear about an open hardware !
BTW, it could be really interesting if this OEM reader have a chooseable output bus, I mean PN532 can be connected to I2C, SPI or UART its better if user can use one hardware for multiple purpose.

ktownsend wrote:

I'm also interested in making a stand-alone board with an ARM MCU, and was thinking about the LPC1343 (as Roel is aware, who has helped a lot with the SW) because I'm already very familiar with this chip, and it's both cheap and supports USB.

I'm not really interesting in stand-alone board with ARM but more in a reader with embedded ARM... which is exactly the same hardware smile

ktownsend wrote:

I was thinking about making two different firmware versions, one that is simply a PN532 UART to USB CDC bridge with no real intermediary logic ... basically no better than a breakout board, but USB-powered rather than having to use an FTDI adapter, etc.  The second firmware could actually drive the PN532 chip itself and communicate with a PC via USB HID, for example, and work independantly of a PC (a LIPO cell and charger can be added to the board for about 2-3€ extra).

I'm agree with you. IMHO, you should add at least one UICC socket to be able to add a custom secured access module.

ktownsend wrote:

I already have written all the non-NFC code required, including drivers to read/write to SD cards (FAT32), bitmap (128x64 pixel  monochrome) and TFT (240x320 pixel 65K color) LCDs, etc., but it would help to know what people might be interested in with a stand-alone board?

I'm interesting in this project but also in a light version without LCD, SD card, etc. but UICC socket.

ktownsend wrote:

Would 20KB be enough to implement most of the core functionality of libnfc on an embedded non-Linux device, keeping in mind that you'll need to work around any 3rd part library dependencies?

Whole libnfc doesn't have to be in the CPU, it can be shinked to the minimal: only use C wrappring  functions to be able to manipulate the PN532 but you don't need for example the code which detect device, multiple bus transport, etc.

ktownsend wrote:

If some of you can provide a list of some features that you'd consider mandatory, it would help to keep them in mind as I start working on the combined PN532 + ARM board.  Mostly, though, I'm curious if it's realistic to build a version of libnfc for an embedded device in <20KB, and what level of interest there is in the HW.

Don't worry about the footprint, the interesting part could be less than remaining bytes. BTW, do you know MiKey Card project, which is an ARM with a PN532 ?
http://www.mikeycard.org/

ktownsend wrote:

The breakout boards in any case should be here in two weeks time, and if everything is OK I'll publish the files and probably make a small batch of them available just to recover some of the costs involved developping them.

OK, please notice us when it will be available. Do you have some idea about price ?

ktownsend wrote:

but it would help to know if 20-25KB is enough for an embedded/ARM version of libnfc (as an estimate).

IMHO, yes I think it will fit.

Romuald Conty

Re: Open Source PN532 HW

rconty wrote:

BTW, it could be really interesting if this OEM reader have a chooseable output bus, I mean PN532 can be connected to I2C, SPI or UART its better if user can use one hardware for multiple purpose.

You can already use all three.  I have two jumpers to select between UART, I2C and SPI though I've only ever tested UART.  All the useful pins are broken out, though.

rconty wrote:

Don't worry about the footprint, the interesting part could be less than remaining bytes. BTW, do you know MiKey Card project, which is an ARM with a PN532 ?
http://www.mikeycard.org/

Yes ... I spoke a few times with the guy working on it.  I'm aiming for something a bit more basic, though, and just want to be able to do basic NFC stuff with an inexpensive MCU.  My interest is just providing a reusable building block that can make it easier to develop other dedicated HW or peripherals.

rconty wrote:

OK, please notice us when it will be available. Do you have some idea about price ?

I've already ordered the PCBs so they should be here in 2 week or so, and I should have enough parts on hand to make a small first batch.  I'll have to sit down and add up the part cost and PCBs and what I spent on the prototypes to figure out a price, but it should be fairly reasonable.  My interest is just recovering the money spent getting the board working (three prototypes plus parts, etc.), plus reimbursing Roel who ordered the PN532s.

rconty wrote:

IMHO, yes I think it will fit.

Sounds good.  I already have working 1343 boards (see www.microbuilder.eu) that I'll hook up to the breakout board for now using UART.  It's trivial to combine the two boards later into a single PCB once the SW is working.  Once I get the PN532 breakouts in I'll let you know here though since I suspect some of you are in a far better position to port parts of libnfc than me.  I already have code to handle UART, I2C and SPI, though ... it's just the libnfc stuff.  I'll post a photo when I get the boards back and post the schematic and gerber files if the boards are OK (which I'm 99% sure they are).

Kevin

Re: Open Source PN532 HW

Here's the breakout board for curiousity sake: http://img211.imageshack.us/img211/6674/brdw.png

Re: Open Source PN532 HW

ktownsend wrote:

You can already use all three.  I have two jumpers to select between UART, I2C and SPI though I've only ever tested UART.  All the useful pins are broken out, though.

Very nice! Exactly as I except for. When could you send some boards, even prototypes to test it?

Romuald Conty

Re: Open Source PN532 HW

I just see the design, why don't you draw antenna around electronics instead of by side?

Romuald Conty

Re: Open Source PN532 HW

I wasn't sure whether the components would interfere with the antenna, and for a breakout board for development the size isn't really that critical so I didn't think it was worth spending a couple hundred Euros on a new design (one test spin plus the production tooling costs and PCB fees).  For a combined stand-alone board (PN532 + ARM) I'll place all the components in the middle, though, and try to make the antenna a little bit longer to improve the range a bit.

I ordered the boards a couple days ago and it's usually two weeks, but with Christmas maybe 2-3 days more.  I can probably put some together the first week of January.

Last edited by ktownsend (2010-12-23 17:59:54)

Re: Open Source PN532 HW

The PCBs were shipped out from China today and should be here Monday.  If everything is OK, I can probably put a batch together next week.  I'll post some photos here when i get them, but I'm not expecting any (bad) surprises.

Re: Open Source PN532 HW

Got the PCBs in this morning and put two together to test.  Everything seems fine over UART, though I have no way at present to test anything via SPI or I2C.

http://yfrog.com/f/h7rsrej/

The range isn't extraordinary ... I can read an ov-chipkaart from about 3.5cm ... but the antenna isn't huge either, and perhaps I can add another 0.5-1.0cm if the board can be tuned a bit better.  I might try making a larger antenna and placing everything in the middle on a future revision, but I need to make sure all the HW is fine first.

Should be useful for development, though, since everything is broken out to 0.1" headers, etc.

Re: Open Source PN532 HW

ktownsend wrote:

Got the PCBs in this morning

Great news! I hope it will be soon your shop: http://www.microbuilder.eu/Store.aspx

ktownsend wrote:

Everything seems fine over UART, though I have no way at present to test anything via SPI or I2C.

Unfortunnately, I2C support is platform dependent and requires a kernel module under linux (some operations needs to be in kernel space to be done). BTW, SPI could be tried with Gwenn's work: http://www.libnfc.org/community/topic/2 … rough-spi/

ktownsend wrote:

I might try making a larger antenna and placing everything in the middle on a future revision, but I need to make sure all the HW is fine first.

NXP have an antenna design guide (AN144511), did you read it?

Romuald Conty

Re: Open Source PN532 HW

rconty wrote:

Great news! I hope it will be soon your shop: http://www.microbuilder.eu/Store.aspx

I'd really like to do some basic tests first in SW before I put it in the store or publish the board files since I don't want to mislead anyone if there are any problems (though admittedly the board is pretty simple).  I believe there is SW SPI support in the Linux kernel, if I2C isn't an option (though I'm hardly a Linux expert and made this mainly for use with small embedded devices).  UART is fine for a PC, but something like SPI or I2C can sometimes be easier in embedded devices ... though it seems NXP has managed the SPI in kind of a wierd/non-standard way as well with the PN53x. :-(  I'll take a look at the link you mentionned though.

rconty wrote:

NXP have an antenna design guide (AN144511), did you read it?

I didn't see that, but it's on request only so no surprise.  I think the antenna is actually OK, though, other than maybe needing some tuning.  Physical size is probably the biggest factor.  If I can get access to a network analyser I can probably improve it a bit or maybe I'll try to hit up someone I know who has one to measure it for me.  What is the typical range for a card like that (ov-chipkaart/RET) out of curiousity?

What I'd love is to get this working with a cheap MCU and make a small dedicated device that can log data, etc., but I'd need some help on the SW side since I don't have enough familiarity with NFC.  If you're interested in collaborating on an integrated open source/HW design I'd be glad to send you a PN532 board plus an LPC1343 or LPC1114 board.  Just email me via the contact page at microbuilder.eu.

Last edited by ktownsend (2011-01-03 14:19:35)

Re: Open Source PN532 HW

Hello

Do you have any news regarding your open board project ?

Regards

Re: Open Source PN532 HW

Hey,

0blar wrote:

Do you have any news regarding your open board project ?

Yes, I have received 4 prototypes.
It works but antenna's electronic need to be tweaked a bit: some devices need to "stick on" antenna to works.

We will annouce on this forum when the board will be available.
BTW, if anybody want to join the development effort of this project, send me a pm or an email.

Romuald Conty

Re: Open Source PN532 HW

rconty wrote:

Yes, I have received 4 prototypes.
It works but antenna's electronic need to be tweaked a bit: some devices need to "stick on" antenna to works.

Excelent!  I'll try to get in touch with people versed in antenas from the networking and telecommunication department of the university: I got told students receive lectures on thoses topics.  Anyway, if you have some resources to recommand about antenas, feel free to give me the pointers ;-)

Romain

Re: Open Source PN532 HW

Roel was able to get the boards tuned, which seems to have made a significant difference in range, especially for smaller tags.  I put together a small first batch of updated boards and will have more parts this week to put some more together next week.  It will take a bit of time to make some tutorials or documentation, but the HW at least seems sound.

Re: Open Source PN532 HW

Hi,

I just received this breakout board board and connected it to a FT232R breakout board. When trying to run the nfc-poll example I get the following error:

lt-nfc-poll: ERROR: No ACK.
lt-nfc-poll: ERROR: Unable to wakeup the PN532.
lt-nfc-poll: ERROR: Unable to receive data. (RX)
lt-nfc-poll: ERROR: No ACK.
lt-nfc-poll: ERROR: Unable to wakeup the PN532.
lt-nfc-poll: ERROR: Unable to receive data. (RX)
Connected to NFC reader: PN532 (/dev/ttyUSB0) - PN532 v1.6 (0x07)
PN532 will poll during 30000 ms

Right now i am powering the board from the 3.3v output on the FTDI chip. Could it be that the FTDI chip is unable to supply sufficient power and that this is the source of the problem?

Re: Open Source PN532 HW

transputer wrote:

Hi,

I just received this breakout board board and connected it to a FT232R breakout board. When trying to run the nfc-poll example I get the following error:

lt-nfc-poll: ERROR: No ACK.
lt-nfc-poll: ERROR: Unable to wakeup the PN532.
lt-nfc-poll: ERROR: Unable to receive data. (RX)
lt-nfc-poll: ERROR: No ACK.
lt-nfc-poll: ERROR: Unable to wakeup the PN532.
lt-nfc-poll: ERROR: Unable to receive data. (RX)
Connected to NFC reader: PN532 (/dev/ttyUSB0) - PN532 v1.6 (0x07)
PN532 will poll during 30000 ms

Right now i am powering the board from the 3.3v output on the FTDI chip. Could it be that the FTDI chip is unable to supply sufficient power and that this is the source of the problem?

I think your you're seeing the "Unable to wakeup" message because the board is permanently 'woken up' since the RSTPD_N pin is pulled high. (I've actually been thinking about putting a solder jumper on this in the enxt revision to be able to disable this as well.)  The board seems to be working if you're seeing the "PN532 will pooll during 30000 ms" message.  Just place a card over the antenna and you should see the details from it.

Re: Open Source PN532 HW

Hello,

transputer wrote:

I just received this breakout board board and connected it to a FT232R breakout board. When trying to run the nfc-poll example I get the following error:

lt-nfc-poll: ERROR: No ACK.
lt-nfc-poll: ERROR: Unable to wakeup the PN532.
lt-nfc-poll: ERROR: Unable to receive data. (RX)
lt-nfc-poll: ERROR: No ACK.
lt-nfc-poll: ERROR: Unable to wakeup the PN532.
lt-nfc-poll: ERROR: Unable to receive data. (RX)

You can ignore these messages, there are not related to your device but are generated while trying to probe PN532 device on other serial ports.
Thanks for reporting, currently we are rewriting the way we use UART port, I hope this will be remove in the next release.

transputer wrote:

Connected to NFC reader: PN532 (/dev/ttyUSB0) - PN532 v1.6 (0x07)
PN532 will poll during 30000 ms

This confirm that your port works as expected.

Sorry for inconvinience.

Bye

Romuald Conty

Re: Open Source PN532 HW

ktownsend wrote:

I think your you're seeing the "Unable to wakeup" message because the board is permanently 'woken up' since the RSTPD_N pin is pulled high.

As said, this board works as expected, messages can be ignored in this case, BTW, I think the RSTPD_N pin should be pulled low to save some power.
Do you know if when RSTPD_N pin is high we can put the PN532 in sleep mode using the right software command ?
(I have to check this point in user manual, if I have enough spare time one day, I hope to implement sleep mode in libnfc.)

Romuald Conty

Re: Open Source PN532 HW

rconty wrote:

As said, this board works as expected, messages can be ignored in this case, BTW, I think the RSTPD_N pin should be pulled low to save some power.
Do you know if when RSTPD_N pin is high we can put the PN532 in sleep mode using the right software command ?
(I have to check this point in user manual, if I have enough spare time one day, I hope to implement sleep mode in libnfc.)

I believe that you can still put it into sleep mode in SW, but I'll have to look myself.  I was hesitant putting a pullup on this pin anyway.  It makes it easy to use on the PC since you don't need to worry about wakeup delays or commands, but in an embedded context you definately want to save power and keep the chip in a power down mode when not in use.  In a future version I may not keep the pullup, or maybe put a solder jumper on it so the pullup can be physically disabled if desired.

I'm working on an updated board with the components in the middle to save some space, so I'm open to any feedback on default pin state, etc.

Re: Open Source PN532 HW

Hey,

Currently, I'm rewrinting PN532_UART driver in order to (greatly) speed up communication and improve the robustness.
During this rewriting I saw a interesting thing: your PN532 breakout board NEED to be waken up !

For a while, I dropped the PN532 wake up sequence at start and the board doesn't reply !
If I send the wake up sequence, the device become reachable again... So, its confirmed: your board start in sleeping mode, BTW, that's exactly what I'm expecting smile

Good news for planet, bad news for developers who will have to code wake up smile

BTW, I hope to implement a real sleep/awake mode handling in libnfc soon, currently its just a wake up sequence at start but we can make better.

Romuald Conty

Re: Open Source PN532 HW

Hey,

Currently, I'm rewrinting PN532_UART driver in order to (greatly) speed up communication and improve the robustness.
During this rewriting I saw a interesting thing: your PN532 breakout board NEED to be waken up !

For a while, I dropped the PN532 wake up sequence at start and the board doesn't reply !
If I send the wake up sequence, the device become reachable again... So, its confirmed: your board start in sleeping mode, BTW, that's exactly what I'm expecting smile

Good news for planet, bad news for developers who will have to code wake up smile

BTW, I hope to implement a real sleep/awake mode handling in libnfc soon, currently its just a wake up sequence at start but we can make better.

Romuald Conty

Re: Open Source PN532 HW

Hi

I'm working with a little project where I'm trying to connect the breakout board from microbuilder.eu to an ARM Cortex-M3 from STMicroelectronic via UART.

I'ved quickly tried to get it to work but I cannot get it to answer me. I'm sending it the wakeup sequence (0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, 0xfd, 0xd4, 0x14, 0x01, 0x17, 0x00), but I don't get any reply from it. The IRQ-pin is always high, I'ved tried to also send the ACK-command (0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00) but nothing happens.

I've verified that all voltage levels are on the right level. I've also verified that I get the commands on UART both in a terminal program and with an oscilliscope.

How should the pins on the board be connected? Obviously 3.3 V, GND, the communication interface selection, Tx and Rx are straightforward, but the rest? What about RSTPDN_N  / RSTOUT_N? Any other pins that are necessary?

What other HEX commands are there out there? I've found these:
char NFC_startup[]     = {    0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0xff, 0x03, 0xfd, 0xd4, 0x14, 0x01, 0x17, 0x00 };
char NFC_ack[]         = { 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00 };
char NFC_nack[]        = { 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 };
char NFC_in_out     = { 0xFF };
char NFC_error[]    = { 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x7F, 0x81, 0x00 };
char NFC_ext[]        = { 0x00, 0x00, 0xFF, 0xFF, 0xFF };
char NFC_com_start[]= {    0x00, 0x00, 0xFF };

Last edited by maax (2011-04-01 11:58:43)

Re: Open Source PN532 HW

Hi Maax,

maax wrote:

How should the pins on the board be connected? Obviously 3.3 V, GND, the communication interface selection, Tx and Rx are straightforward, but the rest? What about RSTPDN_N  / RSTOUT_N? Any other pins that are necessary?

I'm using the PN532 breakout board form microBuilder.eu and I only plug GND, 3.3v and Rx/Tx lines.

Do you have tried to swap Rx and Tx ? (Tx means transmission... but from the host or from the device, that's the question smile )

maax wrote:

What other HEX commands are there out there?

The PN532 User Manual contains all commands and describe the framing, you have to use it to drive the chip:
http://www.libnfc.org/community/topic/3 … r-manuals/

I hope it helps.

Romuald Conty

Re: Open Source PN532 HW

Did you ever post the schematic and BOM for the breakout board? I am looking to build a few of these myself.