TI Tiva TM4c1294 FreeRTOS v10.2.1

I have seen this before where the C startup code is written in C. If it is doing something like clearing memory to zero using a loop counter that is stored on the stack then the loop counter also gets cleared to zero and you have a problem. Turning on optimisation results in the loop counter being held in a register, rather than on the stack, so the loop counter itself is not corrupted as the memory is cleared. I think some early Stellaris projects (Stellaris became Tiva) used C code to clear memory and to get it to work we turned optimisation on for just the startup C files. That was a long time ago though so my memory might not be quite correct.