2009-08-13 11:31 PM
How do I assign a fixed address when a variable is created?
2011-05-17 04:20 AM
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.2011-05-17 04:20 AM
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, Vincent2011-05-17 04:20 AM
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 asCode:
int Variable __attribute__((FLASHB1)); I didn't check if this work. Can you test it and report it hire? best reg, J.O.