[bug report] USB CDC Serial Number in release build not working
Hello, I would like to report a bug on USB CDC middleware generated from CubeMX 6.11.
When I use it in Debug build, everything works as expected. Once I switch to Release, the compiler optimizes out the serial number. I use official VScode extention with Cmake to build the FW.
Without a serial number at USB device, Windows fails to recognize that anything is connected. It works in Linux only.
I have the same issue happen at STM32F411 and STM32L433.
The solution was to add initalization to 3 lines in USB_DEVICE\App\usbd_desc.c
uint32_t deviceserial0 = *(uint32_t*)DEVICE_ID1;
uint32_t deviceserial1 = *(uint32_t*)DEVICE_ID2;
uint32_t deviceserial2 = *(uint32_t*)DEVICE_ID3;
I hope this helps someone and the STM may fix it. No support is needed.
Thanks.
