cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 + FreeRTOS + Static Allocation + USB Host = Driver Bug!

Cory Russell
Associate
Posted on February 09, 2018 at 21:13

I'm using an STM32F779IIT6 configured by the CubeMX (V 4.24.0, STM firmware 1.9).  FreeRTOS is configured for STATIC memory only (important), no dynamic allocations allowed.  I've enabled the USB_HOST_FS system as a Mass Storage Host Class.

The generated Cube code under USBH_Init in usbh_core.c snippet is as follows:

osMessageQDef(USBH_Queue, 10, uint16_t);

phost->os_event = osMessageCreate (osMessageQ(USBH_Queue), NULL);

This, in turn, calls osMessageCreate as seen above, which leads to...

&sharpelif ( configSUPPORT_STATIC_ALLOCATION == 1 )

return xQueueCreateStatic(queue_def->queue_sz, queue_def->item_sz, queue_def->buffer, queue_def->controlblock);

&sharpelse

While that's all fine and dandy, the queue_def->buffer was NEVER initialized by the Cube code; It's NULL, causing an ASSERT each time the processor starts up.

The top line of code should be osMessageQStaticDef, not 

osMessageQDef as there is NO dynamic memory available, as defined in FreeRTOS.  My only options for resolution are to either enable both dynamic and static (preferably not...but it works), or modify the usbh_core.c file to call the proper function, then lose it everytime I update the code from the cube (even less preferable).  Any other solution I'm missing?

Thanks in advance.

#cubemx-4.24 #static #usb-host-fs #stm32-freertos #bug-report #driver-bug
1 REPLY 1

Sorry, bumping old zombie unanswered questions off my feed

@CubeMX newer releases, generally you want to double check stack/heap allocations and memory floor plans to ensure they meet application requirements.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..