memory allocation problem?

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. What causes this?
I have the following type declaration:

#define FIFOlgth 2048

typedef struct {
u16 min,max,o,f;
bool isfull;
u08 data[FIFOlgth];
} t_fifo;

The problem is if I want to declare a global variable like this:

t_fifo fifo;

int main (void)
{
....
}

The make process returns with error (I enclose the compile/link flags too):

avr-gcc -c -g -O2 -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst -mmcu=at90s8515 -I. test.c -o test.o
avr-gcc test.o -Wl,-Map=test.map,--cref -mmcu=at90s8515 -o test.elf
D:\AVRGCC\BIN\..\lib\gcc-lib\avr\2.95.2\..\..\..\..\avr\bin\ld.exe: address 0x869 of test.elf section .bss is not within region data
make: *** [test.elf] Error 1

If I put the declaration in the main function like this:

int main (void)
{
t_fifo fifo;
....
}

it compiles OK.

I need the variable to be global, I have to access it from interrupts.

--------
2. How can I initialize the stack pointer and MCUCR at compile time?
I have read something about --defsym but I don't know where to put and how. In the compiler flags or the linker flags?
What's the syntax using --defsym

Any help would be welcomed
Thanks

PS: I'm using avr-gcc 2.95, but I tryed with 2.97, 3.1 with the same result.

admin's test signature