[En-Nut-Discussion] gcc, large programs, corrupted variable or memory space? :(

Stephen Noftall stephenn at lcsaudio.com
Fri Mar 28 17:31:15 CET 2003


Hi Bret;

I just took a quick look through the code, and it looks like you are using
too much "static" storage space.

Check the MAP file, and make sure the SRAM allocation doesn't go past
0x00800A00 or so. Try to allcoate everything with NutHeapAlloc();

I looked in to this before. The problem comes down to GCC initializing the
boot up stack pointer to top of internal ram (0x1100 on atmega128) when it
firsts boots up. So it is hard at that point to every get this little bit of
ram back. So when SRAM is allocated into this space, lots of bad things
start happening. To get around this, we would need to make our own compiler
init code that initializes the SRAM and puts the stack at the top of SRAM
when we first boot up. Then we would be free to have as much "static"
storage as we want (ok, within limits ;-).

Cheers, and have fun!

Stephen Noftall




More information about the En-Nut-Discussion mailing list