Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Flash variables

2005-04-22 by Robert Adsett

At 07:15 PM 4/22/05 +0200, Anton Erasmus wrote:
>On 22 Apr 2005 at 8:52, Richard Duits wrote:
> > Anything you define as const is allocated in the flash (at least gcc
> > does this, have no experience with other compilers yet). Because the
> > arm has only one address space, all memory (flash and ram) is the
> > same, except you cannot write to the flash directly. The only reason
> > you may want to copy to ram is because ram is faster than flash is
> > some cases.
>
>In which version of arm-gcc does const put the variable in the text 
>section. I have
>checked with arm-elf-gcc v3.4.3, and the variable is not put into the 
>.test section
>when const is used. One must explicitly use a __attribute__((section 
>(".text"))).
>
>const int gConstVar=5;   /* Put in .rodata section */
>const int gConstVar1 __attribute__((section (".text")))=6; /* Put in .text 
>section */
>
>The .rodata section is in flash, and then copied to RAM in the startup 
>code. So if
>the intention of using varaibles in flash is to save memory ( Which is 
>usually the case),
>then just declaring the variables const does not suffice.


OK, I'll bite.  Why would you copy the .rodata section to RAM?  I haven't 
seen any need to.  From one of my linker files

  prog : {                               /*  Program (.text) sections    */
         *(.text)                        /* are next, then constant data.*/
         *(.rodata)
         *(.rodata*)
         *(.glue_7)
         *(.glue_7t)
         } >flash
  __end_of_text__ = .;                   /*  Used by startup to find     */
                                         /* initialized vars.            */

And no,  my startup doesn't copy any of the above to RAM

I'm running 3.3.2 (I generally like to stay off the compilers bleeding edge 
:), but I can't imagine they've gone backwards on this particular issue.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.