Passing constant from program to linker script

Asked by Prakash K Balasubramanian

I need to reserve some part of the flash and the following is my failed attempt.

PROVIDE (FLASH_RESERVED_LENGTH = 0);

MEMORY
{
 FLASH(RX) : ORIGIN = 0x10001000, LENGTH = (0x32000 - FLASH_RESERVED_LENGTH)
 SRAM(!RX) : ORIGIN = 0x20000000, LENGTH = 0x4000
}

In a certain C file, I have "const unsigned FLASH_RESERVED_LENGTH = 16000;"

Linker complains of non-constant expression for length.

How can I control the size of a memory region using a technique similar to above?

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Terry Guo (terry.guo) said :
#1

I am afraid that we can't handle it like this. Here is quoted from LD manual at http://sourceware.org/binutils/docs/ld/MEMORY.html#MEMORY

"The len is an expression for the size in bytes of the memory region. As with the origin expression, the expression must be numerical only and must evaluate to a constant. The keyword LENGTH may be abbreviated to len or l."

Revision history for this message
Terry Guo (terry.guo) said :
#2

Can you help with this problem?

Provide an answer of your own, or ask Prakash K Balasubramanian for more information if necessary.

To post a message you must log in.