avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] code size: .text vs .data


From: Dave Hylands
Subject: RE: [avr-gcc-list] code size: .text vs .data
Date: Fri, 11 Jun 2004 11:42:14 -0700

Hi Pete,

OK, here's a bit about the behind the scenes, and where the 8K limit is
coming from.

Run 

        avr-ld --verbose > ld.txt

If you examine the ld.txt file, you'll see a section that has this:

MEMORY
{
  text   (rx)   : ORIGIN = 0,    LENGTH = 8K
  data   (rw!x) : ORIGIN = (0x800000 + 0x60), LENGTH = 512
  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 512
}

So that's where the limitation is coming from.

If, as a couple of other people have suggested, you pass in
-mmcu=atmega32, then this winds up passing in -m avr5 to the avr-ld
command. If you run:

        avr-ld -m avr5 --verbose > ld2.txt

You'll see that the memory area has been increased:

MEMORY
{
  text   (rx)   : ORIGIN = 0, LENGTH = 128K
  data   (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0
  eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K
}

This will allow your code to work, but won't tell you when you've filled
up the 32k. I normally like to create my own linker script and set the
sizes to be exactly right.

You can make a copy of the avr5 script
(c:\WinAVR\avr\lib\ldscripts\avr5.x) and change the memory size to 32K.
I normally us a .ld or .lds extension on my ld scripts. You can tell gcc
you use your ld script instead of the builtin one:

        avr-gcc -mmcu=atmega32 -Wl,-T,myscript.ld,-Map,a.out.map -lm  -o
a.out a.o b.o c.o ...

Incidently, if you pass in a -v to gcc, then it will show the complete
command line that it passes to all of the various sub-programs (which is
how I knew that -mmcu=atmega32 caused -m avr 5 to be passed to avr-ld).

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/ 

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On Behalf Of Pat Deegan
> Sent: Friday, June 11, 2004 10:45 AM
> To: address@hidden
> Subject: RE: [avr-gcc-list] code size: .text vs .data
> 
> 
> Hello,
> 
> On Fri, 2004-06-11 at 13:32, Dave Hylands wrote:
> > You need to modify your linker script. This is what defines 
> how much 
> > space goes where.
> > 
> > What's the exact command that you used to link your program?
> 
> Well, I'm using the generic Makefile we put together to build 
> the program (see 
> http://electrons.psychogenic.com/avr/linux/makefile.php). 
> 
> Using this, the final step is simply:
> 
>   avr-gcc -Wl,-Map,a.out.map -lm  -o a.out a.o b.o c.o ...
> 
> I am uncertain as to what's going on behind the scenes.
> 
> 
> Where can I find out how to tweak the linking or do you have 
> any suggestions?
> 
> Thanks,
> -- 
> Pat Deegan
> http://www.psychogenic.com/
> PGP Key: http://www.keyserver.net 0x03F86A50
> 
> 
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden 
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]