2019-02-22 03:29 AM
Hi,
i'm trying to perform a communication with an ISO14443-A smart card using the X-NUCLEO-NFC06A1 expansion board. The smart card supports the following bit rate: 106, 212, 424 and 848 kbit/s according to the ATS received. If i negotiate with the smart card a 848 kbit/s bit rate both in transmission and reception and i try to send an APDU, the rfal library returns an ERROR FRAMING in reception. In particular the error is returned by rfalTransceiveRx() method implemented in rfal_rfst25r3911.c file:
case RFAL_TXRX_STATE_RX_WAIT_RXE:
irqs = st25r3911GetInterrupt( (ST25R3911_IRQ_MASK_RXE | ST25R3911_IRQ_MASK_FWL | ST25R3911_IRQ_MASK_EOF) );
if( irqs == ST25R3911_IRQ_MASK_NONE )
{
/*******************************************************************************/
/* REMARK: Silicon workaround ST25R3911B Errata #1.1 */
/* ST25R3911 may indicate RXS without RXE afterwards, this happens rarely on */
/* corrupted frames. */
/* SW timer is used to timeout upon a missing RXE */
if( rfalTimerisExpired( gRFAL.tmr.RXE ) )
{
gRFAL.TxRx.status = ERR_FRAMING;
gRFAL.TxRx.state = RFAL_TXRX_STATE_RX_FAIL;
}
/*******************************************************************************/
break; /* No interrupt to process */
}
It seems that the chip does not receive the end of frame and a timer interrupt occurs. If, instead, the bit rate is set to 424 kbit/s no problem occurs. Is there someone could explain me why this happens? Moreover, where i can find the ST25R3911B Errata #1.1?
Thanks in advance. Best regards,
Pierluigi
Solved! Go to Solution.
2019-03-13 07:47 AM
Summary of the communication in private channel:
Issue disappears when going to optimization level -O3. At high bitrates it is also advisable to increase SPI speed to e.g. 4MHz.
2019-02-25 05:16 AM
Hi Pierluigi,
Regards, Ulysses
2019-02-27 12:11 AM
Hi Ulysses,
thanks for your answer.
I tried also to change the SPI prescaler thinking that the MCU could not observe the IRQ signal, but nothing has changed.
Regards
Pierluigi
2019-02-27 01:58 AM
Hi Pierluigi,
I would like to analyze this further. I do have an STM32L053 Nucleo-64 and of course also an X-NUCLEO-NFC05A1.
Can you please do the following things:
Regards, Ulysses
P.S.: You can can also send this stuff via PM
2019-02-28 12:29 AM
2019-02-28 01:19 AM
Hi Pierluigi,
this makes it difficult for me to analyze. I did now take the ST25R3911B-DISCO and verified with a a Desfire card that 848 is operational: ISO14443A tab, activate to 848 using PPS, going to Debug tab and press send command returns some APDU error code (6700).
Then I did load the ST25R3911B-DISCO fw on X-NUCLEO-NFC05A1+ STM32L476 Nucleo-64 + USB cable attached to the proper pins: The Desfire card can again be read @848.
Don't know what more I could do to analyze your issues.
Regards, Ulysses
2019-02-28 03:04 AM
Hi Ulysses,
I'm sorry but I'm working on a company project and i am not allowed to provide project code or .hex file.
Anyway, I can provide you the SPI initialization as well as the steps performed for the ST25R3911B initialization and smart card activation.
SPI CONFIGURATION
static void MX_SPI1_Init(void)
{
/* SPI1 parameter configuration*/
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 7;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}
}
After SPI initialization I make the following call to initialize the rfal and to perform antenna calibration:
When a ISO 14443 A smart card is put in the field, first I perform the anticollision and then i call the proper rfal routine for the activation sequence as follows:
rfalIsoDepPollAHandleActivation(ISO14443A_RTAS_FSDI_256, RFAL_ISODEP_NO_DID, RFAL_BR_848, &isoDepDev);
Once activated, I try to send an APDU to the card in the following way:
iso14443TransmitAndReceive(&APDU, sizeof(APDU), &rxBuff, sizeof(rxBuff), &actrxlength, isoDepDev.FWT);
At this point RFAL returns ERR_FRAMING.
Reguards, Pierluigi
2019-02-28 04:01 AM
Hi Pierluigi,
I fear I have done what I can do under the circumstances. If you cannot provide me at least a binary file - best the source - I cannot give you meaningful recommendations. My experiments using ST25R3911B-DISCO essentially perform the same steps as you show above. Maybe you could strip your project of your IP and only leave the above sequence with a dummy APDU showing the behavior.
The behavior can be related to many things:
Otherwise you could go through official support channels and get up an NDA with ST and possibly then share your project with ST.
Regards, Ulysses
2019-02-28 11:25 PM
Hi Pierluigi,
I have one idea what it could be, would somehow fit to a an interrupt being lost. We have discovered this fundamental problem in a different project.
Can you please try to change the locking inside platform.h:
extern uint8_t globalCommProtectCnt;
#define platformProtectST25R391xComm() do{ globalCommProtectCnt++; __DSB();NVIC_DisableIRQ(EXTI0_IRQn);__DSB();__ISB();}while(0)
#define platformUnprotectST25R391xComm() do{ if (--globalCommProtectCnt==0) {NVIC_EnableIRQ(EXTI0_IRQn);} }while(0)
#define platformProtectST25R391xIrqStatus() platformProtectST25R391xComm()
#define platformUnprotectST25R391xIrqStatus() platformUnprotectST25R391xComm()
and in e.g. main.c:
uint8_t globalCommProtectCnt = 0;
Background of this fix is that shortly after NVIC_DisableIRQ() the ISR can still execute. Compare below:
Regards, Ulysses
2019-03-01 12:51 AM
Hi Ulysses,
I have changed the locking inside platform.h as you said, but I still have the same behavior.
A strange thing is that I have used another ISO14443 A smart card that supports 848 kb/s bit rate and the communication is performed correctly. I think the problem is with the electronic passports.
Regards, Pierluigi