sprintf not working with floating point after Scheduler started.

harryw12 wrote on Tuesday, October 22, 2013:

porting FreeRTOS7.5.3 on PSOC5LP using PSOC Creator 3.0(newlib included).
where I found sprintf not working with floating point(got all NULL chars except the ‘.’ after conversion) after FreeRTOS scheduler started (works before).

it looks like the newlib with PSOC Creator 3.0 might have the floating point funtion issue while in a multitasking env.
newlib in PSOC Creator 3.0: the floating point functions works
newlib in PSOC Creator 3.0 with FreeRTOS started: floating point functions does not work
newlib in POSC Creator 2.1 with FreeRTOS started: floating point functions works

I don’t know if this is relating to reentrant of newlib (included in PSOC Creator 3.0). But I enabled the macro #define configUSE_NEWLIB_REENTRANT == 1 in FreeRTOSConfig.h, and memory allocation in the port is using heap2.c

Anyone can advise where to start on this issue? thanks.

harryw12 wrote on Wednesday, October 23, 2013:

rtel wrote on Wednesday, October 23, 2013:

This can happen if the stack is not correctly aligned to an 8 byte boundary - but the FreeRTOS code should ensure that it is. I have tried with configUSE_NEWLIB_REENTRANT set to 1 (should not make any difference to alignment) and heap2.c and find the stack is aligned as expected when the task starts.

I assume your FreeRTOS version is very new as configUSE_NEWLIB_REENTRANT was only introduced recently. Are you using V7.5.3 - as prior versions didn’t initialse the reent structures until the first context switch, maybe if you are using it prior to the first context switch you would get a problem resulting in a stack mishap?