How do I change the initialization order to avoid a race condition (ISR vs. FreeRTOS init) during initialization?
CubeMX generates the main.c like this:
int main(void)
{
...
MX_GPIO_Init();
MX_RTC_Init();
MX_NVIC_Init();
MX_FREERTOS_Init();
...
}
We observe a sporadic crash during boot which we traced to an GPIO interrupt whose ISR calls into the FreeRTOS API (xQueueSendToBackFromISR) before MX_FREERTOS_Init(); has been called.
Moving MX_NVIC_Init(); below MX_FREERTOS_Init(); reliably fixes the situation for us. How can we tell CubeMX to generate the init code persistently in that order. As of now, we must manually change the init order after each code regeneration.
