[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Using External RAM via the -Tdata approach --- Losing Poi
[avr-gcc-list] Using External RAM via the -Tdata approach --- Losing Pointers in the mist
Fri, 27 Sep 2002 14:13:52 +1200
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
I have been attempting to make use of the external SRAM using the -Tdata linker
option to relocate the runtime data section. I am seeing some strange
behaviour with pointers passed to/returned from function calls. I would
greatly appreciate it if someone could advise where I should look next as to
the cause (or cure even better).
When the -Tdata linker option is invoked, pointers passing between functions
seem to go to pot.
I understand using the linker option -Tdata moves the variable memory - Im
moving it above the 4K SRAM range (Using atmega161 with 2K internal SRAM but
allowing for 128 model which has 4K). The objective here is to allow the
internal stack to stay within internal SRAM (required for 161). Moving data
into external SRAM seems an easy way to avoid overwriting the stack whilst
allowing me to have heaps of variables defined.... - I have 64K external SRAM
to play with.
I have included below a simple program that works as expected when the -Tdata
option is not used, but not as expected when it is.
Is it possible that the version of the compiler or libraries Im using doesnt
acknowledge the -Tdata command or am I just whistling in the wind by using the
-Tdata option alone without some other obvious config that Ive overlooked.
I include config and example program below in the hope that some kind soul
The solution of course may be not to use the -Tdata option - perhaps there is a
way to reserve the stack area so it doesnt get overwritten - perhaps blocking
out the top 512bytes of internal SRAM - but this may be beyond me without some
Digital Telemetry (New Zealand)
int lentest(char *s) /* Find the length of a string */
for (n = 0; *s != '\0'; s++)
int main( void )
xxx=lentest("Test"); /* Get the length of the passed string */
sei(); /* This is performed when -Tdata is not used - This is what
ought to happen */
sei(); /* This is performed when -Tdata is used. oh dear. */
in particular I am modifying the makefile entry from ...
LDFLAGS = -Wl,-Map=$(TRG).map,--cref
LDFLAGS = -Wl,-Map=$(TRG).map,--cref -Wl,-Tdata,0x801100
Details of the versions Im using are: (Using AVR Studio 3.53, atmega 161,
external RAM (64K) avrgcc 3.2, Falvio's coff converter for debug)
This is a repackaged version of Tony Mahar and Marc Wetzel's successful minGW compilation of
AVRGCC v 3.2. It also contains necessary binary utilities.
The package is courtesy of AVRfreaks.net; the #1 AVR resource on the web.
* binutils - 20020614
* avrgcc 3.2 - 20020610
* avr-libc - 20020612
* Flavio Gobber's Elf2Coff converter.
* Slightly adapted makefiles for better integration with AVRstudio, based on
the originals by Volker Oth.
* gcctest1-9, avrgcc test projects by Volker Oth. Makefiles adapted according
to the above.
avr-gcc-list at http://avr1.org
- [avr-gcc-list] Using External RAM via the -Tdata approach --- Losing Pointers in the mist,
Brett Abbott <=