cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE: how to avoid losing Middleware code changes (USB)

fbar
Senior

Hello,

I plan to modify the USB Audio Class for a project created in STM32CubeIDE and using the USB Middleware library. I select the peripherals I need in the Device Configuration Tool, plus the USB_DEVICe Audio class. then I generate the code.

In all of the code, I can make changes as long as I put my code in the proper places guarded by /* USER CODE BEGIN */ / *USER CODE END */ .

There is no such mechanism for the USB classes. So if I modify or add a function, then later on I might need to re-generate the code using the Device Configuration Tool due to a project change (say, adding a GPIO pin), but doing so will overwrite all the USB files.

My workaround is to find and copy all the USB files I modified, copy them to a safe place, generate the code, then copy back my files. It's slow and error-prone

Is there a way to force STM32CubeIDE to avoid "stomping" middleware files? After all, no matter what I change in the device itself, the USB configuration is not changed. Even a checkbox option with "do not overwrite existing USB Middleware files" would help a lot.

11 REPLIES 11
Enour.1
Associate III

Although it is not the best way but it works, you can comment the whole code before rebuilding it for the configuration changes, because the this problem happens only with any configuration changes in *.ioc file.

Really I don't understand why ST don't fix this simple problem? is it a way to give a space for the other companies to work ?!

> Really I don't understand why ST don't fix this simple problem?

This is not a simple problem IMHO. ST already done a decent job of providing HAL and MW libraries on github.

>  is it a way to give a space for the other companies to work ?!

May be. The product of ST is hardware; they are not interested to compete with software partners in their ecosystem.