Skip to main content
Visitor II
March 18, 2021
Solved

X-NUCLEO-NFC06A1 doesn't read and write any tag, "NDEF NOT DETECTED" error

  • March 18, 2021
  • 14 replies
  • 5677 views

Hello to all!

I have boards - NUCLEOL476RG and X-NUCLEO-NFC06A1 with project "STM32L476RG-Nucleo_PollingTagDetectNdef" running on it.

And got an error when trying to read any tag:

0693W000008xIJLQA2.pngWhen debugging program i found that error, its here in the code, doesn't match

apduParam->statusWord == RFAL_T4T_ISO7816_STATUS_COMPLETE

The walue of statusWord is 27266 instead of 36864 (0x9000)

0693W000008xILRQA2.jpgAppreciate for help and sorry for my english))

    This topic has been closed for replies.
    Best answer by Ulysses HERNIOSUS

    Hi,

    X-CUBE-NFC6 supports card emulation. However if you use a phone which does act as Reader/Writer and as card against another device which acts also in both roles it is somewhat random which one ends up in which mode. In X-CUBE-NFC6 you could remove all PCD/reader/writer modes from techs2find param. Or use the bluetooth pairing demo in STSW-ST25R-LIB. The demo is built to not require any app on the phone but rather rely on the built-in NFC forum support of Android.

    For P2P: Its support is disappearing in recent phones. Iphone never adopted and recent Android phones are dropping it (e.g. Samsung Galaxy S20, S21, Pixel, etc. ).

    Reading through your requests it does not look like that you are interested in NDEF itself. But rather you want a bi-directional communication with phones. If this is true then I would implement an own protocol based on smartcard/ISODEP. Create an Android app similar to above mentioned "NDEF Tag Emulator". Register it with your own Application ID in the system. Then on top of ISODEP you can exchange arbitrary APDUs (You may want to follow ISO7816 (-4ff ) style).

    On X-NUCLEO-NFC06 I would use the polling for NFC-A and maybe NFC-B, use the example for reading T4T but instead reading NDEF, select your own application ID (defined above) and implement the counter part of your protocol.

    An example which could help you on Android side is the SwipeYours app. Its source code is available and it implements VISA payment as example. But you should be able to easily exchange the payment part with your own stuff.

    Best Regards, Ulysses

    14 replies

    WladimirAuthor
    Visitor II
    March 23, 2021

    Hello, Ulysses!

    I set up Card Emulation mode on X-NUCLEO-NFC06A1 board by adding

    #define ST25R3916

    #define DEMO_CARD_EMULATION_ONLY true

    in demo.h file.

    Phone polling for NFC-A and NFC-F technologies both, so i commented

    //case RFAL_NFC_POLL_TYPE_NFCA:

    in demoCycle() function, so i have only NFC-F enabled in CE mode.

    ( Besides, when i commenting

    //case RFAL_NFC_POLL_TYPE_NFCF:

    i.e. setting up only NFC-A its not working, NFC Tools recognizing it as NFC-F and writing on "tag" (board) doesn't working. )

    And what's happening in NFC-F mode. Its not working properly.

    After board reset reading board as tag showing info in NFC Tools:

    0693W000008xghHQAQ.jpgWhen i trying to write plain text ("hello!!") first time - there is success info message in NFC Tools. Second time (and subsequent) - i got fail info message.

    After writing on "tag" 1st time, reading "tag" gives another results:

    0693W000008xgkGQAQ.jpg 

    So there is no message on the label that I wanted to record.

    WladimirAuthor
    Visitor II
    March 23, 2021

    Looking in debug mode function demoCeT3TUpdate(), cmdData[13] - there is data lenght to read, its only = 1, but got to be more....

    Best regards.

    WladimirAuthor
    Visitor II
    March 24, 2021

    Hello!

    (Maybe should to start new topic about Card Emulation)

    Here is interesting detail, when X-NUCLEO-NFC06A1 board starting after reset, ndefFile buffer is empty (observing via debug):

    0693W000008xkfoQAA.jpgWhen reading a "tag" (board in CE mode) 1st time its initializing by default value:

    0693W000008xkcaQAA.jpgMaybe its because CE mode initializing when reading "tag" happens.

    Ok, whats happens next - i writing message on "tag", and its ok:

    0693W000008xkkUQAQ.jpgAlthough we also see leftovers from the previous package.

    But the problem is that this recorded message cannot be read, the reading ends with an error in NFC Tools app.

    I also compared the content of the InformationBlock before and after writing a "tag", it does not change except for the size of the payload and NDEF mapping version (don't know what it is).

    Perhaps this problem, when it is not possible to read the NFC tag, that is, the useful information written to it, is similar to the one when it is not possible to read the information from the NFC-A tag. But with the NFC-A tag, the information cannot be read immediately after the board is started.

    Technical Moderator
    March 24, 2021

    Hi VIVAN.1,

    I have reproduced your symptoms and I fear that there are bugs in the implementation for writing to the emulated T3T/T4T storage.

    As this code is regarded as demo/application code we seem to have only performed limited testing. The write support was implemented, maybe tested in a limited scenario, but not the way you are using now. I have triggered an internal ticket for investigating/fixing.

    Are you actually considering the T3T emulation for your application or are you merely exploring the options?

    Regards, Ulysses

    WladimirAuthor
    Visitor II
    March 24, 2021

    Hi, Ulysses!

    T3T (NFC) is not necessarily the final option, just T4T (NFC-A) in tag emulation mode does not work at all, but is partially defined as NFC-F. I need the technology that will work better with the phone.

    NFC Tools app is currently all that I have on android, there is also an NFC TagWriter app with less functionality. At the moment, I do not have the ability to write for android. Now I want to make the data exchange between the phone and the X-NUCLEO-NFC06A1 board in such a way that the phone and the board change roles as NFC tag and reader/writer. Having only the NFC Tools app on Android, I do not know how to exchange data in another way.

    Best regards.

    Technical Moderator
    March 24, 2021

    Hi,

    the trick should not be playing with the state machine but just change techs2Find.

    Please try the attached hex, it was compiled according to my above instructions.

    0693W000008xnVJQAY.jpgYes, with my proposal you need to have your own Android app.

    Not sure what you want exactly you want to achieve. Just reading/writing some messages to trigger an action?

    Regards, Ulysses

    WladimirAuthor
    Visitor II
    March 24, 2021

    Hi,

    I used your hex and the result of reading the label is the same as yours. I did as you said, changed tech2find and I recognized the NFC-A tag, okay. The writing is more difficult, the text or URL is written in ndefFile, I looked in debugging, but the problem is that when reading the label in ndefFile, the default entry is written again - the address of the page st25demo.

    Writing to NFC-F problems doesn't change.

    Regards

    WladimirAuthor
    Visitor II
    March 26, 2021

    Hello, Ulysses!

    At the moment, the problem is that in the Tag Emulation mode, writing to the "tag" works, that is, the content of the ndefFile changes to what I write, but when reading the content of the ndefFile changes to the default - "st.com/st25-demo".

    I am trying to track the exchange of useful data between phone and board, I looked at the contents of the array txBuf[100] in demoCE() function, but I did not see the default content of the tag ("st.com/st25-demo") there during data exchange.

    Best regards.

    Technical Moderator
    March 26, 2021

    Hi VIVAN.1,

    it makes me curious and I will try to find some time next week to debug into this. In case you have additional findings, please let me know!

    BR, Ulysses

    WladimirAuthor
    Visitor II
    March 26, 2021

    Hi,

    ok, thanks!)