2023-12-21 06:53 AM
Hi @Rene Lenerve @JL. Lebon @Brian TIDAL
So basically I am connecting ST25DV64KC tag with MKE14F512VLL16 based controller and I want to write on the tag through i2c but as I am sending data using I2c write and as I am checking using Logic analyzer it showing its writing and sending ack but when I am checking using st nfc tap app options read memory there nothing was written can you guys confirm few things like is tag slave device address is 0xA6 for writing on tag and is it mandatory to give memory address or it will assume 0000h as base address and write on it and to write on tag do we need to send one byte at a time .Can you please provide details about i2c communication to write on tag by the way I have already gone through the datasheet.
Solved! Go to Solution.
2024-02-14 08:53 AM
Hello,
Sorry for my late answer, I missed your question.
We do have the M24SR in which RF passwords can be modified from I2C interface. The M24SR is an NFC type 4 (ISO14443), so quite different from the ST25DV though.
Best regards.
2023-12-21 07:23 AM
Hello,
I will try to answer to your questions one by one.
"tag slave device address is 0xA6 for writing on tag": yes, that's it to write the user memory. But be aware that this includes the R/W bit, so do not append the R/W bit to this address.
"is it mandatory to give memory address or it will assume 0000h as base address": yes, for a write it is mandatory to provide the 2 Bytes of the memory address.
"to write on tag do we need to send one byte at a time": if you write in user memory (not system configuration memory or registers) you can write from 1 up to 256 Bytes at a time.
A correctly formed I2C write command to user memory should be like this:
Start/0xA6/ack/MSB_memory_address/ack/LSB_memory_address/ack/data_byte1/ack/data_byte2/ack/.../last_data_byte/ack/Stop
Please check if your I2C command is formatted in this way.
Then please try to read back the data from the I2C interface to ensure it has been correctly written. The I2C read command would be:
Start/0xA6/ack/MSB_memory_address/ack/LSB_memory_address/ack/Start/0xA7/ack/data_byte1/ack/data_byte2/ack/.../last_data_byte/Nack/Stop (please note that after 0xA7/ack/, all data bytes are sent by the ST25DV and all ack are sent by the MCU).
Then, if you can read the data from I2C, you can try again to read it from RF.
Best regards.
2023-12-22 05:52 AM
Hello @Rene Lenerve @JL. Lebon @Brian TIDAL
First of all thank you for your reply so I am using I2C write and initialization commands to write on the tag so like-
I2c__Initialize(I2C0 ,I2C_100KHZ ,I2C_ADDR_7BITS ,0xA6 );
Then I used something like I2Cmemorywrite function where passing --------
params.i2c = I2C0;
params.deviceAddress = 0xA6;
params.memoryAddress = 0x03E8;
params.memoryAddressSize = 2;
params.dataBuffer = (uint8[]){0x05};
params.dataSize = 1;
parameter and now after that I am sending like this ------------
void I2C_MemoryWrite(I2C_MemoryWrite_Params *params) {
// Send start condition
// Send device address with write bit
uint8 deviceAddress = (params->deviceAddress << 1) | 0; // Set LSB to 0 for write
// Send memory address
for (uint8 i = 0; i < params->memoryAddressSize; ++i) {
// I2C_SendByte exists to send a byte
I2C_SendByte(params->i2c, (params->memoryAddress >> (8 * (params->memoryAddressSize - 1 - i))) & 0xFF);
}
// Send data
for (uint16 i = 0; i < params->dataSize; ++i) {
I2C_SendByte(params->i2c, params->dataBuffer[i]);
}
// I2c__Disable(params->i2c);
}
BOOL_TYPE I2C_SendByte(I2C_ENUM_TYPE i2c, uint8 byte) {
// Assuming a proper implementation of I2c_Write
uint8 buffer[1];
buffer[0] = byte;
status = I2c__Write(i2c, 0xA6, buffer, 1);
}
So in logic analyzer I am getting ack from device and also its showing writing random data in some random address but if we try to read memory using the st nfc app nothing is there .So i am sharing some logic analyzers pic with you guys if you can suggest about what can be the problem it will be helpful--
2023-12-22 06:54 AM
Hello,
Sorry, but the logic analyzer traces don't help as we can't see the I2C frame at bits or even Byte level: "write to 0x02 ack data:0x12". What does it mean ? Do you write to I2C slave address 0x02? This is not ST25DV64K address...
Nevertheless, I found something that looks wrong in your code:
"params.deviceAddress = 0xA6
uint8 deviceAddress = (params->deviceAddress << 1) | 0; // Set LSB to 0 for write"
As said in my previous post: "be aware that this (0xA6) includes the R/W bit, so do not append the R/W bit to this address".
0xA6 already includes the write bit. In your code, you end up with deviceAddress=0x4C when it must be 0xA6.
You must either set params.deviceAddress = 0x53 if you want to shift it and happen the Write bit, or keep 0xA6 and do deviceAddress = params->deviceAddress & 0xFE.
Did you try to read back from I2C what you have written? I would do this first, since reading from RF is just introducing a new unknown in the equation.
Best regards.
2023-12-23 07:07 AM - edited 2023-12-26 03:14 AM
Hello @Rene Lenerve @JL. Lebon @Brian TIDAL
Again thank you for your speedy response but as you can see in the above code both for sending memory address and data I have written i2c send byte function where I have put slave address as 0xA6 so is it doesn't matter for that left shift .
BOOL_TYPE I2C_SendByte(I2C_ENUM_TYPE i2c, uint8 byte) {
uint8 buffer[1];
buffer[0] = byte;
I2c__Write(i2c, 0xA6, buffer, 1);
}
another way I tried to write on tag ---
any other changes you think I need to make to write on the tag
2024-01-08 02:48 AM
Hi PoolBear,
You were mentioning in you first post that you received an ACK at each write, but in you screenshot it seems to be an error response (not easy to read the answer). Does this response error is due to Debugger stop or sent when in run mode too.
If you could capture with the logic analyzer a single write sequence and zoom in to see the SDA/SCL bits to see in more detail what is happening.
Another test could be to write some data with ST25 NFC Tap App (to ease operation it could be at address 0x000C) and try to read it through I²C.
Kind Regards.
2024-01-18 06:49 AM
Hello @Rene Lenerve @JL. Lebon @Brian TIDAL
hey guys I have been able to write on the tag successfully now if it is possible can you guys provide any information how can I lock this tag so that no one can write on the tag using nfc only reading of the tag will be possible using NFC app.
2024-01-19 12:08 AM
Hello PoolBear,
For RF access protection, please refer to those two messages' threads:
Solved: Re: How to stop overwriting on NFC Tag of ST25DV64... - STMicroelectronics Community
Solved: Re: Secure st25dv04k from RF write - STMicroelectronics Community
Best regards.
2024-01-19 03:32 AM
Hello @Rene Lenerve @JL. Lebon @Brian TIDAL
Hey thank you for your speedy response I have been able to stop writting on the tag by writting on RFA1SS=05h.Now can you please share details on how to change password 1 which is by default 00h .
2024-01-19 05:16 AM
Hello,
Glad that you have been to protect the tag.
To change the password value:
- first present the current password to open the security session. This is done using the "Present password" command. Parameters are the password number you want to change and the current password value (which is all 00 by default).
- then you can change the password. This is done using the "Write password" command. Parameters are the password number (same as the one used in the Present password command) and the new password value. Change is immediate. Do not remove the RF field between the two commands or the security session will be closed and you will have to present the password again.
Two things to note:
- the password number parameter: this should be the password you want to change, which is probably the password you are using to protect your memory access.
- when writing the new password, be sure that the RF field is stable (reader close to the tag, no moving). In fact, if the RF field is removed during write password, the new password can be corrupted and there is no way to recover it.
Best regards.