-1

We have designed a board based on TI RF430FRL152HEVM evaluation module with NFC capability. When an Android phone comes near the the antenna of the board, the NFC allows the processor to boot up and to begin reading the data. It puts the data it reads into memory.

The phone must then grab this data out of the device using NFC (or rather ISO 15693).

The only way we know how to do this for the moment is to write it into the standard NFC memory blocks.

We downloaded an Android App called NFC TagInfo and this lets us scan our sensor and collect all the data in the sensor memory, i.e. all the blocks.

We are writing it into what the chip manufacturer says is the NDEF message area in FRAM. I have written a reader/writer NFC app for another project, that works well, but it refuses to read the data here, although NFC TagInfo does read the data.

We assumed that the TI chip had been NDEF formatted, but all the documentation we found on how to do this is very unclear. So we guess it hasn't been.

Could somebody explain how to properly prepare the memory contents so that an NDEF message can be read by the phone?

Additional information

We write data into the FRAM starting from block 0 onwards and have tried to mimic the data one would see in a typical tag containing a very simple NDEF message. For example we stored the message "ABCD" and using NFC TagInfo you see this in the first few blocks:

04 5c d8 08  4a 62 3e 80
96 48 00 00  e1 10 12 00
01 03 a0 0c  34 03 21 d1
01 1d 54 02  65 6e 41 42
43 44 20 20  ...

Where 41 42 43 44 is "ABCD" in UTF-8.

We took this data (NDEF format + headers) from another tag (read using NFC TagInfo) and copied this data into the FRAM blocks of our tag chip. We stopped at the end of the NDEF message and the rest of the FRAM is 0x00 or 0xff.

Obviously the tag that we copied the data from (NXP) and our tag chip (TI) are from different manufacturers so some data in the first few blocks is not valid for our TI chip but assumed that Android shouldn’t care.

However, when we read our TI tag with NFC TagInfo it can read the raw data blocks but it does not recognize the tag as an NDEF formatted tag.

  • Is it that the NDEF formatting we copied from the other tag is not valid for our tag because we are not using the same tag memory sizes, etc?

  • If one simply writes the correct bytes in the correct blocks then can anything be picked up as NDEF, after all, at the low level what is the difference?

  • If this is the case what would be the most sensible test case of bytes to use in which blocks, is there a better way to test the concept?

  • Does block locking make any difference? As we can see some blocks are locked in a real tag.

  • Why does NFC TagInfo see blocks sometimes and then pages for when NDEF is detected? Are blocks and pages the same?

  • Failing all else, how can we codify in Android simple block reading, in the same way that the NFC TagInfo performs its hex-dump? If we can do that then NDEF is not really necessary.

Additional information 2

I have modified the firmware such that the FRAM, from block 0 onwards contains the data you have mentioned:

E1 40 F2 09   03 0B D1 01
07 54 02 65   6E 41 42 43
44 FE 00 00   00 00 00 00

However I cannot seem to put the TI chip in 8 byte block mode. There does not appear to be a control register related to this.

From my low level point of view writing blocks in 4 or 8 bytes is not an issue, that is, I byte wise write the above data sequentially in FRAM memory.

When I run NFC TagInfo it does two things but does not detect an NDEF message:

  • It does detect the UID correctly, and the fact the RF Tech is Type 5 (ISO 15693 / Vicinity)
  • It also does read the blocks correctly and on selecting Data HEX display I see precisely the above data in the blocks starting from block 0.

I have consulted the NFC Tag Type 5 Specification which I got from http://open-nfc.org/documents/STS_NFC_0707-001%20NFC%20Tag%20Type%205%20Specification.pdf

So I tried to write more data into the TAG from block 0 to try and emulate the SERIAL NUMBER, CONFIGURATION, Application area issuer blocks. And then I placed the NDEF message ABCD after the sections:

01 02 03 04   05 06 07 08   //serial number
00 00 00 80   00 10 00 00   //configuration
...

I used NFC TagInfo but I could not detect an NDEF message either. However, using the Data Hex display I could verify the data was correctly read out as above.

So my questions are:

  • Is it relevant whether 4 or 8 byte block mode are configured and where most likely is this mode defined? Can I work in 4 byte block mode all the same?
  • Is the TAG 5 serial number relevant? Doesn't seem to affect NDEF checking according to the spec.
  • Is the TAG 5 application area issuer relevant? Doesn't seem to be relevant to NDEF verification.
  • Is the NDEF message I have placed in the correct area?
  • For 16 bit values is it high byte low byte or low byte high byte ordering?
  • Any ideas what's going wrong?

