Skip to main content
Associate
Question

STM32U585 USB is OK with Keil; not working with CubeIDE or makefile

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. 

This topic has been closed for replies.

4 replies

Andrew Neil
Super User

@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 ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
CeSiumAuthor
Associate

Yes, I've tried attaching a debugger, and that's what I'm getting:

CeSium_0-1762838890595.png

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 

 

CeSium_2-1762840640108.png

And the hard fault reason is:

CeSium_3-1762840668471.png

 

Pavel A.

The difference can be also in the Keil MDK runtime library.

 

CeSiumAuthor
Associate

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

 

CeSium_5-1762842161643.png