STM32U585 (USB_OTG_FS), latest CubeIDE (USBX 6.2.0)
I implemented USB Audio 1.0 Microphone Descriptor into ThreadX USBX (using builder framework). Descriptor works, (no errors, microphone is shown in audio control), but no audio is received. It seems that ux_device_class_audio_stream_change function is not called, only ux_slave_class_audio_instance_activate. I also tried code from official STM32H7 USBX Audio example (that's Audio 2.0 Speaker), and that one had similar issue, no ux_device_class_audio_stream_change were called.
So I guess this might be an issue with STM32 USB Controller driver inside USBX?
There are some more code shared here on USBX repo: https://github.com/azure-rtos/usbx/issues/92 . But now it seems to be more issue on the controller side, so I am posting this here. Thanks.
Over the last few months, I am facing with similar problem on STM32U585.
I am not using USBX stack but with an old STM USB stack ( it was part of the old CubeMX, before Thredx was integrated into the Cube)
In my case, audio_data_in() callback is not called.
I guess its an issue with STM32 USB driver (stm32u5xx_hal_pcd module)
BTW, as a speaker it is working (not perfect). also for other profiles such as CDC.
Attached link to my open issue
Thanks for letting me know.
USB CDC works for me works absolutely fine, but for speaker, I didn't received any data or callbacks too, same behavior as on Microphone.
From my inspection, I am deducing too, that it might be issue in STM32 USB driver, or controller implementation for USBX.
I will try to take look on it again following week, mainly to check out what IRQs are coming according to USB traffic, although, it would be really helpful if someone from ST could help us find out this issue.
I was able to figure the issue after some painful debugging. I will write here some of my notes, which could be useful for anyone else playing with USB on STM32 platform.
1) Always verify that your descriptor is correct. Test it both on Linux and Windows, most of times, Linux is more verbose about the problems. In my case of UAC 1.0 Microphone implementation, I forgot to change baInterfaceNr to correct interface number of Audio Stream. (Always check information from official USB specifications)
2) If things doesn't work , it is good to dig into the source code and look for calls which might be related, check out with Wireshark if when packet is sent from host to device, if USB OTG interrupt is triggered, and if it replies. If it replies, continue and check if the code will reach the function / callback you need.
3) My audio callbacks were not called, because I used endpoint ID, which was outside of supported endpoints range. I didn't knew about this, because I didn't knew how error handling and logging worked, because the documentation is really... weak, so I found the issue only by debugging in the USBX. Although, I found this useful function ux_utility_error_callback_register , which will call your callback when error occurs! Very handy!
4) I didn't received callbacks about successful "delivery" of IN packets, this was because I was missing USBD_HAL_ISOINCOMPLETE_CALLBACK definition in ux_stm32 header. (Of course, this is nowhere documented.)
5) Endpoint's wMaxPacketSize, HAL_PCD_SetTxFiFo and buffer size in audio parameters are somehow related. After proper configuration of those I was able to get smooth and nice working audio stream from device. I wasn't able to fully understood how it works (yet) 😅
@Community member So far, it seems that USB PCD HAL driver is working properly, so you might have issue in your code. Try the things I mentioned upper, if you will not be lucky, let me know, I will try to help you.