Additional information 3

It turned out that TI needed to provide a patch in order to get NDEF to work with that chip (FRL152H). Basically the chip is designed to support high level control of sensor functions via NFC, using an internal firmware application. This application needed to be disabled and some settings changed.

The following memory configuration turned out to work:

Block 0:  E1 40 79 00
Block 1:  03 0B D1 01
Block 2:  07 54 02 65
Block 3:  6e 41 42 43
Block 4:  44 FE 00 00
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
Clararhea
  • 159
  • 1
  • 2
  • 13
  • I don't know what "put on hold" means and I don't understand why it appears to be off-topic for this site, but if somebody could help or direct me somewhere else, it would be really nice. – Clararhea Mar 24 '16 at 09:17
  • "Put on hold" means that your question does not currently meet the rules for questions on Stack Overflow and needs to be rephrased. Othwerwise it may soon be deleted. In your specific case, the problem was the question "*Could somebody please point us to information or tutorial on how to format it to NDEF?*" as asking for tutorials or off-site resources ("*point us to information*") is not wanted on SO. I tried to rephrase your question to better fit the scope of SO, but it seems this was not enough for the reviewers. – Michael Roland Mar 25 '16 at 09:20
  • In my opinion, this question should be reopened as it can easily be answered by explaining what data structures you need to put into the NDEF memory. However, you might also want to add some more information to your question: What memory contents do you currently read with NFC TagInfo (first few blocks should be enough)? Do you already use the FRAM as NDEF space (i.e. does the data you read exactly match the data you wrote from the µC)? – Michael Roland Mar 25 '16 at 09:23
  • Thank you for your answer Michael. I will come back to you with more info. – Clararhea Mar 25 '16 at 13:37
  • Hi Michael,here are more info. I had to ask my husband because he is more the one dealing with it: – Clararhea Mar 25 '16 at 14:20
  • My message was too long compared to what I am allowed to write here, so I have sent it to the email address I found on your website. – Clararhea Mar 25 '16 at 14:29
  • Hi, please don't send me updates to your question through e-mail (I'll probably ignore them). Edit the information into your question instead. – Michael Roland Mar 25 '16 at 15:44
  • Sorry, I didn't realize I could edit my initial post. I have done that now. – Clararhea Mar 25 '16 at 15:57

1 Answers1

2

Is it that the NDEF formatting we copied from the other tag is not valid for our tag?

That's exactly the problem. Looking at the first 12 bytes of your memory dump, you obviously copied the data blocks from an NXP NTAG203 (or similar) as indicated by the manufacturer code (byte 0: 0x04) and the memory size in the capability container (byte 13: 0x12). NXP's NTAG and MIFARE Ultralight series follow the NFC Forum Type 2 Tag Operation specification. However, your TI chip (RF430FRL152H) is based on ISO/IEC 15693 and consequently follow the NFC Forum Type 5 Tag Operation specification. The Tag Operation specifications define the data formats and command sets that turn an NFC tag into an NDEF tag. There are several (currently 5) different such specifications because NFC technology combines several different RF standards (ISO/IEC 14443, FeliCa, ISO/IEC 15693) and uses tag hardware that already existed for those standards before NFC.

Why does NFC TagInfo see blocks sometimes and then pages for when NDEF is detected? Are blocks and pages the same?

In that case, blocks and pages are equivalent. The different wording simply comes from the terminology used by the chip manufacturers. Note that the RF430FRL152H chip uses the term "pages" to group several blocks and therefore with a different meaning.

If one simply writes the correct bytes in the correct blocks then can anything be picked up as NDEF, after all, at the low level what is the difference?

The difference is that your TI RF430FRL152H tag chip needs to use a different coding for the NDEF memory area than the NXP tag. This is simply because it uses a different low-level communication technology (modulation, coding, framing, command set) and consequently follows a different NFC Forum Tag Operation specification.

