Skip to main content
Graduate II
June 30, 2025
Solved

Why does rfalST25xVPollerWritePassword() fail on ST25TV02KC?

  • June 30, 2025
  • 1 reply
  • 312 views

 

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:

  1. Open a CONFIG security session using PresentPassword (XORed Password)

  2. Generate a new XOR-coded password using GetRandomNumber

  3. 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.

    This topic has been closed for replies.
    Best answer by MERSI

    @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. 

    1 reply

    Technical Moderator
    June 30, 2025

    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

    MERSIAuthorAnswer
    Graduate II
    July 1, 2025

    @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.