Yahoo Groups archive

Lpc2000

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

Thread

Flash to RAM

Flash to RAM

2005-10-06 by tripple_toast

I have managed to store in a flash sector code that is compiled to
run from RAM.  At boot I wish to copy this code from flash to RAM and 
then
run the code in RAM.

Is this possible using the LPC213x?

What do I need to do in the boot file of the flash code to get the RAM 
code running?

Thanks.

Re: [lpc2000] Flash to RAM

2005-10-06 by Richard Duits

This depends on the compiler/tools you use. With GNU you can do this in 
the linker script and startup.s (similar to initialized variables). The 
Keil compiler has a function attribute that lets you run some functions 
from ram. Don't know about other compilers.

Richard Duits.




tripple_toast wrote:
Show quoted textHide quoted text
> I have managed to store in a flash sector code that is compiled to
> run from RAM.  At boot I wish to copy this code from flash to RAM and
> then
> run the code in RAM.
>
> Is this possible using the LPC213x?
>
> What do I need to do in the boot file of the flash code to get the RAM
> code running?
>
> Thanks.
>
>
>
>
>
> 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/>.
>
>
> ------------------------------------------------------------------------
>

Re: Flash to RAM

2005-10-06 by tripple_toast

Thanks for the reply.

So all I need is a section of assembler in boot.s that copies the 
compiled RAM code from flash to RAM.
I've tried the approach of altering the initialised variables routine 
without success ( my arm assembler knowledge is not so good ).

Once this is copied then how does the RAM code run.  Is it a matter 
of setting PC to a RAM start address?

I'm ensuring that the RAM code is not using any of the ISP RAM area 
by loading it into 0x40000200

Will I need to set MEMMAP to RAM, I'm not using any IRQ's?



--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
> This depends on the compiler/tools you use. With GNU you can do 
this in 
> the linker script and startup.s (similar to initialized variables). 
The 
> Keil compiler has a function attribute that lets you run some 
functions 
> from ram. Don't know about other compilers.
> 
> Richard Duits.
> 
> 
> 
> 
> tripple_toast wrote:
> 
> > I have managed to store in a flash sector code that is compiled to
> > run from RAM.  At boot I wish to copy this code from flash to RAM 
and
> > then
> > run the code in RAM.
> >
> > Is this possible using the LPC213x?
> >
> > What do I need to do in the boot file of the flash code to get 
the RAM
> > code running?
> >
> > Thanks.
> >
> >
> >
> >
> >
> > SPONSORED LINKS
> > Microprocessor 
> > <http://groups.yahoo.com/gads?
t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+mic
rocontrollers&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+m
icrocontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq0
1nxwg> 
> > 	Pic microcontrollers 
> > <http://groups.yahoo.com/gads?
t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=P
ic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c
6LyBvUqVQ> 
> >
> > 8051 microprocessor 
> > <http://groups.yahoo.com/gads?
t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pi
c+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVI
lekkDP-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/>.
> >
> >
> > ------------------------------------------------------------------
------
> >

Re: [lpc2000] Re: Flash to RAM

2005-10-06 by Richard Duits

I assume you use GCC. You also need to change the linker script to let 
the linker know that the code is stored in flash but it will be running 
from RAM (just like the initialized variables section). When you copied 
the code to ram, you just load the address of your main routine in pc. 
If you use interrupts, you may change the MEMMAP register, but this is 
not needed because the MAM will cache the bytes used by the interrupt 
vector and it will run just as fast as in RAM. I never did this myself, 
so I have no example code to share with you, maybe someone else?

Richard Duits


tripple_toast wrote:
Show quoted textHide quoted text
> Thanks for the reply.
>
> So all I need is a section of assembler in boot.s that copies the
> compiled RAM code from flash to RAM.
> I've tried the approach of altering the initialised variables routine
> without success ( my arm assembler knowledge is not so good ).
>
> Once this is copied then how does the RAM code run.  Is it a matter
> of setting PC to a RAM start address?
>
> I'm ensuring that the RAM code is not using any of the ISP RAM area
> by loading it into 0x40000200
>
> Will I need to set MEMMAP to RAM, I'm not using any IRQ's?
>
>
>
> --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
> > This depends on the compiler/tools you use. With GNU you can do
> this in
> > the linker script and startup.s (similar to initialized variables).
> The
> > Keil compiler has a function attribute that lets you run some
> functions
> > from ram. Don't know about other compilers.
> >
> > Richard Duits.
> >
> >
> >
> >
> > tripple_toast wrote:
> >
> > > I have managed to store in a flash sector code that is compiled to
> > > run from RAM.  At boot I wish to copy this code from flash to RAM
> and
> > > then
> > > run the code in RAM.
> > >
> > > Is this possible using the LPC213x?
> > >
> > > What do I need to do in the boot file of the flash code to get
> the RAM
> > > code running?
> > >
> > > Thanks.
> > >
> > >
> > >
> > >
> > >
> > > SPONSORED LINKS
> > > Microprocessor
> > > <http://groups.yahoo.com/gads?
> t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+mic
> rocontrollers&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+m
> icrocontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq0
> 1nxwg>
> > >       Pic microcontrollers
> > > <http://groups.yahoo.com/gads?
> t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=P
> ic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c
> 6LyBvUqVQ>
> > >
> > > 8051 microprocessor
> > > <http://groups.yahoo.com/gads?
> t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pi
> c+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVI
> lekkDP-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/>.
> > >
> > >
> > > ------------------------------------------------------------------
> ------
> > >
>
>
>
>
> 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/>.
>
>
> ------------------------------------------------------------------------
>