In order to make your tag chip an NDEF tag, you need to use the following coding for the NDEF memory area starting at block 0: Note that the capability container was filled with values that assume a block size of 8 bytes. You can change the ISO block size option using the flag ISOBlockSize in the Firmware Control Register (see section 7.54 "Firmware System Control Register" in the RF430FRL15xH Firmware User's Guide).

E1 40 F2 09   03 0B D1 01
07 54 02 65   6E 41 42 43
44 FE 00 00   00 00 00 00

This would result into an NDEF message containing one Text record with the message "ABCD".

The first 4 bytes (E1 40 F2 09) are the capability container:

  • 0xE1 is the magic number identifying the capability container for a tag where the complete memory area can be addressed with one byte block addresses.
  • 0x40 codes version 1.0 of the Type 5 tag memory mapping and indicates free read/write access to the memory.
  • 0xF2 defines the overall NDEF memory area (except for the CC bytes) to have a length of 242 (0xF2) times 8 bytes (= 1936 bytes). See the section "Theory vs. practice" below!
  • 0x09 indicates that your tag supports the READ_MULTIPLE_BLOCKS command (bit 0 set) and the LOCK_BLOCK command (bit 3 set).

The next 2 bytes (03 0B) are the header of the NDEF Message TLV (tag-length-value coded data structure):

  • 0x03: Header byte indicating NDEF Message TLV.
  • 0x0B: Length of NDEF Message TLV = 11 bytes.

The next 11 bytes (D1 01 07 54 02 656E 41424344) are the NDEF message:

  • 0xD1: Record header byte:
    • Bits 7 and 6: This is the only record of the NDEF message.
    • Bit 4: This is a short record (i.e. the payload length is coded with a single byte).
    • Bits 2..0: The record type codes an NFC Forum well-known type.
  • 0x01: The type name field has a length of 1 byte.
  • 0x07: The payload field has a length of 7 bytes.
  • 0x54: The type name (in ASCII: "T") indicating an NFC Forum well-known Text record type (Text RTD).
  • 0x02..0x44: The payload field of the Text record:
    • 0x02: The text is encoded in UTF-8, the language field consists of 2 bytes.
    • 0x65 0x6E: The language field (in ASCII: "en") indicating the language English.
    • 0x41 0x42 0x43 0x44: The text payload (in UTF-8: "ABCD").

The next byte (FE) is the Terminator TLV indicating the end of the used data area. The remaining bytes of that block should be filled with zeros (0x00) in order to avoid problems with some Android devices.

Does block locking make any difference?

No, block locking does not change the way your tag is detected. It only changes how it can be accessed by the reading (Android) device: read/write access or read-only access.

Will this tag be detectable on all Android devices?

Unfortunately, no. The NFC Forum Type 5 Tag Operation specification was only finalized in July 2015. While some Android devices implemented NDEF on ISO/IEC 15693 (NFC-V) tags before that date, don't expect this the case for all Android devices. It should work on most devices starting with Android 5.0 though. Some Android devices should be capable of supporting NDEF on certain NFC-V tags even as of Android 4.3.

Theory vs. practice

After some further testing I found that even devices that do support NDEF on Type 5 (NFC-V) tags seem to have significant limitations (bugs???) in the implementations of their NFC stack. I tested a Samsung Galaxy S6 (Android 5.1.1) with two tag types from the TI Tag-it HF-I series:

  1. Tag-it HF-I Plus (2048 bit user memory, in 64 x 4 byte blocks)
  2. Tag-it HF-I Standard (256 bit user memory, in 8 x 4 byte blocks)

Unfortunately, none of them worked with the Galaxy S6 using the capability container that I described above. The problem was the size of the NDEF memory area (MLEN, stored in the third byte of the CC). Obviously, the size used above is too long for these two tags. Consequently I reduced it to match the size of the tag memory for each tag:

  1. Tag-it HF-I Plus:
    • 64 x 4 bytes = 256 bytes
    • 256 bytes / 8 = 32 (MLEN is always calculated as a multiple of 8 bytes)
    • minus 1 block since the CC does not count as part of the data area (according to the Type 5 Tag Operation specification)
    • MLEN = 31 = 0x1F
    • CC: E1 40 1F 09
  2. Tag-it HF-I Standard:
    • 8 x 4 bytes = 32 bytes
    • 32 bytes / 8 = 4 (MLEN is always calculated as a multiple of 8 bytes)
    • minus 1 block since the CC does not count as part of the data area (according to the Type 5 Tag Operation specification)
    • MLEN = 3 = 0x03
    • CC: E1 40 03 09

Still, this did not work. The tags were not detected as NDEF tags (only as NdefFormatable). Finally, I found that the Galaxy S6 only detects those tags if the MLEN byte reflects exactly the size of the whole memory area (including the CC bytes). Thus, only the following values worked:

  1. Tag-it HF-I Plus:
    • CC: E1 40 20 09
  2. Tag-it HF-I Standard:
    • CC: E1 40 04 09

Even worse, while the CC E1 40 04 09 worked on a Tag-it HF-I Standard tag, it did not work on a Tag-it HF-I Plus tag. Thus, the NFC stack of the Galaxy S6 seems to expect very specific values for the CC on different tag products.

Based on this, the following CC values should work for the RF430FRL152H:

  1. when block size is set to 8 bytes: E1 40 F3 09
  2. when block size is set to 4 bytes: E1 40 79 09

"should", since it's unclear how tags are identified and mapped to their expected CC values. Moreover, it's unclear if the Galaxy S6 even knows any expected CC value for that particular chip.

Another way to find the "correct" (= expected) values for the CC bytes would be to write an NDEF message to the tag using the NdefFormatable technology and then reading the CC bytes using a tag reader app like NFC TagInfo:

Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
NdefFormatable ndefFormatable = NdefFormatable.get(tag);

if (ndefFormatable != null) {
    try {
        ndefFormatable.connect();
        ndefFormatable.format(new NdefMessage(NdefRecord.createTextRecord("en", "ABCD")));
    } catch (Exception e) {
    } finally {
        try {
            ndefFormatable.close();
        } catch (Exception e) {
        }
    }
}

The same could be done using some generic tag writer app (except for NXP TagWriter which seems to be unable to write to the tag).

Failing all else, how can we implement simple block reading in Android, in the same way that the NFC TagInfo performs its hex-dump?

The RF430FRL152H should be detected as NFC-V (ISO/IEC 15693 in NFC terminology) tag by Android. So once you receive the NFC intent, you can obtain the tag handle and get an instance of the NfcV class for it:

Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
NfcV nfcV = NfcV.get(tag);

You can the connect to the tag and exchange low-level commands (e.g. READ_SINGLE_BLOCK) using the transceive method:

nfcV.connect();
byte[] tagUid = tag.getId();  // store tag UID for use in addressed commands

int blockAddress = 0;
byte[] cmd = new byte[] {
    (byte)0x60,  // FLAGS
    (byte)0x20,  // READ_SINGLE_BLOCK
    0, 0, 0, 0, 0, 0, 0, 0,
    (byte)(blockAddress & 0x0ff)
};
System.arraycopy(tagUid, 0, cmd, 2, 8);

byte[] response = nfcV.transceive(cmd);

nfcV.close();

Where can I get further information on tag formatting, NDEF and low-level commands?

  • NFC Forum Type 5 Tag Operation specification: from the NFC Forum website (unfortunately, NFC Forum specifications are no longer available for free).

    IMPORTANT: Be careful not to mix that with the "NFC Tag Type 5 Specification" offered by open-nfc.org. Even though both specifications talk about a tag "Type 5", they refer to a completely different tag platform. The specification from open-nfc.org is not compatible with the RF430FRL15xH chip.

  • A public document that is very close to the final NFC Forum Type 5 Tag Operation specification is the NXP application note AN11032 NXP Type ICODE Tag Operation. However, there are some significant differentces between the NFC Forum Type 5 Tag Operation specification and that application note (specifically with regard to the format of the capability container).
  • NFC Data Exchange Format (NDEF) specification: also from the NFC Forum website or from here.
  • NFC Record Type Definition (RTD) specification: also from the NFC Forum website or from here.
  • Text Record Type Definition specification: also from the NFC Forum website or from here.
  • NFC-V in the Digital Protocol specification: also from the NFC Forum website.
  • ISO/IEC 15693: This standard defines the standard low-level commands.
  • RF430FRL15xH User Guide: You can find the custom commands for access to the RAM memory area in sections 4.2ff.
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Thank you. We are digesting and trying it out. – Clararhea Mar 26 '16 at 13:28
  • As for before, I had to edit my initial question as message is too long to post here. You will find it in : Additional info 2. – Clararhea Mar 26 '16 at 17:55
  • @Clararhea A few other things, before I answer the new questions: (1) As I wrote in my answer, the NFC Tag Type 5 specification from open-nfc.org is **not** the same as the NFC Forum Type 5 Tag Operation specification and it **does not** apply to your tag chip. Don't use it. (2) What Android device and what Android version are you using? (3) Don't prepend anything to the data structure I showed you. The capability container must start at the first byte of block 0. (4) See my updated answer on switching block size. – Michael Roland Mar 26 '16 at 18:29
  • a) OK got it. Will not use it. b) I use a SAMSUNG Galaxy S6 with Android 5.1.1 Does the version make a difference? Should I try to update? c) OK Capability Container starts at block 0 d) As I mentionned in additional info 2, I cannot seem to put the TI chip in 8 byte block mode. There does not appear to be a control register related to this. Should I be able to control the 8 byte block read from the Android device and if yes, any ideas how? – Clararhea Mar 26 '16 at 18:51
  • Michael, any more news on your side? Cheers – Clararhea Mar 29 '16 at 16:39
  • @Clararhea Regarding the block size: That's something you control though a flag ("ISOBlockSize") in a register ("Firmware Control Register") on the chip (I assume you write to it just as you write to the NDEF data area). See section 7.54 "Firmware System Control Register" in the RF430FRL15xH Firmware User's Guide. – Michael Roland Mar 30 '16 at 08:01
  • @Clararhea Regarding detection on the Galaxy S6: I performed some tests (I don't have that particular chip but did some testing with other TI tags) and added a section "theory vs. practice" in my post. If you find working values for the CC it would be great if you could share them here. – Michael Roland Mar 30 '16 at 08:04
  • Thanks, will have a look – Clararhea Mar 30 '16 at 09:04
  • We have tried with E1 40 F3 09 03 0B D1 01 07 54 02 65 6E 41 42 43 44 FE 00 00 00 00 00 00 And E1 40 F2 09 03 0B D1 01 07 54 02 65 6E 41 42 43 44 FE 00 00 00 00 00 00 This time we enabled 8 byte block mode as well. Tag Info recognises the 8 byte block mode in its memory HEX dump. So that’s good. However it doesn’t recognise the TAG as an NDEF Tag. – Clararhea Mar 30 '16 at 16:42
  • I think that Texas Instruments has not somehow provided relevant information to Android yet. Do you know: a) Is there a list of Android supported NFC TAGs somewhere? b) Does a new TAG company need to tell Android about it? I will ask the same question to Texas. We will now try to use the low level block read method. Many Thanks! – Clararhea Mar 30 '16 at 16:42
  • @Clararhea So my idea with using `NdefFormatable` to find out how to format the tag did not work either? – Michael Roland Mar 30 '16 at 17:24
  • We didn't try it yet because we wanted to try the low level block reading first – Clararhea Mar 30 '16 at 17:58
  • @Clararhea Would still be great if you could test that and post the results here. – Michael Roland Mar 31 '16 at 22:41
  • Oh yes, definitely will ! Sorry for the delay, working on too many things at the same time. – Clararhea Apr 01 '16 at 08:57
  • I have managed to get Texas to write a patch for the FRL152H device, which results in the fact that I can use the sensor Tag with NDEF messaging. Using exactly the format you originally suggested. Thank you very much for your help. I have only one question, mainly comparing the TAG Info app with a couple of others and I seemed to notice a difference in the energy being received by the TAG looking at certain energy harvesting signals. In the TAG Info app do you ever try to control the emitted energy from the mobile phone? And if so is the method documented somewhere. – Clararhea Apr 04 '16 at 17:29
  • @Clararhea Are you refering to my NFC TagInfo app or to NXP's TagInfo app? – Michael Roland Apr 04 '16 at 19:48
  • @Clararhea Did they reveal what was changed with that patch? Also does the value of the MLEN field matter now? – Michael Roland Apr 04 '16 at 19:51
  • Please see answers in edited initial post : Additional info 3. Thanks – Clararhea Apr 05 '16 at 08:29
  • Regarding emitted energy: No, you can't really control that from an app (at least not directly). In fact, I'm rather surprised that my NFC TagInfo app appears to increase energy output. The only reason I could imagine is that the app tries to read the whole memory area. NFC is consequently busy for a rather long time. This would also mean that once NFC TagInfo finished reading, energy output should go down again since the connection to the tag is closed and the reader field may be turned off (actually cycling through: off - on - reactivate tag - off - ...) – Michael Roland Apr 06 '16 at 07:10
  • yes it's great it seems to work and you definitely helped. I have accepted your answer and voted you up. I hope this post will help some other people, despite an idiot on this forum who voted my question -1. Cheers, mate – Clararhea Apr 06 '16 at 14:26