2024-10-02 10:35 AM
I've been working with USBX for a while now, and after updating to the latest X-CUBE-AZRTOS-H7 package (v3.2.0), I'm running into a couple of problems relating to the templates STM32CubeMX generates. Specifically, the files ux_device_descriptors.c and ux_device_descriptors.h
1). In the function USBD_Get_String_Framework, the variable "count" is declared as uint8_t. This is a problem if the string framework is more than 256 bytes in length. This definition is outside of the user editable code, so I need to remember to edit it every time I regenerate my code. This should be set to uint16_t or unsigned.
2). Also in USBD_Get_String_Framework, the USER CODE tags are missing BEGIN and END. As a result, any code I put in between them is deleted when regenerating code.
3). In the header file, the "USER CODE BEGIN/END Private_defines" tags appear twice, which results in any code in one of the sections begin duplicated when regenerating code.
These are not a big deal, but they are a bit annoying when doing repeated changes in STM32CubeMX.
2024-10-02 10:40 AM
I should also mention that there are other places where the BEGIN/END tags are missing, for example the USBD_FrameWork_AddToConfDesc function.
2024-10-02 11:53 AM
And another addendum - it doesn't appear that there's any way to configure USBD_STRING_FRAMEWORK_MAX_LENGTH from STM32CubeMX, so any change made to that constant gets overwritten by STM32CubeMX as well.
2025-04-01 8:50 PM
What I do is create a separate file with the "SameName-new.c". Then after reconfiguring the CubeMx configuration, i run a script and it restores my code automatically. After the reconfiguration, the file tree looks like: The files with the Red marker are the ones that CubeMX modified.
I can run a diff or compare the CubeMx ver to my version; or if it is just a simple define change, I can quickly restore my code by running the scripts/fix_files.bat.
The script file is a simple .bat file which removes the CubeMx files that are not needed.
This made my life a lot easier