[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Allocation of large globals in external RAM
From: |
Molnar Zoltan |
Subject: |
[avr-gcc-list] Allocation of large globals in external RAM |
Date: |
Wed, 2 May 2001 00:23:15 -0700 (PDT) |
Hi all,
I'm still having problems in allocating large global variables in external RAM.
How can I tell the linker that I have 32K external RAM?
How can I tell the linker where to put the stack (--defsym __stack=0x08000
returns 'No such file or directory').
Does anybody have working makefiles for early MCUCR, stack initialization?
Here I enclose a test program and my makefile (I'm using gcc 2.97), please run
the code and help if You can.
Thank You
Zoltan Molnar
---
test program:
#include <io.h>
#include <interrupt.h>
#define FIFOlgth 2000
typedef unsigned char u08;
typedef char s08;
typedef unsigned short u16;
typedef short s16;
typedef u08 bool;
typedef struct {
u16 min,max,o,f;
bool isfull;
u08 data[FIFOlgth];
} t_fifo;
t_fifo fifo;
//******************************************
//MAIN PROGRAM
int main (void)
{
/*set up port pin directions and levels*/
outp(0x56,DDRB);
outp(0xFF,PORTB);
outp(0xD6,DDRD);
outp(0xFF,PORTD);
outp(0x80,MCUCR); /*enable XSRAM, how to do it from linker???*/
sei();
fifo.min=0;
fifo.max=FIFOlgth-1;
fifo.o=0;
fifo.f=0;
for(;;)
{ }
return 0;
}
makefile:
###### define some variables based on the AVR base path in $(AVR) #######
CC=avr-gcc
AS=avr-gcc -x assembler-with-cpp
RM=rm -f
RN=mv
BIN=avr-objcopy
INCDIR=.
LIBDIR=$(AVR)/avr/lib
SHELL=$(AVR)/bin/sh.exe
###### output format can be srec, ihex (avrobj is always created) #######
FORMAT=ihex
########################## default mcu type #############################
#put the name of the target mcu here (at90s8515, at90s8535, attiny22, atmega603
etc.)
MCU=at90s8515
####################### default compiler flags ##########################
CPFLAGS=-g -O2 -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
####################### default assembler flags #########################
ASFLAGS=-Wa,-gstabs
########################## default linker flags #########################
# LDFLAGS=-Wl,-Map=$(TRG).map,--cref
LDFLAGS=-Wl,-Map=$(TRG).map,--cref --defsym __init_mcucr__=0x80
#put the name of the target file here (without extension)
TRG=test
#put your C sourcefiles here
SRC= $(TRG).c
#put additional assembler source file here
ASRC=
#additional libraries and object files to link
LIB=
#additional includes to compile
INC=
#early MCU init. weaks
#--defsym __init_mcucr__=0xc0
#--defsym __init_wdtcr__=0x00
#--defsym __stack=0x7fff
########### you should not need to change the following line #############
#define all project specific object files
OBJ = $(ASRC:.s=.o) $(SRC:.c=.o)
CPFLAGS += -mmcu=$(MCU)
ASFLAGS += -mmcu=$(MCU)
LDFLAGS += -mmcu=$(MCU)
#this defines the aims of the make process
all: $(TRG).obj $(TRG).elf $(TRG).rom #$(TRG).eep
#compile: instructions to create assembler and/or object files from C source
%o : %c
$(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@
%s : %c
$(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@
#assemble: instructions to create object file from assembler files
%o : %s
$(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@
#link: instructions to create elf output file from object files
%elf: $(OBJ)
$(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@
#create avrobj file from elf output file
%obj: %elf
$(BIN) -O avrobj -R .eeprom $< $@
#create bin (ihex, srec) file from elf output file
%rom: %elf
$(BIN) -O $(FORMAT) -R .eeprom $< $@
%eep: %elf
$(BIN) -j .eeprom --set-section-flags=.eeprom="alloc,load"
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
###### dependecies, add any dependencies you need here ###################
$(TRG).o: $(TRG).c
#make instruction to delete created files
clean:
$(RM) $(OBJ)
$(RM) $(SRC:.c=.s)
$(RM) $(SRC:.c=.lst)
$(RM) $(TRG).map
$(RM) $(TRG).elf
$(RM) $(TRG).obj
$(RM) $(TRG).eep
$(RM) $(TRG).rom
$(RM) *.bak
$(RM) *.log
_____________________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now! Visit
http://www.TechEmail.com
- [avr-gcc-list] Allocation of large globals in external RAM,
Molnar Zoltan <=