AnsweredAssumed Answered

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

Question asked by Cory Russell on Feb 9, 2018

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...


#elif ( configSUPPORT_STATIC_ALLOCATION == 1 )
return xQueueCreateStatic(queue_def->queue_sz, queue_def->item_sz, queue_def->buffer, queue_def->controlblock);


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.