[En-Nut-Discussion] Problem with Ethernut Startup

en-nut-discussion-admin at egnite.de en-nut-discussion-admin at egnite.de
Tue Jun 24 01:03:22 CEST 2003

Hi Thorsten;

This comes up a few times with the Atmel GCC compiler. When declaring large
(>2K) static arrays, the Atmega's internal stack is overwritten on startup.

What is happening is that GCC has a small program that gets executed at
startup. It copies over the static array variables from FLASH into SRAM. It
also sets the stack pointer to the top of internal SRAM, not external
memory. So effectively the stack pointer is 4K from the beggining of memory.
So on boot, the stack is corrupted -> crash.

The short answer is to never use large static structures. Allways use
malloc. Check the MAP file to make sure that the statics are only taking up
a <3K of SRAM.

Someday I'll figure out a way for it to put the stack at the top of external
memory. That is, as long as it has external memory ;-)

Stpehen Noftall

----- Original Message -----
From: <en-nut-discussion-admin at egnite.de>
To: <en-nut-discussion at egnite.de>
Sent: Monday, June 23, 2003 1:22 PM
Subject: Re: [En-Nut-Discussion] Problem with Ethernut Startup

> > There's definitely nothing done with the Ethernet controller
> > unless you call NutRegisterDevice.
> I look through NutInit and so on an it's true. I experimented a bit today
> and now I am totally confused. I took the "simple" project and added part
> after part to it and now I have my whole program rebuilt that way and it
> works. I don't see any differences except that I defined a 4kB bitmap now
> program memory. Maybe I am running out of RAM? But I only have two "big"
> (2kB) arrays and that bitmap and a few char variables.
> > Important:
> > Please do not use Basemon as a sample, this program is a
> > miserable hack, only used to test the board, even if the
> > external RAM is gone. Use httpserv.
> I see that, but it was/is the only program that works, beside my own -
> We'll if it works tomorrow, too. I am a bit worried that there might be a
> hardware problem.
> BTW: How can I determine the actual IP adress? I want to show it on the
> console.
> Bye
> Thorsten
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion

More information about the En-Nut-Discussion mailing list