AnsweredAssumed Answered

STM32Cube stack alignment problem?

Question asked by greiman.william on Jun 23, 2014
Latest reply on Jun 23, 2014 by greiman.william
STM32Cube ld scripts set _estack to the last location of RAM like this:

/* Highest address of the user mode stack */
_estack = 0x20017FFF;    /* end of RAM */

I had several problems with code that uses doubles.  Here is an example of printf which converts float arguments to double.

float flt = 1.234;
printf("flt: %f\n", flt);
double dbl = 9.8765;
printf("dbl: %f\n", dbl);

This code prints this:
flt: -2.000000
dbl: -0.000000

If I change the definition of _estack like this:
/* Highest address of the user mode stack */
_estack = 0x20018000;    /* end of RAM */

I get the correct result:
flt: 1.234000
dbl: 9.876500

Is this ld script wrong?  Many other Cube projects have similar values for _estack.

I thought _estack should be aligned on an 8 byte boundary.  Is this correct?

This example is for the ld script STM32F401RE_FLASH.ld for a Nucleo project.

Outcomes