STM32 USB Host CDC class: USBH_FindInterface issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-18 6:01 AM
Hi,
I am using STM32G0B1CBTX and used the STM32CubeMX to configure USB host with CDC class. When connecting a CDC device, I noticed that it passes the enumeration and configuration but fails to find the interface used. More specifically, it fails the function
interface = USBH_FindInterface(phost, COMMUNICATION_INTERFACE_CLASS_CODE, ABSTRACT_CONTROL_MODEL, COMMON_AT_COMMAND);
at line 158 of the usbh_cdc.c file. Upon deeper inspection, I noticed that the protocol value passed to this function using the macro COMMON_AT_COMMAND is set to 1 while the two interface descriptors I receive from the device both have their interface protocol set to 0. If I manually edit this and use the NO_CLASS_SPECIFIC_PROTOCOL_CODE macro (value = 0), everything works correctly and I can send and receive data. This part of the library should be fixed and no user editing should be needed. So my question is, is their something wrong with the device's descriptors or can the first call to the USBH_FindInterface be set to have no specific protocol instead of using the COMMON_AT_COMMAND one?
Solved! Go to Solution.
- Labels:
-
STM32G0 Series
-
USB
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-28 7:18 AM
Hi @DDeba.1
Thank you for reporting! Indeed, after sharing this with our experts, this could be customized since this middleware was intended to find interface only for COMMON_AT_COMMAND. However, the fix could take some time.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-21 1:24 AM
Hi @DDeba.1
Are you using a reference board or custom board? Would you attach the project to reproduce on my end?
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-21 5:00 AM
Hi @FBL,
Find attached what requested. Note that this is basically the CubeMX generated code where I only changed line 158 of the usbh_cdc.c file such that the last argument of the USBH_FindInterface is NO_CLASS_SPECIFIC_PROTOCOL_CODE.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-02-28 7:18 AM
Hi @DDeba.1
Thank you for reporting! Indeed, after sharing this with our experts, this could be customized since this middleware was intended to find interface only for COMMON_AT_COMMAND. However, the fix could take some time.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-02 11:44 PM
Hi @FBL,
Thanks for clarifying. In this regards, is there a way I can make this change without having the STM32CubeMX overwriting my change every time I regenerate my code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-03 3:15 AM
Hi @DDeba.1
Unfortunately, no possible workaround in such case, since USBH_FindInterface() is copied from MW layer directly. You need to overwrite it every time you regenerate the code.
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.
