Skip to main content
benjamin Gräf
Associate III
April 29, 2019
Question

CubeMX code not working with USB

  • April 29, 2019
  • 5 replies
  • 3822 views

Hello!

I have project created with CubeMX. I coded a lot there and then I wanted to add a USB CDC device with CubeMX. After code generation I compiled the project and I got an error message:

../Inc/usb_device.h:61:22: fatal error: usbd_def.h: No such file or directory

I did some research and some had the problem that the path name hat spaces in it. That was not the case with my path. I thought my path was too long maybe, so I changed the name of the folder created by CubeMX "STM32_USB_Device_Library" to "STM32_USB". Then this error message disapeared but another one appeared.

../Inc/usbd_audio_if.h:59:68: fatal error: ../Middlewares/ST/STM32_USB/Class/AUDIO/Inc/usbd_audio.h: No such file or directory

I don´t know what to do anymore and why is this audio.h file needed anyway for a CDC USB device?

Any help is welcome

This topic has been closed for replies.

5 replies

Mon2
Senior III
April 29, 2019

Which Target could or Target kit?

Which compiler?

Khouloud ZEMMELI
ST Employee
April 29, 2019

​Hello @benjamin Gräf​ , could you please share your ioc file ?

Best Regards,

Khouloud.

benjamin Gräf
Associate III
April 29, 2019

Ok I am using a STM32F303 with the Atollic TrueStudio IDE.

The ioc file is attached.

best regards benjamin

Khouloud ZEMMELI
ST Employee
April 29, 2019

​I generate the code with both True Studio and IAR, and I did not find any error, please use the latest CubeMX version (5.2.0).

Best Regards,

Khouloud.

benjamin Gräf
Associate III
April 29, 2019

I did upgrade to the latest version. Did not change anything.

Best regards,

Benjamin

Mon2
Senior III
April 30, 2019

Hi @benjamin Gräf​ , my suggestion is for you to start a fresh project with your latest toolchain.

Apply only the USB CDC IP -> build and test. Do not insert any other of your custom code. Does the basic (wizard generated) USB CDC IP work on your target hardware?

Is the CPU on some custom hardware or using an official ST kit? If ST kit, which one?

Can you share any details of the wiring of the USB interface with your CPU? A partial schematic will be of help.

Also, review this thread and please post back your results:

https://community.st.com/s/question/0D50X00009fFsXXSA0/stm32f303-usb-cdc-tutorial

benjamin Gräf
Associate III
April 30, 2019

Hi, the CPU is on a custom hardware. I did build a fresh project with nothing but the USB code. Testing will be done next week due to hardware deliverie issues.

Anyway i am able to compile now, which was the problem. Getting it to work should be straight forward since I already have done this once.

best regards,

Benjamin

HHuan.2
Visitor II
April 1, 2021

Hi Benjamin,

I experienced the same problem of losing usb driver "usbd_def.h" automatically created by CubeMX. Before getting crazy, I configured IO for output. Miracle is happening, error disappeared! It seems the IDE has some bugs. Don't waste more time on this supid tools