2025-11-10 4:37 AM - last edited on 2025-11-10 4:49 AM by Andrew Neil
Hi! I have a board based on STM32U585CIU, and I'm trying to enable a USB CDC on it. The problem is: when I generate a project in CubeMX for MDK-ARM, the code I've attached works fine, USB CDC device is being recognized by PC, and I can see messages via COM port. However, once I generate it for CubeIDE or Makefile, it just goes to hard fault in MX_USBX_Device_Init. Considering it works in Keil uVision, seems like hardware is completely okay, so there is something in the difference between gcc-arm and arm compiler.
2025-11-10 4:52 AM
@CeSium wrote:Considering it works in Keil uVision, seems like hardware is completely okay, so there is something in the difference between gcc-arm and arm compiler.
Seems a reasonable hypothesis.
Have you tried debugging the Hard Fault ?
2025-11-10 4:06 PM
The difference can be also in the Keil MDK runtime library.
2025-11-10 9:57 PM
Yes, I've tried attaching a debugger, and that's what I'm getting:
The Hard Fault occurs in ux_utility_memory_free_block_best_get.c in _ux_utility_memory_free_block_best_get function (line 110) while getting a value from memory_block -> ux_memory_block_status. According to debugger, memory_block is 0x1. I've also got the PC address: 0x800bae8, which shows this disassembly
And the hard fault reason is:
2025-11-10 10:22 PM
UPD. I've also tried updating Firmware Package Version to STM32Cube FW_U5 V1.8.0. Now, I'm not getting the hard fault during MX_USBX_Device_Init. However, now I'm stuck in an endless loop in ux_device_stack_descriptor_send.c