roxy3d wrote on Thursday, April 26, 2018:
Hello! I’m trying to slip FreeRTOS under Marlin (the 3D Printing firmware) and have run into a problem. I want to keep trying to xCreateTask() with decreasing amounts of stack memory until the task starts successfully. In order to do that, I need configUSE_MALLOC_FAILED_HOOK=0 (or else the malloc() routines will lock up with the board’s LED blinking).
I can’t do that because vTaskStartScheduler() makes a call to vApplicationMallocFailedHook();
Can we make a small change in the release version of FreeRTOS as described below? It is easy enough to make the change, but the distribution of the needed change is difficult. Marlin uses the GNU license and it would be messy for use to distribute a modified version of FreeRTOS.
void initVariant(void)
{
#if defined(USBCON)
USBDevice.attach();
#endif
setup(); // the normal Arduino setup() function is run here.
vTaskStartScheduler(); // initialise and run the freeRTOS scheduler. Execution should never return here.
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
vApplicationMallocFailedHook(); // Probably we've failed trying to initialise heap for the scheduler. Let someone know.
#endif
HANG: goto HANG;
return;
}