4
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.