cancel
Showing results for 
Search instead for 
Did you mean: 

USB CCID Configuration on STM32WB55 MCU

Sjain
Associate III

Hi ST Support Team,

I am reaching out regarding an issue I have encountered while attempting to utilize USB CCID functionality on the STM32WB55 MCU. Recently, I integrated the CCID driver from the following link into my project.
https://github.com/STMicroelectronics/stm32_mw_usb_device/tree/master/Class/CCID

Following the integration, I successfully configured the USB device, and my system(windows PC) can now detect the STM32WB MCU as a smart card reader.

Sjain_0-1711907270872.png

However, upon further testing, I encountered an unexpected behavior: when attempting to communicate with the smart card reader using a Python script, the STM32WB USB port is detected as a Virtual COM port rather than a smart card reader. As a result, I am unable to establish communication with the MCU via script.
I am reaching out to kindly request your assistance in resolving this issue. Could you please provide guidance or solutions to ensure that the STM32WB MCU is correctly detected as a smart card reader and able to communicate with application?

Any support or insights you can provide on this matter would be immensely appreciated.

Thank you for your attention to this matter.

Best regards,
sjain

 

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hello @Sjain 

"Cannot Unpack Non-iterable NoneType Object" error in Python is not directly related to STM32 USB functionality. The error is specific to Python. Your question was about USB port detected as VCP when using Python script!

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.


I'm out of offce with limited access to my emails.
Happy New Year!

View solution in original post

4 REPLIES 4
Mohamed_AYED
Associate III

Hi @Sjain , you can try with USBX middleware (AzureRTOS) it support CCID Class in baremetal and RTOS (Threadx) 

you can flow the example delivred with STM32H723

https://github.com/STMicroelectronics/x-cube-azrtos-h7/tree/main/Projects/NUCLEO-H723ZG/Applications/USBX/Ux_Device_CCID

 

BR

 

FBL
ST Employee

Hello @Sjain 

Sharing you python script would be helpful to investigate. I guess this issue depends on pyusb library. Maybe these examples STMicroelectronics/stm32ai-datalogger at 0ba92ced44248e606a5cc68139fdfdc84489fa17 (github.com) could be helpful.

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.


I'm out of offce with limited access to my emails.
Happy New Year!
Sjain
Associate III

Thanks @Mohamed_AYED  and @FBL  for the reply.

I just wanted to give you and update that on python script my device able to detect as smart card reader but after that no communication happen. I'm sharing the python script here which I used for my testing. 

from smartcard.System import readers
from smartcard.scard import SCARD_PROTOCOL_T0
from smartcard.CardConnection import CardConnection
from smartcard.Exceptions import CardConnectionException

def test_apdu_command(apdu_command):
    try:
        # Get a list of available smartcard readers
        reader_list = readers()
        
        if reader_list:
            print("Smartcard reader(s) detected:")
            for reader in reader_list:
                print(reader)
                # Create a connection to the reader
                card_connection = CardConnection(reader)
                
                # Connect to the card
                try:
                    card_connection.connect()
                    print("Connected to smart card successfully.")
                    
                    # Send the APDU command to the card
                    response, sw1, sw2 = card_connection.transmit(apdu_command)
                    
                    # Print the response
                    print("Response:", response)
                    print("Status words:", sw1, sw2)
                    
                except CardConnectionException as e:
                    print("Error connecting to smartcard:", e)
                
                finally:
                    # Disconnect from the card
                    card_connection.disconnect()
                    print("Disconnected from smart card.")
            
        else:
            print("No smartcard readers detected.")
    except Exception as e:
        print("Error:", e)

if __name__ == "__main__":
    # Example APDU command (SELECT command)
    # You can replace this with any other APDU command you want to test
    apdu_command = [0x00, 0xA4, 0x04, 0x00, 0x00]  # SELECT command for the master file
    test_apdu_command(apdu_command)

 After run the script I received the response of connected to smart card and name is also correct. But after that no data received on STM32WB55 MCU configured as smart card reader. 
"Error: cannot unpack non-iterable NoneType object" is occurred because no response received from device.
I'm confused because on connection request and transmit data no event generated on MCU.

Sjain_0-1712085916095.png

Can you please suggest where I'm doing wrong ? CCID is new for me so not having much information about it.
Any support you provide will really helpful to me.

Thanks,
SJain

FBL
ST Employee

Hello @Sjain 

"Cannot Unpack Non-iterable NoneType Object" error in Python is not directly related to STM32 USB functionality. The error is specific to Python. Your question was about USB port detected as VCP when using Python script!

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.


I'm out of offce with limited access to my emails.
Happy New Year!