PIC32MX port xc32 2.40/1 sprintf stack alignment

sprintf with a %f or %g conversion works correctly with on pic32mx with xc32 compiler 2.30.

Using the 2.40/1 version (and FreeRTOS) the %f or %g conversion fails.
Adding an additional pxTopOfStack–; to the beginning of the pxPortInitialiseStack function in port.c fixes the problem.

The pic32MZ port works correctly with FreeRTOS and has this extra line.

Should the pic32mx port.c be changed or is there an alternate solution?

1 Like

Thanks for reporting this. That code has not actually changed in a long time so I wonder if there is something different in the way the compiler is handling floats in between the older version used to create the port and the latest compiler - or maybe a change in the way the floating point command line options behave, as what you report is almost always a symptom of having an incorrect stack alignment. The alignment is actually specified as 8 in the header file PIC32MX port xc32 2.40/1 sprintf stack alignment. We will investigate and update accordingly.

This has been addressed in the following PR: https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/182

Thank you for reporting this issue.