Skip to main content
Visitor II
February 19, 2021
Question

Port X-CUBE-USB-AUDIO whithout nodes and recording sessions to create a USB audio microphone

  • February 19, 2021
  • 3 replies
  • 2122 views

Hi ST Geniuses

So, for quite a while I have been trying to create an USB audio mic. Problem is: it is quite hard and not always a complete solution.

And the X-CUBE-USB-AUDIO offers the complete solution, for audio and playback, even with feedback.

The problem is: it is so complicated to detach the USB solution from the nodes, and sessions thing (see here if you don't know what I am talking about USB device audio streaming Expansion Package for STM32Cube - User manual). And the middleware isn't the same generated by CubeMX, which makes it harder to port it to another microcontroller (in my case the STM32L4R9)

So, did anyone manage to do this? Or to approach this problem in another manner?

I also tried TinyUSB, which does not offer native support for the STM32L4 family nor it is fully tested for audio (isochronous).

Thanks for the help,

Gabriel.

    This topic has been closed for replies.

    3 replies

    Visitor II
    February 19, 2021

    It has been 2 years since this question : STM32F4 Cube-based USB Device Microphone in Audio Class streaming to Host PC was asked. I want to believe that someone has figured it out

    Super User
    February 19, 2021

    it actually started 4 years ago!

    I guess the conclusion must be that it's not a priority for ST.

    Presumably, commercial products doing this sort of thing are using dedicated chips rather than general-purpose microcontrollers?

    Visitor II
    February 19, 2021

    Definitely not a priority. There are IC's that do I2S <-> USB, just not available from ST. Weird from them...

    And I'm stuck in a limbo where I have half my code working, a custom board that I made, and I don't wanna start over...

    Graduate II
    February 27, 2021

    That topic actually it started not 2 or 4, but 6 years ago... Honestly ST doesn't care about STM32 software. USB, Ethernet, lwIP, FatFS - nothing works. Even USART and till not long ago pin toggling!

    As for TinyUSB, L4(+) is supported:

    https://github.com/hathach/tinyusb/blob/14083ad2df1252436d9f563fb5cf357052a7ec3c/src/portable/st/synopsys/dcd_synopsys.c#L41

    Audio class seems to be a work in progress. But, comparing ST and TinyUSB software progress... Probably this year TinyUSB will have usable audio class, while ST's stack will always be buggy, bloated, using malloc() and doing everything in ISR. You can even help them develop that audio class. :)

    Visitor II
    March 1, 2021

    Damn, 6 years...

    I got it semi working with the package I asked about... but really it shouldn't take that much work

    TinyUSB is really a work in progress... isochronous transfers aren't that well tested apparently; and as for L4+ I asked hathach personally by mail and I got an answer not too long after. And looking at the branches he is the only one working on audio. Hope it does not take too long but I needed something for now

    For others who can pay, there is also HCC stack (official ST partner); maybe that is why they don't give that much attention to the official package

    Visitor II
    March 2, 2021

    I'm also helping someone else with the same problem, posting here if anyone needs : Having problem setting up USB Audio(Microphone) for STM32H743

    Okay, so, once you change the USB descriptors make sure you uninstall your device on windows, and then plug it in again... Windows does not recognize a USB device with the same VID and PID if it has changed the descriptors (the same is not true on Linux, for example).

    I had more luck using the X-CUBE-USB-AUDIO package, altough it is not cube-compatible. My mic works much better (it is not 100% tough). What you need to do is:

    • Generate code with stm32cubeide for usb audio device
    • Replace files with those on the expansion package but keep those on the Core (Middlewares/ST/STM32_Device_Library/Core) and Target (USB_MIC/Target) folders. The usbd_conf files are device-specific (more on that here: STM32 USB training - 08 STM32 USB Device library - YouTube at around the 4 min mark)
    • Make sure you use the STM32F769I_DISCO_UAC10-DUM example, for a dummy microphone (easier to decouple from the software used for the MEMS mic)

    And then, you configure as your application should run :

    • Have your audio samples transferred by DMA
    • Once you get the HalfTransferComplete and TransferComplete callbacks, call the AUDIO_Fill_Buffer function (you can take a hint by looking at the implementation on STM32F769I_DISCO_UAC10-REC (Application/User/audio_mic_node.c). Try to implement the important functions on audio_mic_node.c to your audio_dummymic_node.c that is in your project. I think you only have to modify this file and the usbd_user_cfg.h file

    Tell me if you have any questions, and good luck ! If you can make it work 100% (or at least 90) please post your updates.

    Regards