On 22 Apr 2005 at 15:07, Robert Adsett wrote:
>
> 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.
Sorry, an artifact from working with the AVR. There the .rodata section is handled the
same as the .data section. The variables are placed in RAM and their initial value
copied from flash memory by the startup code. Of course the ARM does not
need this and the .rodata section can be kept in flash.
Regards
Anton Erasmus
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
--
A J ErasmusMessage
Re: [lpc2000] Flash variables
2005-04-22 by Anton Erasmus
Attachments
- No local attachments were found for this message.