cancel
Showing results for 
Search instead for 
Did you mean: 

CCID USBD transfer block (splitting)

Ayoub-Marghoub
Associate

Hello,

I'm currently preparing the firmware for a USB NFC reader (CCID). I'm working with the STM32F103 MCU and the ST25R3916 NFC reader.
The STM32F103 MCU is programmed on a CCID USB device using the CCID USBD driver provided by STM32. The MCU acts as the mediator between the computer and the ST25R3916 NFC reader. It takes the APDU command sent by the computer and transfers it to the NFC reader, and takes the NFC reader's response and transfers it to the computer using the SC_Itf_XferBlock() function.

The STM32F103 MCU supports usb full-speed, this means that the maximum amount of data to be transferred to the computer is 64 bytes. If you want to transfer data larger than 64 bytes, you transfer it using chunk-by-chunk methods.

To transfer 253-byte data, the splitting is as follows:
5 chunks: chunk 1 (54 bytes of data with 10 bytes of header), chunk 2 (64 bytes of data), chunk 3 (64 bytes of data), chunk 4 (64 bytes of data), and chunk 5 (7 bytes).

The issue is that when I try to transfer 253 bytes of data using splitting, the computer finishes the transfer directly after chunk 4 and doesn't wait for chunk 5, knowing that chunk 4 is 64 bytes long, and I don't send any 0s after chunk 4.
This problem is related to my firmware (CCID USB driver). Can you help me resolve this issue?
Thanks in advance.

3 REPLIES 3
FBL
ST Employee

Hi @Ayoub-Marghoub 

Did you refer to this example provided on H7?

It seems the sum is more than 253Bytes! 4 chunks already 256Bytes.

 

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.


Ayoub-Marghoub
Associate

The first ten bytes of the first chunk are reserved for the transfer header; 54 bytes remain for the data.
The first chunk contains 54 bytes of data, and the following three chunks contain 64 bytes of data, totaling 246 bytes of data. To send 253 bytes of data to the computer, another chunk is needed to contain the remaining seven bytes.
When I capture the transfers with Wireshark software, I find that the computer only received 246 bytes of data. It didn't wait for the fifth chunk; it completed the transfer directly after receiving the fourth chunk.

FBL
ST Employee

Hi @Ayoub-Marghoub 

 

The issue is more likely linked to your firmware.

FBL_0-1754059525664.png

 

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.