cancel
Showing results for 
Search instead for 
Did you mean: 

USB CDC device not compiling properly

Cheyne
Visitor

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:

  1. 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.

  2. The structure USBD_HandleTypeDef is not recognized in some compilation units, leading to cascading errors.

  3. 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.

  4. Even after ensuring all relevant include paths (e.g., Middlewares/ST/...) are configured correctly in the project, the problem persists.

  5. I found there is the issue of circular header dependencies, e.g. usbd_ioreq.h has #include "usbd_core.h". However, usbd_core.h has #include "usbd_ioreq.h".

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,

2 REPLIES 2
TDK
Super User

Please include the IOC file used to generate this code.

If you feel a post has answered your question, please click "Accept as Solution".

This is my .ioc file. Please check!