cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to write more than 4 blocks of data to St25 NFC type 5 tags in iOS

RRN
Associate

I'm working on an iOS app that can read and write to st25 type 5 tags . While writing, i am able to write only 4 blocks at a time using writeMultipleBlocks() method. NFCError occurs if I write more than that.

mISO16593Tag.writeMultipleBlocks(requestFlags: [.address,.highDataRate], blockRange: blockRange, dataBlocks: dataBlock){error in

      if let error = error as? NFCReaderError {

        print("\(error.localizedDescription)")

      }

      else{

        print("write successfull")

      }

       self.semaphoreFunctionSignal()

    }

I tried using stm's NFCTap App, it is also giving me an 'invalid response error' if I write more than 4 blocks of data.

Can someone help to me to understand why this is happening in iOS. The writing works perfectly fine on android.

I am using ST25DV04K NFC tag and have tested on iPhone11 and iPhone8

Edit:

I also tried splitting data and write it as a single block in a loop . But sometimes the write fails overwriting some of the blocks with 00 00 00 00 which leads to corrupted information.

func writeSingleBlock(blockNumber:UInt8,dataBlock:Data){
 
        self.semaphoreFunctionWait()
 
        mISO16593Tag.writeSingleBlock(requestFlags:[.address,.highDataRate] , blockNumber: blockNumber, dataBlock: dataBlock){ error in
            
            if let error = error as? NFCReaderError {
                print("(error.localizedDescription)")
            }
            else{
               print(“write successful�?)
            }
	self.semaphoreFunctionSignal()
 
        }
    }

My use case is to write minimum 6 blocks of data without causing any data corruption.

Does anyone have any suggestions to handle this case?

1 ACCEPTED SOLUTION

Accepted Solutions
JL. Lebon
ST Employee

Hello RRN,

As a matter of fact, the ST25DV can write up to 4 blocks max at a time in the Write Multiple Blocks command.

Concerning your issue with blocks with value 00000000, it looks like a tearing issue.

To understand, I need to explain how data is programmed into an EEPROM.

Unlike a RAM, in an EEPROM data must first be erased and then re-programmed with the new value. Erase state in ST25DV is 00 (in other EEPROM it can be FF).

When you write a block in ST25DV eeprom, it happens in 3 phases: first, block erase, then, block programming (only '1' are programmed), then verify.

If you end-up with a block with value 00000000 when you expect something different, it is probably because the Write Single Block command has been interrupted between the erase phase and the programming phase. The tag has started to erase the block and then RF field has been removed and the tag had no power to finish the programming. This is called "tearing".

This may happen if the phone is too far from the tag and/or moving too much during write.

In case of tearing, you get no answer from the Write Single Block command.

If no response has been received, it means the Write Single Block command has failed and you must retry the write to ensure the data is correctly written.

If the Write Single Block command gives you a response with the "No error" flag, then you are sure that the block has been correctly programmed.

Best regards.

View solution in original post

3 REPLIES 3
Ulysses HERNIOSUS
ST Employee

Hi RRN,

For ST25DV04K I find a remark in DS(DS10925); "ST25DVxxx supports up to 4 blocks".

BR, Ulysses

Hi Ulysses,

Thanks for the information.

I also tried splitting data and write it as a single block in a loop . But sometimes the write fails overwriting the some of the blocks with 00 00 00 00 which leads to corrupted information.

func writeSingleBlock(blockNumber:UInt8,dataBlock:Data){
 
        self.semaphoreFunctionWait()
 
        mISO16593Tag.writeSingleBlock(requestFlags:[.address,.highDataRate] , blockNumber: blockNumber, dataBlock: dataBlock){ error in
            
            if let error = error as? NFCReaderError {
                print("(error.localizedDescription)")
            }
            else{
               print(“write successful�?)
            }
	self.semaphoreFunctionSignal()
 
        }
    }

My use case is to write minimum 6 blocks of data without causing any data corruption.

Do you have any suggestions to handle this case?

JL. Lebon
ST Employee

Hello RRN,

As a matter of fact, the ST25DV can write up to 4 blocks max at a time in the Write Multiple Blocks command.

Concerning your issue with blocks with value 00000000, it looks like a tearing issue.

To understand, I need to explain how data is programmed into an EEPROM.

Unlike a RAM, in an EEPROM data must first be erased and then re-programmed with the new value. Erase state in ST25DV is 00 (in other EEPROM it can be FF).

When you write a block in ST25DV eeprom, it happens in 3 phases: first, block erase, then, block programming (only '1' are programmed), then verify.

If you end-up with a block with value 00000000 when you expect something different, it is probably because the Write Single Block command has been interrupted between the erase phase and the programming phase. The tag has started to erase the block and then RF field has been removed and the tag had no power to finish the programming. This is called "tearing".

This may happen if the phone is too far from the tag and/or moving too much during write.

In case of tearing, you get no answer from the Write Single Block command.

If no response has been received, it means the Write Single Block command has failed and you must retry the write to ensure the data is correctly written.

If the Write Single Block command gives you a response with the "No error" flag, then you are sure that the block has been correctly programmed.

Best regards.