[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Link time stack, mcucr, watchdog init. with avr-gcc
From: |
Molnar Zoltan |
Subject: |
[avr-gcc-list] Link time stack, mcucr, watchdog init. with avr-gcc |
Date: |
Fri, 4 May 2001 02:34:32 -0700 (PDT) |
Thanks to Jason Kyle and Ludovic COURTES I succeded to initialize RAM size,
stack pointer, MCUCR and watchdog control register at link time, so You won't
get strange link error messages if You use ext. memory and large variables.
Also You don't have to init. stack, MCUCR and watchdog from code.
I attach to this mail the makefile and local linker script file that do all
this.
Thanks to everybody who responded to my question.
_____________________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now! Visit
http://www.TechEmail.com
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:2)
MEMORY
{
text (rx) : ORIGIN = 0, LENGTH = 8K
data (rw!x) : ORIGIN = 0x800060, LENGTH = 32672
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 512
}
SECTIONS
{
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/* Internal text space or external memory */
.text :
{
*(.init)
*(.progmem.gcc*)
*(.progmem*)
. = ALIGN(2);
*(.text)
. = ALIGN(2);
*(.text.*)
. = ALIGN(2);
*(.fini)
_etext = . ;
} > text
.data : AT (ADDR (.text) + SIZEOF (.text))
{
PROVIDE (__data_start = .) ;
*(.data)
*(.gnu.linkonce.d*)
. = ALIGN(2);
_edata = . ;
} > data
.bss SIZEOF(.data) + ADDR(.data) :
{
PROVIDE (__bss_start = .) ;
*(.bss)
*(COMMON)
PROVIDE (__bss_end = .) ;
_end = . ;
} > data
.eeprom :
AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.data))
{
*(.eeprom*)
__eeprom_end = . ;
} > eeprom
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
PROVIDE (__stack = 0x7fff) ;
PROVIDE (__init_mcucr__ = 0x80) ;
PROVIDE (__init_wdtcr__ = 0x00) ;
}
#Make file with link time initialization of the stack pointer, MCUCR and
watchdog control register.
#In order to tell the linker how much SRAM You have use the attached local
linker script file.
#Modify length of data segment: 'data (rw!x) : ORIGIN = 0x800060, LENGTH = ...'
<- 512; 32672
#Modified by Molnar Zoltan, original by Volker Oth.
#Special thanks for their help to Jason Kyle address@hidden and Ludovic COURTES
<address@hidden>
#Good luck using it.
###### 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 -Os -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
####################### default assembler flags #########################
ASFLAGS=-Wa,-gstabs
########################## default linker flags #########################
LDFLAGS=-Wl,-Map=$(TRG).map,--cref,-Tavr85xx.x
#put the name of the target file here (without extension)
TRG=test2
#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=
########### 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)
LDFLAGS += -Xlinker --defsym -Xlinker __init_wdtcr__=0x00
LDFLAGS += -Xlinker --defsym -Xlinker __init_mcucr__=0x80
LDFLAGS += -Xlinker --defsym -Xlinker __stack=0x7FFF
#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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-gcc-list] Link time stack, mcucr, watchdog init. with avr-gcc,
Molnar Zoltan <=