Flash Versus RAM
2005-11-14 by mhaines4102
Yahoo Groups archive
Index last updated: 2026-04-28 23:31 UTC
Thread
2005-11-14 by mhaines4102
On the 2138, there is 512K of flash and 32K of RAM. Can anyone tell me what goes in flash vs. RAM (i.e. globals, stacks, heap, executing code.) I have lots of assumptions, but would like a clear answer. Thanks in advance.
2005-11-14 by syedismail_sifa
--- In lpc2000@yahoogroups.com, "mhaines4102" <mhaines4102@y...> wrote: > > On the 2138, there is 512K of flash and 32K of RAM. Can anyone tell me > what goes in flash vs. RAM (i.e. globals, stacks, heap, executing > code.) I have lots of assumptions, but would like a clear answer. > > Thanks in advance. > Code goes into flash. The flash can be erased in sectors, so can be used for data. You can also eexecute code from RAM. But the vaiable space and stack is in RAM.
2005-11-14 by Karl Olsen
--- In lpc2000@yahoogroups.com, "mhaines4102" <mhaines4102@y...> wrote: > > On the 2138, there is 512K of flash and 32K of RAM. Can anyone tell > me what goes in flash vs. RAM (i.e. globals, stacks, heap, executing > code.) I have lots of assumptions, but would like a clear answer. When using gcc, you can define this in the linker script and startup files. The normal setup is: Const variables (global and static) go into flash. Uninitialized global and static variables go into RAM (zeroed by the startup code). Initialized global and static variables go into RAM, but their initialization values are in flash, so they take up space both places. Heap goes into RAM. Stack goes into RAM. Code goes into flash. Sometimes you want some functions in RAM. Those functions count as initialized global/static variables. You can always look at the linker map file if in doubt. (Actually, you should look at it even if you aren't in doubt.) Karl Olsen
2005-11-14 by Ake Hedman, eurosource
>Sometimes you want some functions in RAM. Those functions count as >initialized global/static variables. How do one make a function go into ram? /Ake Karl Olsen wrote: > --- In lpc2000@yahoogroups.com, "mhaines4102" <mhaines4102@y...> > wrote: > > > > On the 2138, there is 512K of flash and 32K of RAM. Can anyone tell > > me what goes in flash vs. RAM (i.e. globals, stacks, heap, executing > > code.) I have lots of assumptions, but would like a clear answer. > > When using gcc, you can define this in the linker script and startup > files. The normal setup is: > > Const variables (global and static) go into flash. > > Uninitialized global and static variables go into RAM (zeroed by the > startup code). > > Initialized global and static variables go into RAM, but their > initialization values are in flash, so they take up space both places. > > Heap goes into RAM. > > Stack goes into RAM. > > Code goes into flash. > > Sometimes you want some functions in RAM. Those functions count as > initialized global/static variables. > > You can always look at the linker map file if in doubt. (Actually, > you should look at it even if you aren't in doubt.) > > Karl Olsen > > > > > > > SPONSORED LINKS > Microprocessor > <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=tsVC-J9hJ5qyXg0WPR0l6g> > Microcontrollers > <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq01nxwg> > Pic microcontrollers > <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c6LyBvUqVQ> > > 8051 microprocessor > <http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVIlekkDP-A> > > > > ------------------------------------------------------------------------ > YAHOO! GROUPS LINKS > > * Visit your group "lpc2000 > <http://groups.yahoo.com/group/lpc2000>" on the web. > > * To unsubscribe from this group, send an email to: > lpc2000-unsubscribe@yahoogroups.com > <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service <http://docs.yahoo.com/info/terms/>. > > > ------------------------------------------------------------------------ > -- --- Ake Hedman (YAP - Yet Another Programmer) eurosource, Brattbergavägen 17, 820 50 LOS, Sweden Phone: (46) 657 413430 Cellular: (46) 73 84 84 102 Company home: http://www.eurosource.se Kryddor/Te/Kaffe: http://www.brattberg.com Personal homepage: http://www.eurosource.se/akhe Automated home: http://www.vscp.org [Non-text portions of this message have been removed]
2005-11-14 by Karl Olsen
--- In lpc2000@yahoogroups.com, "Ake Hedman, eurosource" <akhe@b...>
wrote:
>
>> Sometimes you want some functions in RAM. Those functions count
>> as initialized global/static variables.
>
> How do one make a function go into ram?
With gcc, the easiest way is like this:
static void ramfunc (int i) __attribute__ ((section(".data")));
static void ramfunc (int i)
{
/* ... */
}
This means that the compiler puts the function in section .data
instead of .text, and the linker and startup code then locates and
processes it like initialized data, i.e. stores an initial copy in
flash, and lets the startup code copy it to RAM. The final RAM
address is then used when you reference the function.
Note that flash and RAM functions cannot call each other directly
since flash and RAM are more than 32 MB apart in the memory map, out
of reach by the BL instruction. You then have to use indirect calls
through function pointers.
Karl Olsen2005-11-14 by Ake Hedman, eurosource
Thanks a lot Karl. Much valuable info!
/Ake
Karl Olsen wrote:
> --- In lpc2000@yahoogroups.com, "Ake Hedman, eurosource" <akhe@b...>
> wrote:
> >
> >> Sometimes you want some functions in RAM. Those functions count
> >> as initialized global/static variables.
> >
> > How do one make a function go into ram?
>
> With gcc, the easiest way is like this:
>
> static void ramfunc (int i) __attribute__ ((section(".data")));
> static void ramfunc (int i)
> {
> /* ... */
> }
>
> This means that the compiler puts the function in section .data
> instead of .text, and the linker and startup code then locates and
> processes it like initialized data, i.e. stores an initial copy in
> flash, and lets the startup code copy it to RAM. The final RAM
> address is then used when you reference the function.
>
> Note that flash and RAM functions cannot call each other directly
> since flash and RAM are more than 32 MB apart in the memory map, out
> of reach by the BL instruction. You then have to use indirect calls
> through function pointers.
>
> Karl Olsen
>
>
>
>
>
>
> SPONSORED LINKS
> Microprocessor
> <http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=tsVC-J9hJ5qyXg0WPR0l6g>
> Microcontrollers
> <http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq01nxwg>
> Pic microcontrollers
> <http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c6LyBvUqVQ>
>
> 8051 microprocessor
> <http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVIlekkDP-A>
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
> * Visit your group "lpc2000
> <http://groups.yahoo.com/group/lpc2000>" on the web.
>
> * To unsubscribe from this group, send an email to:
> lpc2000-unsubscribe@yahoogroups.com
> <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>
--
---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavägen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 84 84 102
Company home: http://www.eurosource.se
Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org
[Non-text portions of this message have been removed]