Skip to main content
Associate II
September 11, 2026
Solved

USBX Mass Storage Class device (hard fault)

  • September 11, 2026
  • 2 replies
  • 39 views

I’m trying to implement USB mass storage class device standalone(no RTOS) on nucleo board STM32U575ZI-Q, using RAM for memory.

I tried adapting these steps :

 

but right now, in MX_USBX_Init(), inside  ux_device_stack_initialize  , at this point:

#if UX_DEVICE_ENDPOINT_BUFFER_OWNER == 0

/* Obtain some memory. */
endpoints_pool -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer =
_ux_utility_memory_allocate(UX_NO_ALIGN, UX_CACHE_SAFE_MEMORY, UX_SLAVE_REQUEST_DATA_MAX_LENGTH);

/* Ensure we could allocate memory. */
if (endpoints_pool -> ux_slave_endpoint_transfer_request.ux_slave_transfer_request_data_pointer == UX_NULL)
{
status = UX_MEMORY_INSUFFICIENT;
break;
}
#endif

it goes : 

status = UX_MEMORY_INSUFFICIENT;

Because of that, ux_device_stack_initialize returns UX_ERROR;  witch i think causes Hard fault.

 

This happens before any code i’ve written, so i must’ve messed up something in the CubeMX configuration or i missed some step of the initialization?

 

I’ve increased USBX memory pool size to 32kB and USBX System Stack Size to 10kB but nothing changed.

 

 

i’m really stuck here, any help would be appreciated

 

 

 

Best answer by FBL

Hi ​@dracena 

The issue is in your USBX system memory initialization. USBX cannot allocate from its internal memory pool.

After regenerating you must check your USBX memory pool size here.

2 replies

FBLBest answer
ST Technical Moderator
September 11, 2026

Hi ​@dracena 

The issue is in your USBX system memory initialization. USBX cannot allocate from its internal memory pool.

After regenerating you must check your USBX memory pool size here.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
dracenaAuthor
Associate II
September 11, 2026

Thank you so much for the answer,

I’ve already checked so many times, but now that you said it, it helped.