4

I want a function to go at specific memory location of Flash and I am not able to figure it out.

Do I need to do modification in Linker File?

Also, I have idea that in GCC, I would use #pragma directives by which I can put my code in specific section but don't know how to assign that section to specific address.

I am using Keil and programming LPC2138.

Trygve Laugstøl
  • 1,410
  • 2
  • 19
  • 28
Swanand
  • 3,275
  • 5
  • 30
  • 46

1 Answers1

4

To put a function in a section with GCC, use a function attribute

extern void foobar (void) __attribute__ ((section ("bar")));

Then, declare a section called bar in your linker script. Eg.

MEMORY
{
  FLASH (rx): ORIGIN=0xDEADBEEF, LENGTH=0x80000000
}

SECTIONS
{
  .bar:
  {
    KEEP(*(.bar))
  } > FLASH
}
Toby Jaffey
  • 28,836
  • 19
  • 98
  • 150