[Top][All Lists]

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

Re: [avr-gcc-list] a symbol for end of program memory used?

From: Erik Christiansen
Subject: Re: [avr-gcc-list] a symbol for end of program memory used?
Date: Thu, 29 Apr 2010 23:18:32 +1000
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

On Wed, Apr 28, 2010 at 12:07:18PM -0700, Paul Stoffregen wrote:
> So far, I'm using "__data_load_end" to know where the unused flash memory 
> begins.  Is that the best way?  Does the linker provide any special symbols 
> or other way I can get the end of allocated flash memory as a constant 
> which I can use in my program?

Looking at the avr linker script which I last used, __data_load_end
seems a suitable choice for your purpose, _if_ you have nothing in
.eeprom. All that follows then is .bss and .noinit, neither of which
produce loadable data.

And given:

  .data    : AT (ADDR (.text) + SIZEOF (.text))

   __data_load_start = LOADADDR(.data);
   __data_load_end = __data_load_start + SIZEOF(.data);

it is then an LMA you can use in that case.

But the .eeprom output section specifies an LMA coincident with
__data_load_end. To be safe, I'd place something like the following
after the end of the .eeprom output section in the linker script:

   __vacant_flash = __data_load_end + SIZEOF(.eeprom);

   or with same effect:

   __vacant_flash = LOADADDR(.eeprom) + SIZEOF(.eeprom);

That should just about do it.
(Caveat: Untested; And the hour is late here.)

Better still, would be to use a custom linker script to manage location
of your extra stuff which goes into flash, by adding your own section.
(Oh, all right, that's a little bit more effort.)


Crime does not pay ... as well as politics.
                                                 -- A. E. Newman

reply via email to

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