Yahoo Groups archive

Lpc2000

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

Message

Re: How to get a function running in RAM (Lpc21xx+GnuArm)?

2006-01-19 by arkeryd

Thanks to all who replied!

I ended up defining a section named ram_func in the .ld file similiar
to the example from analog electronics and added "__attribute__
((section(".ram_func")));" to the headers of each function I want to
have in ram.

This works fine, and for some reason unknown for me this avoids the
compiler warnings that arrise when just declaring "__atribute__
((section(".data")));". :-)

If anybody is interested, I did the changes listed further below
compared to the default .ld file for LPC2129.

Btw, if anybody knows how to calculate the "_ramfuncetext" value
without needing to explicitly specify "- 0x40000000", I would be glad
to know how!

/ Dennis


...

MEMORY
{
  CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x0001E000
  DATA (rw) : ORIGIN = 0x40000000, LENGTH = 0x00003FE0
}


/* Section Definitions */

SECTIONS
{

  ...

  _etext = . ;
  PROVIDE (etext = .);

  /* .data section which is used for initialized data */

  .data : AT (_etext)
  {
    _data = . ;
    *(.data)
    SORT(CONSTRUCTORS)
  } >DATA
  . = ALIGN(4);

  _foo = . ;
  _ramfuncetext = _foo - 0x40000000 + _etext;
  PROVIDE (ramfuncetext = .);

  .ram_func : AT (_ramfuncetext)
  {
    _ram_func = .;
    *(.ram_func)
  } >DATA
  . = ALIGN(4);

  ...

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.