[arm-gnu] Placing variable at absolute address in RAM
JM
hondgm at yahoo.com
Thu Apr 5 14:12:25 UTC 2012
I started implementing your suggestion, but realized I have to split off a piece of RAM for HWMAP, which will waste a considerable amount of RAM...unless I'm misunderstanding something.
What I need, ideally, is to reserve 16 bytes at an arbitrary place in the RAM space. Unfortunately, since it must be 464 bytes after a 1024 byte boundary, it ends up being "in the middle" somewhere. About 12K of the 96K is global or statically assigned, and the rest is allocated dynamically in fairly large chunks using a proprietary allocation system.
I had no idea this would be so difficult, but apparently GCC doesn't make this easy, unlike other compilers. Since I'm using the lite (free) compiler, buying one really isn't an option for hobby use.
________________________________
From: Alexander Zakharov <azakharov at uniserve.com>
To: tom_usenet at optusnet.com.au; 'JM' <hondgm at yahoo.com>
Cc: arm-gnu at codesourcery.com
Sent: Thursday, April 5, 2012 3:24 AM
Subject: RE: [arm-gnu] Placing variable at absolute address in RAM
This is what I used in a past:
In linker 'helper' file hwmap.ld
............
.dmaRegisters 0X70000000 (NOLOAD): {
*(.dmaRegisters) } > HWMAP
............
In source file hwmap.c
.......
DMA_REGISTERS dmaRegisters
__attribute__ ((used,section(".dmaRegisters")));
.......
In header file dmaRegisters.h
.......
typedef struct
{
/* Something */
} DMA_REGISTERS;
extern DMA_REGISTERS dmaRegisters;
.........
And finally, in a main linker file my_board.ld
......
MEMORY
{
RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 16M
ROM (rwx) : ORIGIN = 0xFFFFFFFF, LENGTH = 0
ALIASMEM (rwx) : ORIGIN = 0x10000000, LENGTH = 16M
HWMAP (rw ) : ORIGIN = 0x20000000, LENGTH = 3584M
}
......
/* Include hardware registers maps */
INCLUDE hwmap.ld
.....
Then you just use dmaRegisters in your code like " dmaRegisters.field = X; "
Hope it helps. This way you can 'stick' your variable in any place in a
memory - this is how I implemented my hardware registers access in a past,
but should work like a charm for your cause.
Cheers,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/arm-gnu/attachments/20120405/464b1edb/attachment.html>
More information about the arm-gnu
mailing list