2025-02-04 03:11 PM - edited 2025-02-05 10:47 AM
I am having trouble creating custom queue sizes and making them work with the Heap Usage tool within CubeMX. But I found a workaround until the bug gets fixed.
I created a queue using a custom item size (the message_data_t type is defined in my code):
The code generation is correct:
/* Create the queue(s) */
/* creation of UsbRxQueue */
UsbRxQueueHandle = osMessageQueueNew (16, sizeof(message_data_t), &UsbRxQueue_attributes);
/* creation of BufferQueue */
BufferQueueHandle = osMessageQueueNew (8, sizeof(message_data_t), &BufferQueue_attributes);
/* creation of SystemQueue */
SystemQueueHandle = osMessageQueueNew (16, sizeof(message_data_t), &SystemQueue_attributes);
When the Heap Usage tool calculates the memory the queue needs, it incorrectly uses 4 bytes by default the heap size is wrong.
My solution is to create a user constant to tell the GUI what size it is:
.. then I #undef the message_data_t it creates so the code compiles correctly!
/* Private defines -----------------------------------------------------------*/
#define GAIN_COMP1 0
#define GAIN_COMP2 0
#define message_data_t 8
#define USART2_TX_Pin GPIO_PIN_2
#define USART2_TX_GPIO_Port GPIOA
....
/* USER CODE BEGIN Private defines */
// CubeMX bugfix:
#undef message_data_t
I think it works, but will post any updates.
STM32CubeMX - STM32 Device Configuration Tool
Version: 6.12.1-RC4
Build: 20240912-2256 (UTC)
2025-02-05 02:07 PM
I made some other changes to the code, and after a while, CubeMX started generating the code incorrectly. I had to manually type in the "sizeof(" here. This errored out:
/* Create the queue(s) */
/* creation of UsbRxQueue */
UsbRxQueueHandle = osMessageQueueNew (16, message_data_t, &UsbRxQueue_attributes);
/* creation of BufferQueue */
BufferQueueHandle = osMessageQueueNew (8, message_data_t, &BufferQueue_attributes);
/* creation of SystemQueue */
SystemQueueHandle = osMessageQueueNew (16, message_data_t, &SystemQueue_attributes);
As far as I can tell I didn't change anything relating to this in the .ioc file.