cancel
Showing results for 
Search instead for 
Did you mean: 

Why does rfalST25xVPollerWritePassword() fail on ST25TV02KC?

MERSI
Associate III

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2
Brian TIDAL
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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