Re: Flash to RAM

2005-10-07 by tripple_toast

Hi Richard,

Thanks for being my sounding block, I've now got the RAM code stored 
in flash running from RAM at boot.

>>I assume you use GCC.

GNUARM

>>You also need to change the linker script to let
>>the linker know that the code is stored in flash but it will be 
running
>>from RAM (just like the initialized variables section).

At the moment my boot app just uses hardcoded addresses to relocate 
the RAM code, are you saying I should use the linker script for the 
boot app and create a new section similar to the initialised 
variables section i.e.

  .data : AT (_etext)
  {
    _data = .;
    *(.data)
  } > RAM


--- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
>
> I assume you use GCC. You also need to change the linker script to 
let 
> the linker know that the code is stored in flash but it will be 
running 
> from RAM (just like the initialized variables section). When you 
copied 
> the code to ram, you just load the address of your main routine in 
pc. 
> If you use interrupts, you may change the MEMMAP register, but this 
is 
> not needed because the MAM will cache the bytes used by the 
interrupt 
> vector and it will run just as fast as in RAM. I never did this 
myself, 
> so I have no example code to share with you, maybe someone else?
> 
> Richard Duits
> 
> 
> tripple_toast wrote:
> 
> > Thanks for the reply.
> >
> > So all I need is a section of assembler in boot.s that copies the
> > compiled RAM code from flash to RAM.
> > I've tried the approach of altering the initialised variables 
routine
> > without success ( my arm assembler knowledge is not so good ).
> >
> > Once this is copied then how does the RAM code run.  Is it a 
matter
> > of setting PC to a RAM start address?
> >
> > I'm ensuring that the RAM code is not using any of the ISP RAM 
area
> > by loading it into 0x40000200
> >
> > Will I need to set MEMMAP to RAM, I'm not using any IRQ's?
> >
> >
> >
> > --- In lpc2000@yahoogroups.com, Richard Duits <yahoo@r...> wrote:
> > > This depends on the compiler/tools you use. With GNU you can do
> > this in
> > > the linker script and startup.s (similar to initialized 
variables).
> > The
> > > Keil compiler has a function attribute that lets you run some
> > functions
> > > from ram. Don't know about other compilers.
> > >
> > > Richard Duits.
> > >
> > >
> > >
> > >
> > > tripple_toast wrote:
> > >
> > > > I have managed to store in a flash sector code that is 
compiled to
> > > > run from RAM.  At boot I wish to copy this code from flash to 
RAM
> > and
> > > > then
> > > > run the code in RAM.
> > > >
> > > > Is this possible using the LPC213x?
> > > >
> > > > What do I need to do in the boot file of the flash code to get
> > the RAM
> > > > code running?
> > > >
> > > > Thanks.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > SPONSORED LINKS
> > > > Microprocessor
> > > > <http://groups.yahoo.com/gads?
> > 
t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+mic
> > rocontrollers&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+m
> > 
icrocontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq0
> > 1nxwg>
> > > >       Pic microcontrollers
> > > > <http://groups.yahoo.com/gads?
> > 
t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=P
> > 
ic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c
> > 6LyBvUqVQ>
> > > >
> > > > 8051 microprocessor
> > > > <http://groups.yahoo.com/gads?
> > 
t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pi
> > 
c+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVI
> > lekkDP-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/>.
> > > >
> > > >
> > > > --------------------------------------------------------------
----
> > ------
> > > >
> >
> >
> >
> >
> > SPONSORED LINKS
> > Microprocessor 
> > <http://groups.yahoo.com/gads?
t=ms&k=Microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pic+mic
rocontrollers&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+m
icrocontrollers&w4=8051+microprocessor&c=4&s=93&.sig=DvJVNqC_pqRTm8Xq0
1nxwg> 
> > 	Pic microcontrollers 
> > <http://groups.yahoo.com/gads?
t=ms&k=Pic+microcontrollers&w1=Microprocessor&w2=Microcontrollers&w3=P
ic+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=TpkoX4KofDJ7c
6LyBvUqVQ> 
> >
> > 8051 microprocessor 
> > <http://groups.yahoo.com/gads?
t=ms&k=8051+microprocessor&w1=Microprocessor&w2=Microcontrollers&w3=Pi
c+microcontrollers&w4=8051+microprocessor&c=4&s=93&.sig=1Ipf1Fjfbd_HVI
lekkDP-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/>.
> >
> >
> > ------------------------------------------------------------------
------
> >
>

Re: [lpc2000] Re: Flash to RAM

2005-10-07 by Richard Duits

It may be easier to add the *(.text) to the initialized data section. It 
may be a bit of a hack, but this way you you can leave to startup/boot 
code unchanged (just tought of this, otherwise I would have mentioned it 
sooner). Make sure that the startup/boot code is in flash if you do this.


tripple_toast wrote:
Show quoted textHide quoted text
> Hi Richard,
>
> Thanks for being my sounding block, I've now got the RAM code stored
> in flash running from RAM at boot.
>
> >>I assume you use GCC.
>
> GNUARM
>
> >>You also need to change the linker script to let
> >>the linker know that the code is stored in flash but it will be
> running
> >>from RAM (just like the initialized variables section).
>
> At the moment my boot app just uses hardcoded addresses to relocate
> the RAM code, are you saying I should use the linker script for the
> boot app and create a new section similar to the initialised
> variables section i.e.
>
>   .data : AT (_etext)
>   {
>     _data = .;
>     *(.data)
>   } > RAM
>
>

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.