cancel
Showing results for 
Search instead for 
Did you mean: 

How do I assign a fixed address when a variable is created?

design5
Associate II
Posted on August 14, 2009 at 08:31

How do I assign a fixed address when a variable is created?

3 REPLIES 3
design5
Associate II
Posted on May 17, 2011 at 13:20

Hi Fellow Programmers and ST Support:

Does anybody know how to assign a fixed address to a variable (not a pointer) at creation time?

I seem to remember some compilers allow the @ symbol to do this, for example:

u8 abc @ 0x60000000; // create ''abc'' and locate at 0x60000000 address

However, the GNU tool chain does not recognize the @ symbol, so perhaps there is another way. This type of operation is useful to create large arrays in external memory space, but I don't know how it would work with RIDE7.

Any help would be appreciated.

Thanks,

Garry.

vincentchoplin9
Associate II
Posted on May 17, 2011 at 13:20

Hi,

The GNU linker is a one-pass linker and therefore cannot implement this kind of syntax.

For doing what you request, you must make changes in the linker script, declare a memory region at the address, and an associated section. Or just declare a memory region for your external memory and let the linker place objects in it, if you have several.

See the GNU linker doc for the syntax of the commands in the linker script, and the GettingStartedARM doc from Ride for how to use a custom linker script in Ride, and retrieve the default version for using as starting point.

I hope it helps.

Best Regards,

Vincent

jaroslaw2
Associate II
Posted on May 17, 2011 at 13:20

Hi,

When you work with RIDE7 with GCC you wave it already done.

In linker script you have FLASHB1 region that you can use.

Code:

MEMORY

{

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K

FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K

FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0

EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0

EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0

EXTMEMB2 (rx) : ORIGIN = 0x00000000, LENGTH = 0

EXTMEMB3 (rx) : ORIGIN = 0x00000000, LENGTH = 0

}

And then you can use it as

Code:

int Variable __attribute__((FLASHB1));

I didn't check if this work. Can you test it and report it hire?

best reg,

J.O.