cancel
Showing results for 
Search instead for 
Did you mean: 

Read/Write to STmicro ISO 14443-4 tags using X-Nucleo and raspberry pi

JMilk.1
Associate III

Hi all,

I'm trying to read and write values to an STmicro tag(ST25TA02KB-D,  ISO 14443-4) using the X-Nucleo board from a python program. I've tried a number of approaches(waveshare pi hat, standalone PN532 modules, using libnfc and adafruit libraries, to list) but none really work and it's honestly a little out of my depth.

Currently I've built the Linux nfc polling demo included with the X-Nucleo board, but even that fails to run(see attached)

If I had resources or python examples using any of these systems, I could probably figure it out, but all the support I've found seems to apply mainly to mifare classic cards.

If anybody has experience or pointers for any of this I'd be quite grateful to hear it!

27 REPLIES 27

Hi,

please check if you have libpthread.so in your file system. Please also share CMakeLists.txt and the generated Makefile. Also share the output of the cmake call.

Best Regards, Ulysses

JMilk.1
Associate III

Thank you! After making these revisions the tag was picked up by the NFC Poller! Below is the result:

0693W00000QKUeAQAX.pngHere is Cmakelists.txt:

0693W00000QKUeFQAX.pngAnd attached is the makefile>

I've found functions outside of main.c that support reading and writing- would I just call them in main or are there separate examples to support that? I'd like to dump the contents of a tag, then write to a specific location.

Brian TIDAL
ST Employee

Hi,

good job!

Do you use a T2T or T4T tag? The tag seems to be an ST tag (manufacturer id = 02 in the first byte of the UID). Is it an ST25TA (T4T) or an ST25TN (T2T)?

T2T uses simple READ/WRITE block commands to access memory location whereas T4T uses ISO7816 commands to select an application and then to select a file and then to read/write a given file.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
JMilk.1
Associate III

Thank you! Almost there.

I appreciate all the help! They're ST25TA(02KB-D) tags, so T4T I think.

JMilk.1
Associate III

Running the default nfcPoller.exe just lists the uid of found tags, but the rfal package seems equipped to do a lot more than that.

Are there different programs in there, or parameters I could enable to allow for T4T read/write? I've seen functions like that in the code, I've tried to implement some of the prototypes in ST25R3911_com.h, but thus far my attempts have been pretty kludgy.

For reference, here's all I see when I run nfcPoller as is:

0693W00000QKaxrQAD.png After making some(undoubtedly nonstandard) changes to exampleRfalPollerRun.c and rebuilding I get here:

0693W00000QKayBQAT.pngBut that's kind of an unreliable approach, and better to use the program as intended.

Edit: exampleRfalPollerRun.c is outside the build folder, so I'm reextracting ST25R009.xz and running a completely fresh build to account for any changes.

JMilk.1
Associate III

Running a clean build yields a similar result.

So here's my process:

I extracted ST25R009.xz to /home/pi/, then replaced the Cmakelists.txt file in applications with the fixed pthread version. Running nfcPoller gives me this, just looping, it looks similar to the demo output in the documentation but it never makes it to the deactivation step:

0693W00000QKb2wQAD.png I set a breakpoint at exampleRfalPollerRun and step through(actually "next" not "step"), and it seems like everything runs normally up to this point here, where collision avoidance completes and gState is set to activation:

0693W00000QKb49QAD.pngOn hitting the switch statement again, it should go here, Rfal activation. (That gState data exchange start line comes commented out, I'm assuming for demo mode?) But it doesn't even get there:

0693W00000QKb5bQAD.png 

Instead it looks like the "#if 0" fails, and the program skips everything down to here, turning the field off, and from that point it just restarts the loop(edit, it's likely this is intentional, and just a way of block commenting stuff out):

0693W00000QKb6FQAT.png 

By changing exampleRfalPollerRun to invert the #if 0 and uncommenting the activation line I can force it through, like so:0693W00000QKbBjQAL.pngBut even then, the data exchange just starts and throws a "busy" (err = 2 in exampleRfalPollerDataExchange) before exiting with error 4(time out).

Grégoire Poulain
ST Employee

Hi,

The Polling demo by default basically lists the UID of the cards/tags identified.

Please be aware that that package was released ~5years ago and it may not be the best reference to base your work (also the drivers are outdated).

The demo has indeed some disabled/commented/excluded code by means of the preprocessor directive #if 0.

If this is somehow unclear to you, I would suggest to refer to additional documentation on the topic (e.g. GCC, Wikibooks).

If you enable those code blocks the demo will continue and activate a card.

In case it's a T4T, it will try to exchange an ISO7816 APDU.

As you are using an ST25TA, which NDEF formatted, the first command to be send should be a Select NDEF Application. You would need to update the APDU packet (t4tSelectReq) frame.

Nevertheless, that demo exchanges a single frame as an example, but it is not a complete implementation of NDEF or any other higher layer application.

Unlike others T4T have a complex organization of applications, files, data blocks, that need to be understood and navigated.

What exactly would you like to do with the card?

Would a simpler memory card such as T2T or T5T suffice?

Kind regards

GP

JMilk.1
Associate III

Thank you! I'm a junior EE mostly dealing with hardware, but we're tagging in one of our developers to assist, so hopefully that'll be less of an issue.

What we're trying to do is automate the process of reading the memory and writing a short text file- essentially a model number. Unfortunately we're locked into the ST25TA at this point, and revising the board isn't a possibility, though there are some alternative options to interface with it, namely a waveshare PN532 NFC hat, or a standalone PN532 module.

Solution update: I've found that NFCpy(https://nfcpy.readthedocs.io/en/latest/topics/get-started.html#installation) has support for T4T tags- we're using the PN532 module connected over UART, and are now able to read and write text to the ST25 tag.

I'm tagging this as best for anyone doing the same thing in the future, Thank you all for your help!