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

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

Re: [avr-gcc-list] End of program symbol


From: Adam Dunkels
Subject: Re: [avr-gcc-list] End of program symbol
Date: Fri, 09 Jun 2006 01:43:17 +0200
User-agent: Thunderbird 1.5 (X11/20060225)

Pink Boy wrote:
Adam sez,

How about using a ROM/PROGMEM array in which dynamic code is loaded
instead of putting it after _etext? This is what we are doing in
the Contiki OS. One nice thing with this is that you can decide
beforehand how much space you'd like to reserve for the dynamic
code (and you'll be notified by the linker if there isn't enough
space in ROM).
How do you align the array with the 64/128 byte flash sector boundries?

I simply over-allocate the array and make sure that pointers to allocations are properly aligned. I.e., for a 512 byte alignment, I add 512 bytes to the size of the array and round the pointer to the allocated memory upwards to the next 512 byte boundary. Something along the lines of this:

static const PROGMEM unsigned char textmemory[SIZE + 0x200];

static PROGMEM char *allocate_memory() {
  return (char *)
    ((unsigned long)&textmemory[0] & 0xfffffe00) +
    (((unsigned long)&textmemory[0] & 0x1ff) == 0? 0: 0x200);
}

I lose 512 bytes of ROM, but I don't need to fiddle with linker scripts, sections, or #defines.

/adam
--
Adam Dunkels, Swedish Institute of Computer Science
http://www.sics.se/~adam/




reply via email to

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