2025-06-30 1:43 PM
Hi everyone,
I'm working on writing the configuration password (PWD_CFG, 0x00) to an ST25TV02KC NFC tag using the ST25R3916B reader and the RFAL middleware (X-CUBE-NFC6). I am following the standard procedure:
Open a CONFIG security session using PresentPassword (XORed Password)
Generate a new XOR-coded password using GetRandomNumber
Call WritePassword to write a new password (in this case, still 0x00..0x00 for testing)
Here's the code I use:
if (generateXorPassword(uid, pwd_cfg, xorPwd) != RFAL_ERR_NONE) goto ERROR_RED_LED;
if (rfalST25xVPollerPresentPassword( // 0x00 = PWD_CFG
RFAL_NFCV_REQ_FLAG_DEFAULT | RFAL_NFCV_REQ_FLAG_ADDRESS,
uid,
0x00, // PWD_CFG
xorPwd, sizeof(xorPwd)
) != RFAL_ERR_NONE)
{
goto ERROR_RED_LED;
}
// CONFIG Security Session is now open!
{
// Change PWD_CFG (0x00)
if (generateXorPassword(uid, pwd_cfg, xorPwd) != RFAL_ERR_NONE) goto ERROR_RED_LED;
if(rfalST25xVPollerWritePassword(
RFAL_NFCV_REQ_FLAG_DEFAULT | RFAL_NFCV_REQ_FLAG_ADDRESS,
uid,
0x00, // PWD_CFG
xorPwd,
4
) != RFAL_ERR_NONE) goto ERROR_RED_LED;
}
Despite the session being open, the WritePassword() command always fails (with return code 5, RFAL_ERR_REQUEST).
The PresentPassword() call succeeds, and I can confirm that the session is active.
What could be the reason that WritePassword() is failing?
Any help or ideas would be greatly appreciated!
Thanks in advance.
Solved! Go to Solution.
2025-06-30 10:26 PM - edited 2025-06-30 10:58 PM
@Brian TIDAL Thank you
It is 12h (Security Session is closed). But I just opened the security session on line above (returns no error) .
I've found the problem. In the generateXORPassword I am calling GetRandomNumber. This function deactivates also the rf field for a while. This ends the security session and therefore I could not write a new password. I am calling the random number by my own and now it works.
2025-06-30 2:29 PM
Hi,
set a breakpoint in rfalNfcvParseError. What is the err value in rfalNfcvParseError when the WritePassword fails? See WritePassword error codes in the datasheet.
As a side comment, RFAL_NFCV_REQ_FLAG_ADDRESS is automatically set when the uid parameter is non-null in the various APIs. Thus, it is not needed to set it on user side.
Rgds
BT
2025-06-30 10:26 PM - edited 2025-06-30 10:58 PM
@Brian TIDAL Thank you
It is 12h (Security Session is closed). But I just opened the security session on line above (returns no error) .
I've found the problem. In the generateXORPassword I am calling GetRandomNumber. This function deactivates also the rf field for a while. This ends the security session and therefore I could not write a new password. I am calling the random number by my own and now it works.