2025-09-01 12:49 PM - edited 2025-09-16 10:12 AM
Hi,
I have downloaded and installed STM32CubeIDE version 1.18.1, and created a new project for the STM32F042C6T6 chip. For this chip, the latest available firmware pack is STMCube MCU Package for STM32F0 series version 1.11.5.
When I install this firmware pack and open it from the STM32Cube / Repository directory, I can see that in the middleware folder I have the STM32 USB middleware library version 2.5.3. This is apparent from the Relese Notes file present in the directory.
In GitHub, the latest available version for the STM32 USB middleware library is much newer, version 2.11.4 which contains all the nice things I need such as support for USB composite devices. I have already reviewed the post https://community.st.com/t5/stm32-mcus/how-to-implement-a-usb-device-composite-in-stm32h5/ta-p/708078 found from this forum but this link only deals with STM32H5 which is a completely different MCU from my meager F0.
My main question then is, how can I use the latest STM32 USB middleware library together with the STM32CubeIDE and benefit e.g. from the Composite builder support?
Or is my only choice to generate a sample USB implementation e.g. for Custom HID using the older version present in the firmware package, then replace the core and class files with the files from the newer middleware package, and "port" the code that STM32Cube generated for me to the standards and practises used by the new version?
This second approach is a bit problematic because the PMA memory of the STM32 USB implementation is not very thoroughly documented. Sure, there is the chip's reference manual, and there's UM1734 but then you'd just "have to know" that there's also this post https://community.st.com/t5/stm32-mcus/how-to-select-suitable-endpoints-for-your-stm32-usb-application/ta-p/719823 which gives you the "reason" why STM32CubeIDE chose the otherwise arbitrary-looking 0x18 and 0x58 for the PMA addresses of endpoint 0. Nothing for example in the UM1734 hints about maximum package sizes of various endpoint types, or what kind of parameters to use with HAL_PCDEx_PMAConfig call...
Solved! Go to Solution.
2025-09-14 6:11 AM
In the end, I accomplished this goal in F0 by creating a project for STM32F4 (which uses a more recent version of the library), and then copy-pasting these files into my F0 project.
I had a few compiler errors and warnings related to the HAL PCD function names but they were quite easy to fix.
2025-09-02 3:30 AM
Hi @ankes
About PMA, I am preparing an article to explain and simplify the documentation provided. You can refer to Figure 328. Packet buffer areas with examples of buffer description table locations in RM
Regarding your second question, I recommend using USB Device library provided in CubeF0. and it would be better to provide minimal project. To use Composite builder, you need to be careful to insert all framework layer function pointers.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-02 8:00 AM
Hi @FBL,
Thank you for the swift response. I look forward for the article, and will review the reference manual once more.
So far, I have understood that STM32CubeIDE chooses 0x18 and 0x58 as the PMA addresses for endpoint 0 to ensure there's 64 bytes available for both buffers (0x18 and 0x58, when converted to decimal, are exactly 64 bytes apart). Same applies for the Custom HID's endpoint 1; the PMA addresses 0x98 and 0xD8 are 64 bytes apart, and 0x98 is 64 bytes from 0x58.
I can use this information as a baseline. Hopefully your article will shed some more light.
Regarding your answer about the USB Device Library provided with CubeF0, I cannot use it if I want to utilize the Composite builder. The reason is rather simple: the latest CubeF0 firmware package does not have it. The "Class" folder does not contain the "CompositeBuilder" subfolder.
My final goal is to build a composite HID and AUDIO (microphone) device, so I still have a long way to go. Unfortunately for me when I ask STM32CubeIDE to generate an example of an AUDIO device then it creates some kind of a custom low-level implementation that omits all calls to HAL_PCDEx_PMAConfig...
Thus I will need to understand the ramifications of using (or not using) PMAConfig, and how the USB Audio driver provided with the Device Library actually works.
2025-09-14 6:11 AM
In the end, I accomplished this goal in F0 by creating a project for STM32F4 (which uses a more recent version of the library), and then copy-pasting these files into my F0 project.
I had a few compiler errors and warnings related to the HAL PCD function names but they were quite easy to fix.