cancel
Showing results for 
Search instead for 
Did you mean: 

Has anyone managed to get a USBX audio device working on STM32 MCU? Do any official examples exist?

BKlus.1
Associate II

I am trying to implement a USB audio device using ThreadX/AZURE and USBX, mostly by following instructions from: https://docs.microsoft.com/en-us/azure/rtos/usbx/usbx-device-stack-supplemental-2#usb-device-audio-class It's been pretty frustrating, unfortunately. My device enumerates properly but then I get the dreaded "This device cannot start. (Code 10)" message.

It is always easier to start with a known working example and modify it as needed than it is to write something from scratch. Can someone point me into the right direction? 

Thanks!

Bart

7 REPLIES 7
Imen.D
ST Employee

Hello @BKlus.1​ and welcome to the Community 🙂

What board are you using? Custom board?

Make sure to update the ST-Link Firmware and check if the USB cable is connected properly.

I also advise you to follow this FAQ: USB device not recognized.

Hope this helped you!

When your question is answered, please close this topic by choosing Select as Best.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
BKlus.1
Associate II

Hi Imen,

I tried using a STM32f4-DISCOVERY board first and it did not work at all. I attribute it to bad hardware - I have two of these boards and they both have been very unreliable. For example, HSE randomly starts - or it does not.

Anyway, I gave up on these boards and have been using a custom board with a STM32F407 instead. This board has, in the past, run the older (non-USBX) version of ST USB stack with no problems. In other words, I have reasons to believe that my hardware is not to blame. The ST-Link firmware is up to date and the USB cable appears to be connected properly. 

I checked the FAQ and tried increasing my heap size to 0x4000. This did not solve the problem.

It would be very helpful if there was an example I could look like. I bet it is some callback that I need to implement, or maybe USBX expects some particular endpoints to be used?

Thanks!

Bart

Hi @BKlus.1​ ,

Please check this post with same issue and let me know if this solved your issue.

If not, I will try to contact expert internally.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
K_Szynalski
Associate III

It's not only about the USBX Device Audio class, but it's a general remark. When I import the existing project into CubeIDE workspace, I only get the minimum set of files. The most important source files are not available or they are replaced with templates when I (re)generate code, so it takes time and effort to copy the content from the examples, to fix compilation errors. Maybe I don't know how to do this right, but I tried different options with the same result again, and again. ST Team, could you please take a look into this?

@BKlus.1​ What I found in examples for STM32H735G-DK was the incorrect setting for the memory byte pool. The result was 'not enough memory' error typically returned during the last thread creation. The next issue was the wrong PID assigned (0x5740) in device descriptor. The workaround was to assign correct PID, e.g. 0x5710 for CDC ACM and to use the ST tool to generate the .inf file if needed. This solved error code 10 and error code 28 in Windows.

Another issue in USBX examples is related to the descriptor generation for HS an FS mode, while we can only use FS mode. It's a complex and useless process in the example and this can also generate some UB, e.g. sometimes it stucks in endless loop due to descriptor size == 0. I was not able to reproduce this error, but it tends to occur during the same debugging sessions.

CLee.21
Associate

I tried to use Azure USBX on STM32H7-DISCO and hit the same problem. Any working example for USBX High-Speed audio application?

BKlus.1
Associate II

It's been a while, but I think I figured it out. I have not implemented physical audio input/output yet, but it looks like I am receiving and sending (simulated) audio streams from and to the PC.

Here's a code example I used: https://renesas.github.io/fsp/group___u_s_b_x.html

There's a lot information there that I could not find anywhere else.

mohamed.ayed
ST Employee

Hi @BKlus.1​ ,

This is a first sample example showing support of Audio Class that can be accessed from ST github .

https://github.com/STMicroelectronics/x-cube-azrtos-h7/tree/dev/usbx/Projects/STM32H743I-EVAL/Applications/USBX/Ux_Device_Audio

Regards.