ATMega128 and the stack pointer with GCC

nobody wrote on Friday, September 30, 2005:

Hi all
I have just ported the AVR323 GCC code to the at128. After much fiddling around I managed to get a cut down version of the demo app working.

However i found the the stack pointer at the entery to the main function was incorrectly set to 0x10FF ie 8k. The ATmega128 is according to the data sheet has 4k Internal SRAM. To get the demo app to run I had to use the

-minit-stack=0xFFF

command in the makefile

I would be greatful if anyone could shed some light on this.

nobody wrote on Friday, September 30, 2005:

Thats odd, but from what I have seen on the AVR ports FreeRTOS does not have any effect until after main() is called, so this must be a linker or configuration problem.

Did you set the 'MCU = ’ flag correctly in the makefile?  Although if you left it configured for a 323 the SP should not end up at 8K.

Can you take a look at the map file and see the memory configuration.

What is the heap size set to in FreeRTOSConfig.h?

nobody wrote on Saturday, October 01, 2005:

I also had problems getting the demo to run on mega128. Two things fixed the problems:

1. Make sure to change `SIGNAL( SIG_UART_DATA )’ to `SIGNAL( SIG_UART0_DATA )’.

2. Do a `make clean’. This should not be necessary, but the makefile seems broken. You may want to do this for every compile after non-trivial changes.

/Lars Hamren

nobody wrote on Tuesday, October 04, 2005:

Many thanks guys!

Barry

nobody wrote on Friday, October 07, 2005:

Guys, what exactly do you mean by "porting"? It works with Atmega128 nearly "out of the box" - may tale 15 minutes to get it running.

Alex.