2025-07-21 5:41 AM
Product: STM32F401VET6
Firmware Package: STM32Cube_FW_F4 V1.28.0
Tool: STM32CubeIDE (latest version)
Description:
Hi!
I’m currently working on a USB CDC device project using the STM32F401VET6 microcontroller with the STM32Cube_FW_F4 firmware package (V1.28.0) in STM32CubeIDE.
I have encountered a series of issues when enabling USB_DEVICE with the CDC class. Specifically:
The generated project fails to compile due to errors, such as USBD_ClassTypeDef being undefined in some modules (e.g., usbd_ioreq.h), even though usbd_def.h is included and USBD_ClassTypeDef is defined in usbd_def.h.
The structure USBD_HandleTypeDef is not recognized in some compilation units, leading to cascading errors.
There seem to be conflicts or inconsistencies when including usbd_def.h, especially between header files like usbd_ctlreq.c, usbd_core.c, and usbd_ioreq.c.
Even after ensuring all relevant include paths (e.g., Middlewares/ST/...) are configured correctly in the project, the problem persists.
I suspect that there may be version mismatches, circular header dependencies, or missing default initializations with the USB stack in this firmware version.
Could you kindly:
Confirm if STM32Cube_FW_F4 V1.28.0 supports USB CDC correctly for STM32F401?
Provide any known solutions or a verified example for USB CDC on STM32F401 using CubeMX-generated code?
I would be grateful if you could help clarify whether this issue is known and how to resolve it.
Best regards,
2025-07-21 5:47 AM
Please include the IOC file used to generate this code.
2025-07-21 6:01 AM
2025-07-30 9:01 AM
Hi @Cheyne
First, I recommend upgrading to latest version of CubeF4 V1.28.2.
Second, I regenerated the code using your IOC file with latest version STM32CubeIDE without compiling issues.
So, check include paths : it seems some MW files are missing in your project : usbd_cdc.h ..
Sometimes the compiler cache may cause stale or incomplete builds. Perform a full clean of the project followed by a rebuild to ensure all files are correctly compiled and linked.
If still having issue, you can share your full project.
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.